Class: UspsApi::DomesticOptionsRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::DomesticOptionsRequest
- Defined in:
- lib/usps_api/models/domestic_options_request.rb
Overview
Domestic Options Request
Instance Attribute Summary collapse
-
#destination_entry_facility_type ⇒ DestinationEntryFacilityType1
Types of Facilities: * NONE - Translate to Destination Rate Indicator N * DESTINATION_NETWORK_DISTRIBUTION_CENTER - Translate to Destination Rate Indicator B * DESTINATION_SECTIONAL_CENTER_FACILITY - Translate to Destination Rate Indicator S * DESTINATION_DELIVERY_UNIT - Translate to Destination Rate Indicator D * DESTINATION_SERVICE_HUB - Translate to Destination Rate Indicator H * DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER - Translate to Destination Rate Indicator B Note: - The Destination Entry Facility Type is only used in calculating Shipping Standards.
-
#destination_zip_code ⇒ String
The destination ZIP code for the package.
-
#origin_zip_code ⇒ String
The originating ZIP code for the package.
-
#package_description ⇒ DomesticPackageDescription
Details of package being shipped.
-
#pricing_options ⇒ Array[DomesticPricingOption]
List of domestic pricing options.
-
#shipping_filter ⇒ ShippingFilter
A filter for domestic results to return only one response based on lowest price or fastest service standard.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(pricing_options:, origin_zip_code:, destination_zip_code:, package_description:, destination_entry_facility_type: DestinationEntryFacilityType1::NONE, shipping_filter: SKIP, additional_properties: nil) ⇒ DomesticOptionsRequest
constructor
A new instance of DomesticOptionsRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(pricing_options:, origin_zip_code:, destination_zip_code:, package_description:, destination_entry_facility_type: DestinationEntryFacilityType1::NONE, shipping_filter: SKIP, additional_properties: nil) ⇒ DomesticOptionsRequest
Returns a new instance of DomesticOptionsRequest.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 80 def initialize( pricing_options:, origin_zip_code:, destination_zip_code:, package_description:, destination_entry_facility_type: DestinationEntryFacilityType1::NONE, shipping_filter: SKIP, additional_properties: nil ) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @pricing_options = @origin_zip_code = origin_zip_code @destination_zip_code = destination_zip_code unless destination_entry_facility_type == SKIP @destination_entry_facility_type = destination_entry_facility_type end @package_description = package_description @shipping_filter = shipping_filter unless shipping_filter == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#destination_entry_facility_type ⇒ DestinationEntryFacilityType1
Types of Facilities:
-
NONE - Translate to Destination Rate Indicator N
-
DESTINATION_NETWORK_DISTRIBUTION_CENTER - Translate to Destination Rate
Indicator B
-
DESTINATION_SECTIONAL_CENTER_FACILITY - Translate to Destination Rate
Indicator S
-
DESTINATION_DELIVERY_UNIT - Translate to Destination Rate Indicator D
-
DESTINATION_SERVICE_HUB - Translate to Destination Rate Indicator H
-
DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER - Translate to
Destination Rate Indicator B Note:
-
The Destination Entry Facility Type is only used in calculating Shipping
Standards.
-
Effective 01/18/2026: ‘DESTINATION_NETWORK_DISTRIBUTION_CENTER` with
‘PARCEL_SELECT` is no longer eligible.
-
Effective 01/18/2026: (NSA Only)
‘DESTINATION_REGIONAL_PROCESSING_DISTRIBUTION_CENTER` with `PARCEL_SELECT` is available as an option.
43 44 45 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 43 def destination_entry_facility_type @destination_entry_facility_type end |
#destination_zip_code ⇒ String
The destination ZIP code for the package.
22 23 24 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 22 def destination_zip_code @destination_zip_code end |
#origin_zip_code ⇒ String
The originating ZIP code for the package.
18 19 20 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 18 def origin_zip_code @origin_zip_code end |
#package_description ⇒ DomesticPackageDescription
Details of package being shipped
47 48 49 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 47 def package_description @package_description end |
#pricing_options ⇒ Array[DomesticPricingOption]
List of domestic pricing options
14 15 16 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 14 def @pricing_options end |
#shipping_filter ⇒ ShippingFilter
A filter for domestic results to return only one response based on lowest price or fastest service standard
52 53 54 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 52 def shipping_filter @shipping_filter end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 102 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it = nil unless hash['pricingOptions'].nil? = [] hash['pricingOptions'].each do |structure| << (DomesticPricingOption.from_hash(structure) if structure) end end = nil unless hash.key?('pricingOptions') origin_zip_code = hash.key?('originZIPCode') ? hash['originZIPCode'] : nil destination_zip_code = hash.key?('destinationZIPCode') ? hash['destinationZIPCode'] : nil package_description = DomesticPackageDescription.from_hash(hash['packageDescription']) if hash['packageDescription'] destination_entry_facility_type = hash['destinationEntryFacilityType'] ||= DestinationEntryFacilityType1::NONE shipping_filter = hash.key?('shippingFilter') ? hash['shippingFilter'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. DomesticOptionsRequest.new(pricing_options: , origin_zip_code: origin_zip_code, destination_zip_code: destination_zip_code, package_description: package_description, destination_entry_facility_type: destination_entry_facility_type, shipping_filter: shipping_filter, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 55 def self.names @_hash = {} if @_hash.nil? @_hash['pricing_options'] = 'pricingOptions' @_hash['origin_zip_code'] = 'originZIPCode' @_hash['destination_zip_code'] = 'destinationZIPCode' @_hash['destination_entry_facility_type'] = 'destinationEntryFacilityType' @_hash['package_description'] = 'packageDescription' @_hash['shipping_filter'] = 'shippingFilter' @_hash end |
.nullables ⇒ Object
An array for nullable fields
76 77 78 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 76 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
68 69 70 71 72 73 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 68 def self.optionals %w[ destination_entry_facility_type shipping_filter ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 145 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value., ->(val) { DomesticPricingOption.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.origin_zip_code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.destination_zip_code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.package_description, ->(val) { DomesticPackageDescription.validate(val) }, is_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['pricingOptions'], ->(val) { DomesticPricingOption.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['originZIPCode'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['destinationZIPCode'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['packageDescription'], ->(val) { DomesticPackageDescription.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
189 190 191 192 193 194 195 196 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 189 def inspect class_name = self.class.name.split('::').last "<#{class_name} pricing_options: #{@pricing_options.inspect}, origin_zip_code:"\ " #{@origin_zip_code.inspect}, destination_zip_code: #{@destination_zip_code.inspect},"\ " destination_entry_facility_type: #{@destination_entry_facility_type.inspect},"\ " package_description: #{@package_description.inspect}, shipping_filter:"\ " #{@shipping_filter.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
180 181 182 183 184 185 186 |
# File 'lib/usps_api/models/domestic_options_request.rb', line 180 def to_s class_name = self.class.name.split('::').last "<#{class_name} pricing_options: #{@pricing_options}, origin_zip_code: #{@origin_zip_code},"\ " destination_zip_code: #{@destination_zip_code}, destination_entry_facility_type:"\ " #{@destination_entry_facility_type}, package_description: #{@package_description},"\ " shipping_filter: #{@shipping_filter}, additional_properties: #{@additional_properties}>" end |