-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathget_with_shipment_details.rb
More file actions
353 lines (318 loc) · 14.7 KB
/
get_with_shipment_details.rb
File metadata and controls
353 lines (318 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# frozen_string_literal: true
module ShipEngine
module Domain
class Rates
module GetWithShipmentDetails
class Response
attr_reader :shipment_id,
:carrier_id,
:service_code,
:external_order_id,
:items,
:tax_identifiers,
:external_shipment_id,
:ship_date,
:created_at,
:modified_at,
:shipment_status,
:ship_to,
:ship_from,
:warehouse_id,
:return_to,
:confirmation,
:customs,
:advanced_options,
:origin_type,
:insurance_provider,
:tags,
:order_source_code,
:packages,
:total_weight,
:rate_response
# rubocop:todo Metrics/ParameterLists
def initialize(shipment_id:, carrier_id:, service_code:, external_order_id:, items:, tax_identifiers:, external_shipment_id:, ship_date:, created_at:, modified_at:, shipment_status:, ship_to:, ship_from:, warehouse_id:, return_to:, confirmation:, customs:, advanced_options:, origin_type:,
insurance_provider:, tags:, order_source_code:, packages:, total_weight:, rate_response:)
# rubocop:enable Metrics/ParameterLists
@shipment_id = shipment_id
@carrier_id = carrier_id
@service_code = service_code
@external_order_id = external_order_id
@items = items
@tax_identifiers = tax_identifiers
@external_shipment_id = external_shipment_id
@ship_date = ship_date
@created_at = created_at
@modified_at = modified_at
@shipment_status = shipment_status
@ship_to = ship_to
@ship_from = ship_from
@warehouse_id = warehouse_id
@return_to = return_to
@confirmation = confirmation
@customs = customs
@advanced_options = advanced_options
@origin_type = origin_type
@insurance_provider = insurance_provider
@tags = tags
@order_source_code = order_source_code
@packages = packages
@total_weight = total_weight
@rate_response = rate_response
end
class Item
attr_reader :name, :sales_order_id, :sales_order_item_id, :quantity, :sku, :external_order_id, :external_order_item_id, :asin, :order_source_code
def initialize(name:, sales_order_id:, sales_order_item_id:, quantity:, sku:, external_order_id:, external_order_item_id:, asin:, order_source_code:) # rubocop:todo Metrics/ParameterLists
@name = name
@sales_order_id = sales_order_id
@sales_order_item_id = sales_order_item_id
@quantity = quantity
@sku = sku
@external_order_id = external_order_id
@external_order_item_id = external_order_item_id
@asin = asin
@order_source_code = order_source_code
end
end
class TaxIdentifier
attr_reader :taxable_entity_type, :identifier_type, :issuing_authority, :value
def initialize(taxable_entity_type:, identifier_type:, issuing_authority:, value:)
@taxable_entity_type = taxable_entity_type
@identifier_type = identifier_type
@issuing_authority = issuing_authority
@value = value
end
end
class Address
attr_reader :name, :phone, :company_name, :address_line1, :address_line2, :address_line3, :city_locality, :state_province, :postal_code, :country_code, :address_residential_indicator
def initialize(name:, phone:, company_name:, address_line1:, address_line2:, address_line3:, city_locality:, state_province:, postal_code:, country_code:, address_residential_indicator:) # rubocop:todo Metrics/ParameterLists
@name = name
@phone = phone
@company_name = company_name
@address_line1 = address_line1
@address_line2 = address_line2
@address_line3 = address_line3
@city_locality = city_locality
@state_province = state_province
@postal_code = postal_code
@country_code = country_code
@address_residential_indicator = address_residential_indicator
end
end
class Customs
attr_reader :contents, :non_delivery, :customs_items
def initialize(contents:, non_delivery:, customs_items:)
@contents = contents
@non_delivery = non_delivery
@customs_items = customs_items
end
class CustomsItem
attr_reader :customs_item_id, :description, :quantity, :value, :harmonized_tariff_code, :country_of_origin, :unit_of_measure, :sku, :sku_description
def initialize(customs_item_id:, description:, quantity:, value:, harmonized_tariff_code:, country_of_origin:, unit_of_measure:, sku:, sku_description:) # rubocop:todo Metrics/ParameterLists
@customs_item_id = customs_item_id
@description = description
@quantity = quantity
@value = value
@harmonized_tariff_code = harmonized_tariff_code
@country_of_origin = country_of_origin
@unit_of_measure = unit_of_measure
@sku = sku
@sku_description = sku_description
end
end
end
class MonetaryValue
attr_reader :currency, :amount
def initialize(currency:, amount:)
@currency = currency
@amount = amount
end
end
class Weight
attr_reader :value, :unit
def initialize(value:, unit:)
@value = value
@unit = unit
end
end
class Dimensions
attr_reader :unit, :length, :width, :height
# type ["inch" | "centimeter"] unit
# @param [Double] length - e.g. 1.0
# @param [Double] width - e.g. 1.0
# @param [Double] height - e.g. 1.0
def initialize(unit:, length:, width:, height:)
@unit = unit
@length = length
@width = width
@height = height
end
end
class AdvancedOptions
attr_reader :bill_to_account,
:bill_to_country_code,
:bill_to_party,
:bill_to_postal_code,
:contains_alcohol,
:delivered_duty_paid,
:dry_ice,
:dry_ice_weight,
:non_machinable,
:saturday_delivery,
:use_ups_ground_freight_pricing,
:freight_class,
:custom_field1,
:custom_field2,
:custom_field3,
:origin_type,
:shipper_release,
:collect_on_delivery,
:license_number,
:invoice_number,
:certificate_number
# rubocop:todo Metrics/ParameterLists
def initialize(bill_to_account:, bill_to_country_code:, bill_to_party:, bill_to_postal_code:, contains_alcohol:, delivered_duty_paid:, dry_ice:, dry_ice_weight:, non_machinable:, saturday_delivery:, use_ups_ground_freight_pricing:, freight_class:, custom_field1:, custom_field2:,
custom_field3:, origin_type:, shipper_release:, collect_on_delivery:, license_number:, invoice_number:, certificate_number:)
# rubocop:enable Metrics/ParameterLists
@bill_to_account = bill_to_account
@bill_to_country_code = bill_to_country_code
@bill_to_party = bill_to_party
@bill_to_postal_code = bill_to_postal_code
@contains_alcohol = contains_alcohol
@delivered_duty_paid = delivered_duty_paid
@dry_ice = dry_ice
@dry_ice_weight = dry_ice_weight
@non_machinable = non_machinable
@saturday_delivery = saturday_delivery
@use_ups_ground_freight_pricing = use_ups_ground_freight_pricing
@freight_class = freight_class
@custom_field1 = custom_field1
@custom_field2 = custom_field2
@custom_field3 = custom_field3
@origin_type = origin_type
@shipper_release = shipper_release
@collect_on_delivery = collect_on_delivery
@license_number = license_number
@invoice_number = invoice_number
@certificate_number = certificate_number
end
class CollectOnDelivery
attr_reader :payment_type, :payment_amount
def initialize(payment_type:, payment_amount:)
@payment_type = payment_type
@payment_amount = payment_amount
end
end
end
class Tag
attr_reader :name
def initialize(name:)
@name = name
end
end
class Package
attr_reader :package_code, :weight, :dimensions, :insured_value, :tracking_number, :label_messages, :external_package_id
def initialize(package_code:, weight:, dimensions:, insured_value:, tracking_number:, label_messages:, external_package_id:) # rubocop:todo Metrics/ParameterLists
@package_code = package_code
@weight = weight
@dimensions = dimensions
@insured_value = insured_value
@tracking_number = tracking_number
@label_messages = label_messages
@external_package_id = external_package_id
end
class LabelMessages
attr_reader :reference1, :reference2, :reference3
def initialize(reference1:, reference2:, reference3:)
@reference1 = reference1
@reference2 = reference2
@reference3 = reference3
end
end
end
class RateResponse
attr_reader :rates, :invalid_rates, :rate_request_id, :shipment_id, :created_at, :status, :errors
def initialize(rates:, invalid_rates:, rate_request_id:, shipment_id:, created_at:, status:, errors:) # rubocop:todo Metrics/ParameterLists
@rates = rates
@invalid_rates = invalid_rates
@rate_request_id = rate_request_id
@shipment_id = shipment_id
@created_at = created_at
@status = status
@errors = errors
end
class Rate
attr_reader :rate_id,
:rate_type,
:carrier_id,
:shipping_amount,
:insurance_amount,
:confirmation_amount,
:other_amount,
:tax_amount,
:zone,
:package_type,
:delivery_days,
:guaranteed_service,
:estimated_delivery_date,
:carrier_delivery_days,
:ship_date,
:negotiated_rate,
:service_type,
:service_code,
:trackable,
:carrier_code,
:carrier_nickname,
:carrier_friendly_name,
:validation_status,
:warning_messages,
:error_messages
# rubocop:todo Metrics/ParameterLists
def initialize(rate_id:, rate_type:, carrier_id:, shipping_amount:, insurance_amount:, confirmation_amount:, other_amount:, tax_amount:, zone:, package_type:, delivery_days:, guaranteed_service:, estimated_delivery_date:, carrier_delivery_days:, ship_date:, negotiated_rate:,
service_type:, service_code:, trackable:, carrier_code:, carrier_nickname:, carrier_friendly_name:, validation_status:, warning_messages:, error_messages:)
# rubocop:enable Metrics/ParameterLists
@rate_id = rate_id
@rate_type = rate_type
@carrier_id = carrier_id
@shipping_amount = shipping_amount
@insurance_amount = insurance_amount
@confirmation_amount = confirmation_amount
@other_amount = other_amount
@tax_amount = tax_amount
@zone = zone
@package_type = package_type
@delivery_days = delivery_days
@guaranteed_service = guaranteed_service
@estimated_delivery_date = estimated_delivery_date
@carrier_delivery_days = carrier_delivery_days
@ship_date = ship_date
@negotiated_rate = negotiated_rate
@service_type = service_type
@service_code = service_code
@trackable = trackable
@carrier_code = carrier_code
@carrier_nickname = carrier_nickname
@carrier_friendly_name = carrier_friendly_name
@validation_status = validation_status
@warning_messages = warning_messages
@error_messages = error_messages
end
end
class Error
attr_reader :error_source, :error_type, :error_code, :message
# type ["carrier" | "order_source" | "shipengine"] error_source
# type ["account_status" | "business_rules" | "validation" | "security" | "system" | "integrations"] error_type
# @param [String] error_code
# @param [String] message
def initialize(error_source:, error_type:, error_code:, message:)
@error_source = error_source
@error_type = error_type
@error_code = error_code
@message = message
end
end
end
end
end
end
end
end