Class: WalmartApIs::OneClickShipmentRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/one_click_shipment_request.rb

Overview

OneClickShipmentRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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:, service_selection:, requested_document_specification:, channel_details:, return_to: SKIP, ship_date: SKIP, value_added_services: SKIP, additional_properties: nil) ⇒ OneClickShipmentRequest

Returns a new instance of OneClickShipmentRequest.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 83

def initialize(ship_to:, ship_from:, packages:, service_selection:,
               requested_document_specification:, channel_details:,
               return_to: SKIP, ship_date: 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
  @service_selection = service_selection
  @value_added_services = value_added_services unless value_added_services == SKIP
  @requested_document_specification = requested_document_specification
  @channel_details = channel_details
  @additional_properties = additional_properties
end

Instance Attribute Details

#channel_detailsChannelDetails

Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).

Returns:



51
52
53
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 51

def channel_details
  @channel_details
end

#packagesArray[Package]

TODO: Write general description for this method

Returns:



31
32
33
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 31

def packages
  @packages
end

#requested_document_specificationRequestedDocumentSpecification

Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).



46
47
48
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 46

def requested_document_specification
  @requested_document_specification
end

#return_toAddress1

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 23

def return_to
  @return_to
end

#service_selectionServiceSelection

Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).

Returns:



36
37
38
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 36

def service_selection
  @service_selection
end

#ship_dateDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


27
28
29
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 27

def ship_date
  @ship_date
end

#ship_fromAddress1

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 19

def ship_from
  @ship_from
end

#ship_toAddress1

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 15

def ship_to
  @ship_to
end

#value_added_servicesArray[RequestedValueAddedService]

Optional seller-supplied filter to restrict the rate quote to a specific carrier(s) and/or service(s).

Returns:



41
42
43
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 41

def value_added_services
  @value_added_services
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 103

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')
  service_selection = ServiceSelection.from_hash(hash['serviceSelection']) if
    hash['serviceSelection']
  if hash['requestedDocumentSpecification']
    requested_document_specification = RequestedDocumentSpecification.from_hash(hash['requestedDocumentSpecification'])
  end
  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
  # 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.
  OneClickShipmentRequest.new(ship_to: ship_to,
                              ship_from: ship_from,
                              packages: packages,
                              service_selection: service_selection,
                              requested_document_specification: requested_document_specification,
                              channel_details: channel_details,
                              return_to: return_to,
                              ship_date: ship_date,
                              value_added_services: value_added_services,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 54

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['service_selection'] = 'serviceSelection'
  @_hash['value_added_services'] = 'valueAddedServices'
  @_hash['requested_document_specification'] =
    'requestedDocumentSpecification'
  @_hash['channel_details'] = 'channelDetails'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



70
71
72
73
74
75
76
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 70

def self.optionals
  %w[
    return_to
    ship_date
    value_added_services
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



177
178
179
180
181
182
183
184
185
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 177

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},"\
  " service_selection: #{@service_selection.inspect}, value_added_services:"\
  " #{@value_added_services.inspect}, requested_document_specification:"\
  " #{@requested_document_specification.inspect}, channel_details:"\
  " #{@channel_details.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_ship_dateObject



162
163
164
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 162

def to_custom_ship_date
  DateTimeHelper.to_rfc3339(ship_date)
end

#to_sObject

Provides a human-readable string representation of the object.



167
168
169
170
171
172
173
174
# File 'lib/walmart_ap_is/models/one_click_shipment_request.rb', line 167

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}, service_selection:"\
  " #{@service_selection}, value_added_services: #{@value_added_services},"\
  " requested_document_specification: #{@requested_document_specification}, channel_details:"\
  " #{@channel_details}, additional_properties: #{@additional_properties}>"
end