shipengine_sdk 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/README.md +96 -0
- data/lib/faraday/raise_http_exception.rb +77 -0
- data/lib/shipengine/configuration.rb +43 -0
- data/lib/shipengine/constants/base.rb +22 -0
- data/lib/shipengine/constants/countries.rb +16 -0
- data/lib/shipengine/constants.rb +4 -0
- data/lib/shipengine/domain/addresses/address_validation.rb +118 -0
- data/lib/shipengine/domain/addresses.rb +76 -0
- data/lib/shipengine/domain/carriers/list_carriers.rb +140 -0
- data/lib/shipengine/domain/carriers.rb +93 -0
- data/lib/shipengine/domain/labels/create_from_rate.rb +163 -0
- data/lib/shipengine/domain/labels/create_from_shipment_details.rb +163 -0
- data/lib/shipengine/domain/labels/void_label.rb +18 -0
- data/lib/shipengine/domain/labels.rb +297 -0
- data/lib/shipengine/domain/rates/get_with_shipment_details.rb +347 -0
- data/lib/shipengine/domain/rates.rb +379 -0
- data/lib/shipengine/domain/tracking/track_using_carrier_code_and_tracking_number.rb +45 -0
- data/lib/shipengine/domain/tracking/track_using_label_id.rb +45 -0
- data/lib/shipengine/domain/tracking.rb +103 -0
- data/lib/shipengine/domain.rb +7 -0
- data/lib/shipengine/exceptions/error_code.rb +254 -0
- data/lib/shipengine/exceptions/error_type.rb +49 -0
- data/lib/shipengine/exceptions.rb +132 -0
- data/lib/shipengine/internal_client.rb +91 -0
- data/lib/shipengine/utils/base58.rb +109 -0
- data/lib/shipengine/utils/pretty_print.rb +29 -0
- data/lib/shipengine/utils/request_id.rb +16 -0
- data/lib/shipengine/utils/user_agent.rb +24 -0
- data/lib/shipengine/utils/validate.rb +106 -0
- data/lib/shipengine/version.rb +5 -0
- data/lib/shipengine.rb +164 -0
- metadata +117 -0
@@ -0,0 +1,297 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'hashie'
|
4
|
+
require_relative 'labels/create_from_rate'
|
5
|
+
require_relative 'labels/create_from_shipment_details'
|
6
|
+
require_relative 'labels/void_label'
|
7
|
+
|
8
|
+
module ShipEngine
|
9
|
+
module Domain
|
10
|
+
class Labels # rubocop:todo Metrics/ClassLength
|
11
|
+
require 'shipengine/constants'
|
12
|
+
|
13
|
+
# @param [ShipEngine::InternalClient] internal_client
|
14
|
+
def initialize(internal_client)
|
15
|
+
@internal_client = internal_client
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param label_id [String]
|
19
|
+
# @param params [Hash]
|
20
|
+
# @param config [Hash?]
|
21
|
+
#
|
22
|
+
# @return [ShipEngine::Domain::Labels::CreateFromRate::Response]
|
23
|
+
#
|
24
|
+
# @see https://shipengine.github.io/shipengine-openapi/#operation/create_label_from_rate
|
25
|
+
def create_from_rate(rate_id, params, config)
|
26
|
+
response = @internal_client.post("/v1/labels/rates/#{rate_id}", params, config)
|
27
|
+
label_api_result = response.body
|
28
|
+
mash_result = Hashie::Mash.new(label_api_result)
|
29
|
+
|
30
|
+
shipment_cost = nil
|
31
|
+
if mash_result.shipment_cost
|
32
|
+
shipment_cost = CreateFromRate::Response::MonetaryValue.new(
|
33
|
+
currency: mash_result.shipment_cost.currency,
|
34
|
+
amount: mash_result.shipment_cost.amount
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
insurance_cost = nil
|
39
|
+
if mash_result.insurance_cost
|
40
|
+
insurance_cost = CreateFromRate::Response::MonetaryValue.new(
|
41
|
+
currency: mash_result.insurance_cost.currency,
|
42
|
+
amount: mash_result.insurance_cost.amount
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
label_download = nil
|
47
|
+
if mash_result.label_download
|
48
|
+
label_download = CreateFromRate::Response::LabelDownload.new(
|
49
|
+
href: mash_result.label_download.href,
|
50
|
+
pdf: mash_result.label_download.pdf,
|
51
|
+
png: mash_result.label_download.png,
|
52
|
+
zpl: mash_result.label_download.zpl
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
form_download = nil
|
57
|
+
if mash_result.form_download
|
58
|
+
form_download = CreateFromRate::Response::FormDownload.new(
|
59
|
+
href: mash_result.form_download.href,
|
60
|
+
type: mash_result.form_download.type
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
insurance_claim = nil
|
65
|
+
if mash_result.insurance_claim
|
66
|
+
insurance_claim = CreateFromRate::Response::InsuranceClaim.new(
|
67
|
+
href: mash_result.insurance_claim.href,
|
68
|
+
type: mash_result.insurance_claim.type
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
packages = mash_result.packages.map do |package|
|
73
|
+
weight = CreateFromRate::Response::Weight.new(
|
74
|
+
value: package.weight.value,
|
75
|
+
unit: package.weight.unit
|
76
|
+
)
|
77
|
+
|
78
|
+
dimensions = nil
|
79
|
+
if package.dimensions
|
80
|
+
dimensions = CreateFromRate::Response::Dimensions.new(
|
81
|
+
unit: package.dimensions.unit,
|
82
|
+
length: package.dimensions['length'],
|
83
|
+
width: package.dimensions.width,
|
84
|
+
height: package.dimensions.height
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
insured_value = nil
|
89
|
+
if package.insured_value
|
90
|
+
insured_value = CreateFromRate::Response::MonetaryValue.new(
|
91
|
+
currency: package.insured_value.currency,
|
92
|
+
amount: package.insured_value.amount
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
label_messages = nil
|
97
|
+
if package.label_messages
|
98
|
+
label_messages = CreateFromRate::Response::Package::LabelMessages.new(
|
99
|
+
reference1: package.label_messages.reference1,
|
100
|
+
reference2: package.label_messages.reference2,
|
101
|
+
reference3: package.label_messages.reference3
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
CreateFromRate::Response::Package.new(
|
106
|
+
package_code: package.package_code,
|
107
|
+
weight:,
|
108
|
+
dimensions:,
|
109
|
+
insured_value:,
|
110
|
+
tracking_number: package.tracking_number,
|
111
|
+
label_messages:,
|
112
|
+
external_package_id: package.external_package_id
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
CreateFromRate::Response.new(
|
117
|
+
label_id: mash_result.label_id,
|
118
|
+
status: mash_result.status,
|
119
|
+
shipment_id: mash_result.shipment_id,
|
120
|
+
ship_date: mash_result.ship_date,
|
121
|
+
created_at: mash_result.created_at,
|
122
|
+
shipment_cost:,
|
123
|
+
insurance_cost:,
|
124
|
+
tracking_number: mash_result.tracking_number,
|
125
|
+
is_return_label: mash_result.is_return_label,
|
126
|
+
rma_number: mash_result.rma_number,
|
127
|
+
is_international: mash_result.is_international,
|
128
|
+
batch_id: mash_result.batch_id,
|
129
|
+
carrier_id: mash_result.carrier_id,
|
130
|
+
charge_event: mash_result.charge_event,
|
131
|
+
service_code: mash_result.service_code,
|
132
|
+
package_code: mash_result.package_code,
|
133
|
+
voided: mash_result.voided,
|
134
|
+
voided_at: mash_result.voided_at,
|
135
|
+
label_format: mash_result.label_format,
|
136
|
+
display_scheme: mash_result.display_scheme,
|
137
|
+
label_layout: mash_result.label_layout,
|
138
|
+
trackable: mash_result.trackable,
|
139
|
+
label_image_id: mash_result.label_image_id,
|
140
|
+
carrier_code: mash_result.carrier_code,
|
141
|
+
tracking_status: mash_result.tracking_status,
|
142
|
+
label_download:,
|
143
|
+
form_download:,
|
144
|
+
insurance_claim:,
|
145
|
+
packages:
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
# @param params [Hash]
|
150
|
+
# @param config [Hash?]
|
151
|
+
#
|
152
|
+
# @return [ShipEngine::Domain::Labels::CreateFromShipmentDetails::Response]
|
153
|
+
#
|
154
|
+
# @see https://shipengine.github.io/shipengine-openapi/#operation/create_label
|
155
|
+
def create_from_shipment_details(params, config)
|
156
|
+
response = @internal_client.post('/v1/labels', params, config)
|
157
|
+
label_api_result = response.body
|
158
|
+
mash_result = Hashie::Mash.new(label_api_result)
|
159
|
+
|
160
|
+
shipment_cost = nil
|
161
|
+
if mash_result.shipment_cost
|
162
|
+
shipment_cost = CreateFromShipmentDetails::Response::MonetaryValue.new(
|
163
|
+
currency: mash_result.shipment_cost.currency,
|
164
|
+
amount: mash_result.shipment_cost.amount
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
insurance_cost = nil
|
169
|
+
if mash_result.insurance_cost
|
170
|
+
insurance_cost = CreateFromShipmentDetails::Response::MonetaryValue.new(
|
171
|
+
currency: mash_result.insurance_cost.currency,
|
172
|
+
amount: mash_result.insurance_cost.amount
|
173
|
+
)
|
174
|
+
end
|
175
|
+
|
176
|
+
label_download = nil
|
177
|
+
if mash_result.label_download
|
178
|
+
label_download = CreateFromShipmentDetails::Response::LabelDownload.new(
|
179
|
+
href: mash_result.label_download.href,
|
180
|
+
pdf: mash_result.label_download.pdf,
|
181
|
+
png: mash_result.label_download.png,
|
182
|
+
zpl: mash_result.label_download.zpl
|
183
|
+
)
|
184
|
+
end
|
185
|
+
|
186
|
+
form_download = nil
|
187
|
+
if mash_result.form_download
|
188
|
+
form_download = CreateFromShipmentDetails::Response::FormDownload.new(
|
189
|
+
href: mash_result.form_download.href,
|
190
|
+
type: mash_result.form_download.type
|
191
|
+
)
|
192
|
+
end
|
193
|
+
|
194
|
+
insurance_claim = nil
|
195
|
+
if mash_result.insurance_claim
|
196
|
+
insurance_claim = CreateFromShipmentDetails::Response::InsuranceClaim.new(
|
197
|
+
href: mash_result.insurance_claim.href,
|
198
|
+
type: mash_result.insurance_claim.type
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
packages = mash_result.packages.map do |package|
|
203
|
+
weight = CreateFromShipmentDetails::Response::Weight.new(
|
204
|
+
value: package.weight.value,
|
205
|
+
unit: package.weight.unit
|
206
|
+
)
|
207
|
+
|
208
|
+
dimensions = nil
|
209
|
+
if package.dimensions
|
210
|
+
dimensions = CreateFromShipmentDetails::Response::Dimensions.new(
|
211
|
+
unit: package.dimensions.unit,
|
212
|
+
length: package.dimensions['length'],
|
213
|
+
width: package.dimensions.width,
|
214
|
+
height: package.dimensions.height
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
insured_value = nil
|
219
|
+
if package.insured_value
|
220
|
+
insured_value = CreateFromShipmentDetails::Response::MonetaryValue.new(
|
221
|
+
currency: package.insured_value.currency,
|
222
|
+
amount: package.insured_value.amount
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
label_messages = nil
|
227
|
+
if package.label_messages
|
228
|
+
label_messages = CreateFromShipmentDetails::Response::Package::LabelMessages.new(
|
229
|
+
reference1: package.label_messages.reference1,
|
230
|
+
reference2: package.label_messages.reference2,
|
231
|
+
reference3: package.label_messages.reference3
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
CreateFromShipmentDetails::Response::Package.new(
|
236
|
+
package_code: package.package_code,
|
237
|
+
weight:,
|
238
|
+
dimensions:,
|
239
|
+
insured_value:,
|
240
|
+
tracking_number: package.tracking_number,
|
241
|
+
label_messages:,
|
242
|
+
external_package_id: package.external_package_id
|
243
|
+
)
|
244
|
+
end
|
245
|
+
|
246
|
+
CreateFromShipmentDetails::Response.new(
|
247
|
+
label_id: mash_result.label_id,
|
248
|
+
status: mash_result.status,
|
249
|
+
shipment_id: mash_result.shipment_id,
|
250
|
+
ship_date: mash_result.ship_date,
|
251
|
+
created_at: mash_result.created_at,
|
252
|
+
shipment_cost:,
|
253
|
+
insurance_cost:,
|
254
|
+
tracking_number: mash_result.tracking_number,
|
255
|
+
is_return_label: mash_result.is_return_label,
|
256
|
+
rma_number: mash_result.rma_number,
|
257
|
+
is_international: mash_result.is_international,
|
258
|
+
batch_id: mash_result.batch_id,
|
259
|
+
carrier_id: mash_result.carrier_id,
|
260
|
+
charge_event: mash_result.charge_event,
|
261
|
+
service_code: mash_result.service_code,
|
262
|
+
package_code: mash_result.package_code,
|
263
|
+
voided: mash_result.voided,
|
264
|
+
voided_at: mash_result.voided_at,
|
265
|
+
label_format: mash_result.label_format,
|
266
|
+
display_scheme: mash_result.display_scheme,
|
267
|
+
label_layout: mash_result.label_layout,
|
268
|
+
trackable: mash_result.trackable,
|
269
|
+
label_image_id: mash_result.label_image_id,
|
270
|
+
carrier_code: mash_result.carrier_code,
|
271
|
+
tracking_status: mash_result.tracking_status,
|
272
|
+
label_download:,
|
273
|
+
form_download:,
|
274
|
+
insurance_claim:,
|
275
|
+
packages:
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
279
|
+
# @param label_id [String]
|
280
|
+
# @param config [Hash?]
|
281
|
+
#
|
282
|
+
# @return [ShipEngine::Domain::Labels::CreateFromShipmentDetails::Response]
|
283
|
+
#
|
284
|
+
# @see https://shipengine.github.io/shipengine-openapi/#operation/create_label
|
285
|
+
def void(label_id, config)
|
286
|
+
response = @internal_client.put("/v1/labels/#{label_id}/void", {}, config)
|
287
|
+
label_api_result = response.body
|
288
|
+
mash_result = Hashie::Mash.new(label_api_result)
|
289
|
+
|
290
|
+
VoidLabel::Response.new(
|
291
|
+
approved: mash_result.approved,
|
292
|
+
message: mash_result['message']
|
293
|
+
)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,347 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShipEngine
|
4
|
+
module Domain
|
5
|
+
class Rates
|
6
|
+
module GetWithShipmentDetails
|
7
|
+
class Response
|
8
|
+
attr_reader :shipment_id,
|
9
|
+
:carrier_id,
|
10
|
+
:service_code,
|
11
|
+
:external_order_id,
|
12
|
+
:items,
|
13
|
+
:tax_identifiers,
|
14
|
+
:external_shipment_id,
|
15
|
+
:ship_date,
|
16
|
+
:created_at,
|
17
|
+
:modified_at,
|
18
|
+
:shipment_status,
|
19
|
+
:ship_to,
|
20
|
+
:ship_from,
|
21
|
+
:warehouse_id,
|
22
|
+
:return_to,
|
23
|
+
:confirmation,
|
24
|
+
:customs,
|
25
|
+
:advanced_options,
|
26
|
+
:origin_type,
|
27
|
+
:insurance_provider,
|
28
|
+
:tags,
|
29
|
+
:order_source_code,
|
30
|
+
:packages,
|
31
|
+
:total_weight,
|
32
|
+
:rate_response
|
33
|
+
|
34
|
+
# rubocop:todo Metrics/ParameterLists
|
35
|
+
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:,
|
36
|
+
insurance_provider:, tags:, order_source_code:, packages:, total_weight:, rate_response:)
|
37
|
+
# rubocop:enable Metrics/ParameterLists
|
38
|
+
@shipment_id = shipment_id
|
39
|
+
@carrier_id = carrier_id
|
40
|
+
@service_code = service_code
|
41
|
+
@external_order_id = external_order_id
|
42
|
+
@items = items
|
43
|
+
@tax_identifiers = tax_identifiers
|
44
|
+
@external_shipment_id = external_shipment_id
|
45
|
+
@ship_date = ship_date
|
46
|
+
@created_at = created_at
|
47
|
+
@modified_at = modified_at
|
48
|
+
@shipment_status = shipment_status
|
49
|
+
@ship_to = ship_to
|
50
|
+
@ship_from = ship_from
|
51
|
+
@warehouse_id = warehouse_id
|
52
|
+
@return_to = return_to
|
53
|
+
@confirmation = confirmation
|
54
|
+
@customs = customs
|
55
|
+
@advanced_options = advanced_options
|
56
|
+
@origin_type = origin_type
|
57
|
+
@insurance_provider = insurance_provider
|
58
|
+
@tags = tags
|
59
|
+
@order_source_code = order_source_code
|
60
|
+
@packages = packages
|
61
|
+
@total_weight = total_weight
|
62
|
+
@rate_response = rate_response
|
63
|
+
end
|
64
|
+
|
65
|
+
class Item
|
66
|
+
attr_reader :name, :sales_order_id, :sales_order_item_id, :quantity, :sku, :external_order_id, :external_order_item_id, :asin, :order_source_code
|
67
|
+
|
68
|
+
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
|
69
|
+
@name = name
|
70
|
+
@sales_order_id = sales_order_id
|
71
|
+
@sales_order_item_id = sales_order_item_id
|
72
|
+
@quantity = quantity
|
73
|
+
@sku = sku
|
74
|
+
@external_order_id = external_order_id
|
75
|
+
@external_order_item_id = external_order_item_id
|
76
|
+
@asin = asin
|
77
|
+
@order_source_code = order_source_code
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class TaxIdentifier
|
82
|
+
attr_reader :taxable_entity_type, :identifier_type, :issuing_authority, :value
|
83
|
+
|
84
|
+
def initialize(taxable_entity_type:, identifier_type:, issuing_authority:, value:)
|
85
|
+
@taxable_entity_type = taxable_entity_type
|
86
|
+
@identifier_type = identifier_type
|
87
|
+
@issuing_authority = issuing_authority
|
88
|
+
@value = value
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Address
|
93
|
+
attr_reader :name, :phone, :company_name, :address_line1, :address_line2, :address_line3, :city_locality, :state_province, :postal_code, :country_code, :address_residential_indicator
|
94
|
+
|
95
|
+
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
|
96
|
+
@name = name
|
97
|
+
@phone = phone
|
98
|
+
@company_name = company_name
|
99
|
+
@address_line1 = address_line1
|
100
|
+
@address_line2 = address_line2
|
101
|
+
@address_line3 = address_line3
|
102
|
+
@city_locality = city_locality
|
103
|
+
@state_province = state_province
|
104
|
+
@postal_code = postal_code
|
105
|
+
@country_code = country_code
|
106
|
+
@address_residential_indicator = address_residential_indicator
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class Customs
|
111
|
+
attr_reader :contents, :non_delivery, :customs_items
|
112
|
+
|
113
|
+
def initialize(contents:, non_delivery:, customs_items:)
|
114
|
+
@contents = contents
|
115
|
+
@non_delivery = non_delivery
|
116
|
+
@customs_items = customs_items
|
117
|
+
end
|
118
|
+
|
119
|
+
class CustomsItem
|
120
|
+
attr_reader :customs_item_id, :description, :quantity, :value, :harmonized_tariff_code, :country_of_origin, :unit_of_measure, :sku, :sku_description
|
121
|
+
|
122
|
+
def initialize(customs_item_id:, description:, quantity:, value:, harmonized_tariff_code:, country_of_origin:, unit_of_measure:, sku:, sku_description:) # rubocop:todo Metrics/ParameterLists
|
123
|
+
@customs_item_id = customs_item_id
|
124
|
+
@description = description
|
125
|
+
@quantity = quantity
|
126
|
+
@value = value
|
127
|
+
@harmonized_tariff_code = harmonized_tariff_code
|
128
|
+
@country_of_origin = country_of_origin
|
129
|
+
@unit_of_measure = unit_of_measure
|
130
|
+
@sku = sku
|
131
|
+
@sku_description = sku_description
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class MonetaryValue
|
137
|
+
attr_reader :currency, :amount
|
138
|
+
|
139
|
+
def initialize(currency:, amount:)
|
140
|
+
@currency = currency
|
141
|
+
@amount = amount
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class Weight
|
146
|
+
attr_reader :value, :unit
|
147
|
+
|
148
|
+
def initialize(value:, unit:)
|
149
|
+
@value = value
|
150
|
+
@unit = unit
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
class Dimensions
|
155
|
+
attr_reader :unit, :length, :width, :height
|
156
|
+
|
157
|
+
# type ["inch" | "centimeter"] unit
|
158
|
+
# @param [Double] length - e.g. 1.0
|
159
|
+
# @param [Double] width - e.g. 1.0
|
160
|
+
# @param [Double] height - e.g. 1.0
|
161
|
+
|
162
|
+
def initialize(unit:, length:, width:, height:)
|
163
|
+
@unit = unit
|
164
|
+
@length = length
|
165
|
+
@width = width
|
166
|
+
@height = height
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class AdvancedOptions
|
171
|
+
attr_reader :bill_to_account,
|
172
|
+
:bill_to_country_code,
|
173
|
+
:bill_to_party,
|
174
|
+
:bill_to_postal_code,
|
175
|
+
:contains_alcohol,
|
176
|
+
:delivered_duty_paid,
|
177
|
+
:dry_ice,
|
178
|
+
:dry_ice_weight,
|
179
|
+
:non_machinable,
|
180
|
+
:saturday_delivery,
|
181
|
+
:use_ups_ground_freight_pricing,
|
182
|
+
:freight_class,
|
183
|
+
:custom_field1,
|
184
|
+
:custom_field2,
|
185
|
+
:custom_field3,
|
186
|
+
:origin_type,
|
187
|
+
:shipper_release,
|
188
|
+
:collect_on_delivery
|
189
|
+
|
190
|
+
# rubocop:todo Metrics/ParameterLists
|
191
|
+
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:,
|
192
|
+
custom_field3:, origin_type:, shipper_release:, collect_on_delivery:)
|
193
|
+
# rubocop:enable Metrics/ParameterLists
|
194
|
+
@bill_to_account = bill_to_account
|
195
|
+
@bill_to_country_code = bill_to_country_code
|
196
|
+
@bill_to_party = bill_to_party
|
197
|
+
@bill_to_postal_code = bill_to_postal_code
|
198
|
+
@contains_alcohol = contains_alcohol
|
199
|
+
@delivered_duty_paid = delivered_duty_paid
|
200
|
+
@dry_ice = dry_ice
|
201
|
+
@dry_ice_weight = dry_ice_weight
|
202
|
+
@non_machinable = non_machinable
|
203
|
+
@saturday_delivery = saturday_delivery
|
204
|
+
@use_ups_ground_freight_pricing = use_ups_ground_freight_pricing
|
205
|
+
@freight_class = freight_class
|
206
|
+
@custom_field1 = custom_field1
|
207
|
+
@custom_field2 = custom_field2
|
208
|
+
@custom_field3 = custom_field3
|
209
|
+
@origin_type = origin_type
|
210
|
+
@shipper_release = shipper_release
|
211
|
+
@collect_on_delivery = collect_on_delivery
|
212
|
+
end
|
213
|
+
|
214
|
+
class CollectOnDelivery
|
215
|
+
attr_reader :payment_type, :payment_amount
|
216
|
+
|
217
|
+
def initialize(payment_type:, payment_amount:)
|
218
|
+
@payment_type = payment_type
|
219
|
+
@payment_amount = payment_amount
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class Tag
|
225
|
+
attr_reader :name
|
226
|
+
|
227
|
+
def initialize(name:)
|
228
|
+
@name = name
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
class Package
|
233
|
+
attr_reader :package_code, :weight, :dimensions, :insured_value, :tracking_number, :label_messages, :external_package_id
|
234
|
+
|
235
|
+
def initialize(package_code:, weight:, dimensions:, insured_value:, tracking_number:, label_messages:, external_package_id:) # rubocop:todo Metrics/ParameterLists
|
236
|
+
@package_code = package_code
|
237
|
+
@weight = weight
|
238
|
+
@dimensions = dimensions
|
239
|
+
@insured_value = insured_value
|
240
|
+
@tracking_number = tracking_number
|
241
|
+
@label_messages = label_messages
|
242
|
+
@external_package_id = external_package_id
|
243
|
+
end
|
244
|
+
|
245
|
+
class LabelMessages
|
246
|
+
attr_reader :reference1, :reference2, :reference3
|
247
|
+
|
248
|
+
def initialize(reference1:, reference2:, reference3:)
|
249
|
+
@reference1 = reference1
|
250
|
+
@reference2 = reference2
|
251
|
+
@reference3 = reference3
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
class RateResponse
|
257
|
+
attr_reader :rates, :invalid_rates, :rate_request_id, :shipment_id, :created_at, :status, :errors
|
258
|
+
|
259
|
+
def initialize(rates:, invalid_rates:, rate_request_id:, shipment_id:, created_at:, status:, errors:) # rubocop:todo Metrics/ParameterLists
|
260
|
+
@rates = rates
|
261
|
+
@invalid_rates = invalid_rates
|
262
|
+
@rate_request_id = rate_request_id
|
263
|
+
@shipment_id = shipment_id
|
264
|
+
@created_at = created_at
|
265
|
+
@status = status
|
266
|
+
@errors = errors
|
267
|
+
end
|
268
|
+
|
269
|
+
class Rate
|
270
|
+
attr_reader :rate_id,
|
271
|
+
:rate_type,
|
272
|
+
:carrier_id,
|
273
|
+
:shipping_amount,
|
274
|
+
:insurance_amount,
|
275
|
+
:confirmation_amount,
|
276
|
+
:other_amount,
|
277
|
+
:tax_amount,
|
278
|
+
:zone,
|
279
|
+
:package_type,
|
280
|
+
:delivery_days,
|
281
|
+
:guaranteed_service,
|
282
|
+
:estimated_delivery_date,
|
283
|
+
:carrier_delivery_days,
|
284
|
+
:ship_date,
|
285
|
+
:negotiated_rate,
|
286
|
+
:service_type,
|
287
|
+
:service_code,
|
288
|
+
:trackable,
|
289
|
+
:carrier_code,
|
290
|
+
:carrier_nickname,
|
291
|
+
:carrier_friendly_name,
|
292
|
+
:validation_status,
|
293
|
+
:warning_messages,
|
294
|
+
:error_messages
|
295
|
+
|
296
|
+
# rubocop:todo Metrics/ParameterLists
|
297
|
+
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:,
|
298
|
+
service_type:, service_code:, trackable:, carrier_code:, carrier_nickname:, carrier_friendly_name:, validation_status:, warning_messages:, error_messages:)
|
299
|
+
# rubocop:enable Metrics/ParameterLists
|
300
|
+
@rate_id = rate_id
|
301
|
+
@rate_type = rate_type
|
302
|
+
@carrier_id = carrier_id
|
303
|
+
@shipping_amount = shipping_amount
|
304
|
+
@insurance_amount = insurance_amount
|
305
|
+
@confirmation_amount = confirmation_amount
|
306
|
+
@other_amount = other_amount
|
307
|
+
@tax_amount = tax_amount
|
308
|
+
@zone = zone
|
309
|
+
@package_type = package_type
|
310
|
+
@delivery_days = delivery_days
|
311
|
+
@guaranteed_service = guaranteed_service
|
312
|
+
@estimated_delivery_date = estimated_delivery_date
|
313
|
+
@carrier_delivery_days = carrier_delivery_days
|
314
|
+
@ship_date = ship_date
|
315
|
+
@negotiated_rate = negotiated_rate
|
316
|
+
@service_type = service_type
|
317
|
+
@service_code = service_code
|
318
|
+
@trackable = trackable
|
319
|
+
@carrier_code = carrier_code
|
320
|
+
@carrier_nickname = carrier_nickname
|
321
|
+
@carrier_friendly_name = carrier_friendly_name
|
322
|
+
@validation_status = validation_status
|
323
|
+
@warning_messages = warning_messages
|
324
|
+
@error_messages = error_messages
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
class Error
|
329
|
+
attr_reader :error_source, :error_type, :error_code, :message
|
330
|
+
|
331
|
+
# type ["carrier" | "order_source" | "shipengine"] error_source
|
332
|
+
# type ["account_status" | "business_rules" | "validation" | "security" | "system" | "integrations"] error_type
|
333
|
+
# @param [String] error_code
|
334
|
+
# @param [String] message
|
335
|
+
def initialize(error_source:, error_type:, error_code:, message:)
|
336
|
+
@error_source = error_source
|
337
|
+
@error_type = error_type
|
338
|
+
@error_code = error_code
|
339
|
+
@message = message
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|