Class: WalmartApIs::GetRatesRequest
- Defined in:
- lib/walmart_ap_is/models/get_rates_request.rb
Overview
GetRatesRequest Model.
Instance Attribute Summary collapse
-
#channel_details ⇒ ChannelDetails
When the shipment will be tendered to the carrier.
-
#packages ⇒ Array[Package]
When the shipment will be tendered to the carrier.
-
#return_to ⇒ Address1
TODO: Write general description for this method.
-
#service_selection ⇒ ServiceSelection
Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).
-
#ship_date ⇒ DateTime
When the shipment will be tendered to the carrier.
-
#ship_from ⇒ Address1
TODO: Write general description for this method.
-
#ship_to ⇒ Address1
TODO: Write general description for this method.
-
#value_added_services ⇒ Array[RequestedValueAddedService]
Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).
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.
Instance Method Summary collapse
-
#initialize(ship_to:, ship_from:, packages:, channel_details:, return_to: SKIP, ship_date: SKIP, service_selection: SKIP, value_added_services: SKIP, additional_properties: nil) ⇒ GetRatesRequest
constructor
A new instance of GetRatesRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_ship_date ⇒ Object
-
#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(ship_to:, ship_from:, packages:, channel_details:, return_to: SKIP, ship_date: SKIP, service_selection: SKIP, value_added_services: SKIP, additional_properties: nil) ⇒ GetRatesRequest
Returns a new instance of GetRatesRequest.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 76 def initialize(ship_to:, ship_from:, packages:, channel_details:, return_to: SKIP, ship_date: SKIP, service_selection: SKIP, value_added_services: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @ship_to = ship_to @ship_from = ship_from @return_to = return_to unless return_to == SKIP @ship_date = ship_date unless ship_date == SKIP @packages = packages @channel_details = channel_details @service_selection = service_selection unless service_selection == SKIP @value_added_services = value_added_services unless value_added_services == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#channel_details ⇒ ChannelDetails
When the shipment will be tendered to the carrier.
35 36 37 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 35 def channel_details @channel_details end |
#packages ⇒ Array[Package]
When the shipment will be tendered to the carrier.
31 32 33 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 31 def packages @packages end |
#return_to ⇒ Address1
TODO: Write general description for this method
23 24 25 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 23 def return_to @return_to end |
#service_selection ⇒ ServiceSelection
Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).
40 41 42 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 40 def service_selection @service_selection end |
#ship_date ⇒ DateTime
When the shipment will be tendered to the carrier.
27 28 29 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 27 def ship_date @ship_date end |
#ship_from ⇒ Address1
TODO: Write general description for this method
19 20 21 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 19 def ship_from @ship_from end |
#ship_to ⇒ Address1
TODO: Write general description for this method
15 16 17 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 15 def ship_to @ship_to end |
#value_added_services ⇒ Array[RequestedValueAddedService]
Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).
45 46 47 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 45 def value_added_services @value_added_services end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
94 95 96 97 98 99 100 101 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 142 143 144 145 146 147 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 94 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. ship_to = Address1.from_hash(hash['shipTo']) if hash['shipTo'] ship_from = Address1.from_hash(hash['shipFrom']) if hash['shipFrom'] # Parameter is an array, so we need to iterate through it packages = nil unless hash['packages'].nil? packages = [] hash['packages'].each do |structure| packages << (Package.from_hash(structure) if structure) end end packages = nil unless hash.key?('packages') channel_details = ChannelDetails.from_hash(hash['channelDetails']) if hash['channelDetails'] return_to = Address1.from_hash(hash['returnTo']) if hash['returnTo'] ship_date = if hash.key?('shipDate') (DateTimeHelper.from_rfc3339(hash['shipDate']) if hash['shipDate']) else SKIP end service_selection = ServiceSelection.from_hash(hash['serviceSelection']) if hash['serviceSelection'] # Parameter is an array, so we need to iterate through it value_added_services = nil unless hash['valueAddedServices'].nil? value_added_services = [] hash['valueAddedServices'].each do |structure| value_added_services << (RequestedValueAddedService.from_hash(structure) if structure) end end value_added_services = SKIP unless hash.key?('valueAddedServices') # 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. GetRatesRequest.new(ship_to: ship_to, ship_from: ship_from, packages: packages, channel_details: channel_details, return_to: return_to, ship_date: ship_date, service_selection: service_selection, value_added_services: value_added_services, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 48 def self.names @_hash = {} if @_hash.nil? @_hash['ship_to'] = 'shipTo' @_hash['ship_from'] = 'shipFrom' @_hash['return_to'] = 'returnTo' @_hash['ship_date'] = 'shipDate' @_hash['packages'] = 'packages' @_hash['channel_details'] = 'channelDetails' @_hash['service_selection'] = 'serviceSelection' @_hash['value_added_services'] = 'valueAddedServices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
62 63 64 65 66 67 68 69 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 62 def self.optionals %w[ return_to ship_date service_selection value_added_services ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
163 164 165 166 167 168 169 170 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 163 def inspect class_name = self.class.name.split('::').last "<#{class_name} ship_to: #{@ship_to.inspect}, ship_from: #{@ship_from.inspect}, return_to:"\ " #{@return_to.inspect}, ship_date: #{@ship_date.inspect}, packages: #{@packages.inspect},"\ " channel_details: #{@channel_details.inspect}, service_selection:"\ " #{@service_selection.inspect}, value_added_services: #{@value_added_services.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_ship_date ⇒ Object
149 150 151 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 149 def to_custom_ship_date DateTimeHelper.to_rfc3339(ship_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
154 155 156 157 158 159 160 |
# File 'lib/walmart_ap_is/models/get_rates_request.rb', line 154 def to_s class_name = self.class.name.split('::').last "<#{class_name} ship_to: #{@ship_to}, ship_from: #{@ship_from}, return_to: #{@return_to},"\ " ship_date: #{@ship_date}, packages: #{@packages}, channel_details: #{@channel_details},"\ " service_selection: #{@service_selection}, value_added_services: #{@value_added_services},"\ " additional_properties: #{@additional_properties}>" end |