friendly_shipping 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +16 -16
- data/lib/friendly_shipping/services/rl/parse_rate_quote_response.rb +3 -3
- data/lib/friendly_shipping/services/ups_json/parse_money_hash.rb +1 -0
- data/lib/friendly_shipping/services/usps_international/parse_rate_response.rb +3 -3
- data/lib/friendly_shipping/services/{usps → usps_international}/parse_xml_response.rb +1 -1
- data/lib/friendly_shipping/services/usps_international/serialize_rate_request.rb +1 -1
- data/lib/friendly_shipping/services/usps_ship/parse_rate_estimates_response.rb +1 -1
- data/lib/friendly_shipping/version.rb +1 -1
- metadata +3 -51
- data/lib/friendly_shipping/services/ups/label.rb +0 -20
- data/lib/friendly_shipping/services/ups/label_billing_options.rb +0 -41
- data/lib/friendly_shipping/services/ups/label_item_options.rb +0 -75
- data/lib/friendly_shipping/services/ups/label_options.rb +0 -174
- data/lib/friendly_shipping/services/ups/label_package_options.rb +0 -49
- data/lib/friendly_shipping/services/ups/parse_address_classification_response.rb +0 -29
- data/lib/friendly_shipping/services/ups/parse_address_validation_response.rb +0 -53
- data/lib/friendly_shipping/services/ups/parse_city_state_lookup_response.rb +0 -33
- data/lib/friendly_shipping/services/ups/parse_modifier_element.rb +0 -29
- data/lib/friendly_shipping/services/ups/parse_money_element.rb +0 -128
- data/lib/friendly_shipping/services/ups/parse_rate_response.rb +0 -101
- data/lib/friendly_shipping/services/ups/parse_shipment_accept_response.rb +0 -77
- data/lib/friendly_shipping/services/ups/parse_shipment_confirm_response.rb +0 -24
- data/lib/friendly_shipping/services/ups/parse_time_in_transit_response.rb +0 -56
- data/lib/friendly_shipping/services/ups/parse_void_shipment_response.rb +0 -24
- data/lib/friendly_shipping/services/ups/parse_xml_response.rb +0 -50
- data/lib/friendly_shipping/services/ups/rate_estimate_options.rb +0 -111
- data/lib/friendly_shipping/services/ups/rate_estimate_package_options.rb +0 -22
- data/lib/friendly_shipping/services/ups/serialize_access_request.rb +0 -20
- data/lib/friendly_shipping/services/ups/serialize_address_snippet.rb +0 -60
- data/lib/friendly_shipping/services/ups/serialize_address_validation_request.rb +0 -40
- data/lib/friendly_shipping/services/ups/serialize_city_state_lookup_request.rb +0 -26
- data/lib/friendly_shipping/services/ups/serialize_package_node.rb +0 -75
- data/lib/friendly_shipping/services/ups/serialize_rating_service_selection_request.rb +0 -98
- data/lib/friendly_shipping/services/ups/serialize_shipment_accept_request.rb +0 -27
- data/lib/friendly_shipping/services/ups/serialize_shipment_address_snippet.rb +0 -21
- data/lib/friendly_shipping/services/ups/serialize_shipment_confirm_request.rb +0 -285
- data/lib/friendly_shipping/services/ups/serialize_time_in_transit_request.rb +0 -56
- data/lib/friendly_shipping/services/ups/serialize_void_shipment_request.rb +0 -21
- data/lib/friendly_shipping/services/ups/shipping_methods.rb +0 -111
- data/lib/friendly_shipping/services/ups/timing_options.rb +0 -33
- data/lib/friendly_shipping/services/ups.rb +0 -218
- data/lib/friendly_shipping/services/usps/choose_package_rate.rb +0 -40
- data/lib/friendly_shipping/services/usps/machinable_package.rb +0 -50
- data/lib/friendly_shipping/services/usps/parse_address_validation_response.rb +0 -43
- data/lib/friendly_shipping/services/usps/parse_city_state_lookup_response.rb +0 -41
- data/lib/friendly_shipping/services/usps/parse_package_rate.rb +0 -159
- data/lib/friendly_shipping/services/usps/parse_rate_response.rb +0 -86
- data/lib/friendly_shipping/services/usps/parse_time_in_transit_response.rb +0 -240
- data/lib/friendly_shipping/services/usps/rate_estimate_options.rb +0 -26
- data/lib/friendly_shipping/services/usps/rate_estimate_package_options.rb +0 -66
- data/lib/friendly_shipping/services/usps/serialize_address_validation_request.rb +0 -25
- data/lib/friendly_shipping/services/usps/serialize_city_state_lookup_request.rb +0 -20
- data/lib/friendly_shipping/services/usps/serialize_rate_request.rb +0 -83
- data/lib/friendly_shipping/services/usps/serialize_time_in_transit_request.rb +0 -22
- data/lib/friendly_shipping/services/usps/shipping_methods.rb +0 -66
- data/lib/friendly_shipping/services/usps/timing_options.rb +0 -19
- data/lib/friendly_shipping/services/usps.rb +0 -115
@@ -1,285 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FriendlyShipping
|
4
|
-
module Services
|
5
|
-
class Ups
|
6
|
-
class SerializeShipmentConfirmRequest
|
7
|
-
class << self
|
8
|
-
# Item options (only necessary for international shipping)
|
9
|
-
# ShipTo CompanyName & AttentionName required for international shipping
|
10
|
-
#
|
11
|
-
# @option description [String] A description of the item for the intl. invoice
|
12
|
-
# @option commodity_code [String] Commodity code for the item. See https://www.tariffnumber.com/
|
13
|
-
# @option value [Money] Price of the item
|
14
|
-
# @option unit_of_item_count [String] What kind of thing is one of this item? Example: Barrel, m3.
|
15
|
-
# See UPS docs for codes.
|
16
|
-
#
|
17
|
-
def call(
|
18
|
-
shipment:,
|
19
|
-
options:
|
20
|
-
)
|
21
|
-
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
22
|
-
xml.ShipmentConfirmRequest do
|
23
|
-
xml.Request do
|
24
|
-
xml.RequestAction('ShipConfirm')
|
25
|
-
# Required element controls level of address validation.
|
26
|
-
xml.RequestOption(options.validate_address ? 'validate' : 'nonvalidate')
|
27
|
-
xml.SubVersion(options.sub_version)
|
28
|
-
# Optional element to identify transactions between client and server.
|
29
|
-
if options.customer_context
|
30
|
-
xml.TransactionReference do
|
31
|
-
xml.CustomerContext(options.customer_context)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
xml.Shipment do
|
37
|
-
xml.Service do
|
38
|
-
xml.Code(options.shipping_method.service_code)
|
39
|
-
end
|
40
|
-
|
41
|
-
xml.ShipTo do
|
42
|
-
SerializeShipmentAddressSnippet.call(xml: xml, location: shipment.destination, international: international?(shipment))
|
43
|
-
end
|
44
|
-
|
45
|
-
# Required element. The company whose account is responsible for the label(s).
|
46
|
-
xml.Shipper do
|
47
|
-
SerializeShipmentAddressSnippet.call(xml: xml, location: options.shipper || shipment.origin)
|
48
|
-
|
49
|
-
xml.ShipperNumber(options.shipper_number)
|
50
|
-
end
|
51
|
-
|
52
|
-
if options.shipper || options.return_service_code
|
53
|
-
origin = options.return_service_code ? shipment.destination : shipment.origin
|
54
|
-
xml.ShipFrom do
|
55
|
-
SerializeShipmentAddressSnippet.call(xml: xml, location: origin)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
if options.negotiated_rates
|
60
|
-
xml.RateInformation do
|
61
|
-
xml.NegotiatedRatesIndicator
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# shipment.options.fetch(:reference_numbers, {}).each do |reference_code, reference_value|
|
66
|
-
# xml.ReferenceNumber do
|
67
|
-
# xml.Code(reference_code)
|
68
|
-
# xml.Value(reference_value)
|
69
|
-
# end
|
70
|
-
# end
|
71
|
-
|
72
|
-
if options.billing_options.prepay
|
73
|
-
xml.PaymentInformation do
|
74
|
-
xml.Prepaid do
|
75
|
-
build_billing_info_node(xml, options)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
else
|
79
|
-
xml.ItemizedPaymentInformation do
|
80
|
-
xml.ShipmentCharge do
|
81
|
-
# Type '01' means 'Transportation'
|
82
|
-
# This node specifies who will be billed for transportation.
|
83
|
-
xml.Type('01')
|
84
|
-
build_billing_info_node(xml, options)
|
85
|
-
end
|
86
|
-
if international?(shipment) && options.terms_of_shipment_code == 'DDP'
|
87
|
-
# The shipper will cover duties and taxes
|
88
|
-
# Otherwise UPS will charge the receiver
|
89
|
-
xml.ShipmentCharge do
|
90
|
-
xml.Type('02') # Type '02' means 'Duties and Taxes'
|
91
|
-
build_billing_info_node(
|
92
|
-
xml,
|
93
|
-
options,
|
94
|
-
bill_to_consignee: true
|
95
|
-
)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
if international?(shipment)
|
102
|
-
unless options.return_service_code
|
103
|
-
xml.SoldTo do
|
104
|
-
sold_to_location = options.sold_to || shipment.destination
|
105
|
-
SerializeShipmentAddressSnippet.call(xml: xml, location: sold_to_location)
|
106
|
-
xml.AccountNumber(options.sold_to.account_number) if options.sold_to.try(:account_number).present?
|
107
|
-
xml.TaxIdentificationNumber(options.sold_to.tax_id_number) if options.sold_to.try(:tax_id_number).present?
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
if shipment.origin.country.code == 'US' && ['CA', 'PR'].include?(shipment.destination.country.code)
|
112
|
-
# Required for shipments from the US to Puerto Rico or Canada
|
113
|
-
# We'll assume USD as the origin country is the United States here.
|
114
|
-
xml.InvoiceLineTotal do
|
115
|
-
total_value = shipment.packages.inject(Money.new(0, 'USD')) do |shipment_sum, package|
|
116
|
-
shipment_sum + package.items.inject(Money.new(0, 'USD')) do |package_sum, item|
|
117
|
-
package_sum + (item.cost || Money.new(0, 'USD'))
|
118
|
-
end
|
119
|
-
end
|
120
|
-
xml.MonetaryValue(total_value.to_f)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
contents_description = shipment.packages.flat_map do |package|
|
125
|
-
package.items.map(&:description)
|
126
|
-
end.compact.uniq.join(', ').slice(0, 50)
|
127
|
-
|
128
|
-
unless contents_description.empty?
|
129
|
-
xml.Description(contents_description)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
if options.return_service_code
|
134
|
-
xml.ReturnService do
|
135
|
-
xml.Code(options.return_service_code)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
xml.ShipmentServiceOptions do
|
140
|
-
xml.SaturdayDelivery if options.saturday_delivery
|
141
|
-
xml.UPScarbonneutralIndicator if options.carbon_neutral
|
142
|
-
if options.delivery_confirmation_code
|
143
|
-
xml.DeliveryConfirmation do
|
144
|
-
xml.DCISType(options.delivery_confirmation_code)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
if international?(shipment)
|
149
|
-
build_international_forms(xml, shipment, options)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
shipment.packages.each do |package|
|
154
|
-
package_options = options.options_for_package(package)
|
155
|
-
reference_numbers = allow_package_level_reference_numbers(shipment) ? package_options.reference_numbers : {}
|
156
|
-
delivery_confirmation_code = package_level_delivery_confirmation?(shipment) ? package_options.delivery_confirmation_code : nil
|
157
|
-
SerializePackageNode.call(
|
158
|
-
xml: xml,
|
159
|
-
package: package,
|
160
|
-
reference_numbers: reference_numbers,
|
161
|
-
delivery_confirmation_code: delivery_confirmation_code,
|
162
|
-
shipper_release: package_options.shipper_release,
|
163
|
-
declared_value: package_options.declared_value
|
164
|
-
)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
xml.LabelSpecification do
|
169
|
-
xml.LabelStockSize do
|
170
|
-
xml.Height(options.label_size[0])
|
171
|
-
xml.Width(options.label_size[1])
|
172
|
-
end
|
173
|
-
|
174
|
-
xml.LabelPrintMethod do
|
175
|
-
xml.Code(options.label_format)
|
176
|
-
end
|
177
|
-
|
178
|
-
# API requires these only if returning a GIF formated label
|
179
|
-
if options.label_format == 'GIF'
|
180
|
-
xml.HTTPUserAgent('Mozilla/4.5')
|
181
|
-
xml.LabelImageFormat(options.label_format) do
|
182
|
-
xml.Code(options.label_format)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
xml_builder.to_xml
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
# if the package is US -> US or PR -> PR the only type of reference numbers that are allowed are package-level
|
194
|
-
# Otherwise the only type of reference numbers that are allowed are shipment-level
|
195
|
-
def allow_package_level_reference_numbers(shipment)
|
196
|
-
origin, destination = shipment.origin.country.code, shipment.destination.country.code
|
197
|
-
[['US', 'US'], ['PR', 'PR']].include?([origin, destination])
|
198
|
-
end
|
199
|
-
|
200
|
-
# For certain origin/destination pairs, UPS allows each package in a shipment to have a specified
|
201
|
-
# delivery_confirmation option
|
202
|
-
# otherwise the delivery_confirmation option must be specified on the entire shipment.
|
203
|
-
# See Appendix P of UPS Shipping Package XML Developers Guide for the rules on which the logic below is based.
|
204
|
-
def package_level_delivery_confirmation?(shipment)
|
205
|
-
origin, destination = shipment.origin.country.code, shipment.destination.country.code
|
206
|
-
origin == destination || [['US', 'PR'], ['PR', 'US']].include?([origin, destination])
|
207
|
-
end
|
208
|
-
|
209
|
-
def build_billing_info_node(xml, options, bill_to_consignee: false)
|
210
|
-
billing_options = options.billing_options
|
211
|
-
if billing_options.bill_third_party || bill_to_consignee
|
212
|
-
xml.BillThirdParty do
|
213
|
-
node_type = bill_to_consignee ? :BillThirdPartyConsignee : :BillThirdPartyShipper
|
214
|
-
xml.public_send(node_type) do
|
215
|
-
xml.AccountNumber(billing_options.billing_account)
|
216
|
-
xml.ThirdParty do
|
217
|
-
xml.Address do
|
218
|
-
xml.PostalCode(billing_options.billing_zip)
|
219
|
-
xml.CountryCode(billing_options.billing_country)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
else
|
225
|
-
xml.BillShipper do
|
226
|
-
xml.AccountNumber(options.shipper_number)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
def build_international_forms(xml, shipment, options)
|
232
|
-
return unless options.paperless_invoice
|
233
|
-
|
234
|
-
reason_for_export = options.return_service_code ? "RETURN" : options.reason_for_export
|
235
|
-
|
236
|
-
invoice_date = options.invoice_date || Date.current
|
237
|
-
xml.InternationalForms do
|
238
|
-
xml.FormType('01') # 01 is "Invoice"
|
239
|
-
xml.InvoiceDate(invoice_date.strftime('%Y%m%d'))
|
240
|
-
xml.ReasonForExport(reason_for_export)
|
241
|
-
xml.CurrencyCode(options.billing_options.currency || 'USD')
|
242
|
-
xml.DeclarationStatement(options.declaration_statement) if options.declaration_statement
|
243
|
-
|
244
|
-
if options.terms_of_shipment_code
|
245
|
-
xml.TermsOfShipment(options.terms_of_shipment_code)
|
246
|
-
end
|
247
|
-
all_items = shipment.packages.map(&:items).map(&:to_a).flatten
|
248
|
-
all_item_options = shipment.packages.flat_map do |package|
|
249
|
-
package_options = options.options_for_package(package)
|
250
|
-
package.items.flat_map do |item|
|
251
|
-
package_options.options_for_item(item)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
all_items.group_by(&:description).each do |description, items|
|
256
|
-
# This is a group of identically described items
|
257
|
-
reference_item = items.first
|
258
|
-
# Get the options for this item
|
259
|
-
item_options = all_item_options.detect { |o| o.item_id == reference_item.id } || LabelItemOptions.new(item_id: nil)
|
260
|
-
|
261
|
-
xml.Product do
|
262
|
-
cost = reference_item.cost || Money.new(0, 'USD')
|
263
|
-
xml.Description(description&.slice(0, 35))
|
264
|
-
xml.CommodityCode(item_options.commodity_code)
|
265
|
-
xml.OriginCountryCode(item_options.country_of_origin || shipment.origin.country.code)
|
266
|
-
xml.Unit do
|
267
|
-
xml.Value(cost)
|
268
|
-
xml.Number(items.length)
|
269
|
-
xml.UnitOfMeasurement do
|
270
|
-
xml.Code(item_options.product_unit_of_measure_code)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
def international?(shipment)
|
279
|
-
shipment.origin.country != shipment.destination.country
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FriendlyShipping
|
4
|
-
module Services
|
5
|
-
class Ups
|
6
|
-
class SerializeTimeInTransitRequest
|
7
|
-
MAX_SHIPMENT_WEIGHT = Measured::Weight.new(150, :pounds)
|
8
|
-
|
9
|
-
def self.call(shipment:, options:)
|
10
|
-
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
11
|
-
xml.TimeInTransitRequest do
|
12
|
-
xml.Request do
|
13
|
-
if options.customer_context
|
14
|
-
xml.TransactionReference do
|
15
|
-
xml.CustomerContext(options.customer_context)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
xml.RequestAction('TimeInTransit')
|
19
|
-
end
|
20
|
-
xml.TransitFrom do
|
21
|
-
xml.AddressArtifactFormat do
|
22
|
-
xml.PoliticalDivision2(shipment.origin.city)
|
23
|
-
xml.PoliticalDivision1(shipment.origin.region.code)
|
24
|
-
xml.CountryCode(shipment.origin.country.code)
|
25
|
-
xml.PostcodePrimaryLow(shipment.origin.zip)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
xml.TransitTo do
|
29
|
-
xml.AddressArtifactFormat do
|
30
|
-
xml.PoliticalDivision2(shipment.destination.city)
|
31
|
-
xml.PoliticalDivision1(shipment.destination.region.code)
|
32
|
-
xml.CountryCode(shipment.destination.country.code)
|
33
|
-
xml.PostcodePrimaryLow(shipment.destination.zip)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
xml.ShipmentWeight do
|
37
|
-
xml.UnitOfMeasurement do
|
38
|
-
xml.Code('LBS')
|
39
|
-
end
|
40
|
-
shipment_weight = shipment.packages.map(&:weight).inject(Measured::Weight(0, :pounds), :+)
|
41
|
-
weight_for_ups = [shipment_weight, MAX_SHIPMENT_WEIGHT].min
|
42
|
-
xml.Weight(weight_for_ups.convert_to(:pounds).value.to_f.round(3))
|
43
|
-
end
|
44
|
-
xml.InvoiceLineTotal do
|
45
|
-
xml.CurrencyCode(options.invoice_total.currency.iso_code)
|
46
|
-
xml.MonetaryValue(options.invoice_total.to_f.round(2))
|
47
|
-
end
|
48
|
-
xml.PickupDate(options.pickup.strftime('%Y%m%d'))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
xml_builder.to_xml
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FriendlyShipping
|
4
|
-
module Services
|
5
|
-
class Ups
|
6
|
-
class SerializeVoidShipmentRequest
|
7
|
-
def self.call(label:)
|
8
|
-
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
9
|
-
xml.VoidShipmentRequest do
|
10
|
-
xml.Request do
|
11
|
-
xml.RequestAction('Void')
|
12
|
-
end
|
13
|
-
xml.ShipmentIdentificationNumber(label.tracking_number)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
xml_builder.to_xml
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FriendlyShipping
|
4
|
-
module Services
|
5
|
-
class Ups
|
6
|
-
EU_COUNTRIES = %w(
|
7
|
-
AT BE BG CY CZ DE DK EE ES FI FR GB GR HR HU IE IT LT LU LV MT NL PL PT RO SE SI SK
|
8
|
-
).map { |country_code| Carmen::Country.coded(country_code) }
|
9
|
-
|
10
|
-
class << self
|
11
|
-
private
|
12
|
-
|
13
|
-
def countries_by_code(code)
|
14
|
-
all_countries = Carmen::Country.all
|
15
|
-
covered_countries = EU_COUNTRIES + %w(US PR CA PL MX).map do |country_code|
|
16
|
-
Carmen::Country.coded(country_code)
|
17
|
-
end
|
18
|
-
other_countries = Carmen::Country.all - covered_countries
|
19
|
-
case code
|
20
|
-
when 'EU' then EU_COUNTRIES
|
21
|
-
when 'OTHER' then other_countries
|
22
|
-
when 'ALL' then all_countries
|
23
|
-
else
|
24
|
-
[Carmen::Country.coded(code)]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
SHIPPING_METHODS = [
|
30
|
-
['US', 'international', 'UPS Standard', '11'],
|
31
|
-
['US', 'international', 'UPS Worldwide Express', '07'],
|
32
|
-
['US', 'international', 'UPS Worldwide Expedited', '08'],
|
33
|
-
['US', 'international', 'UPS Worldwide Express Plus', '54'],
|
34
|
-
['US', 'international', 'UPS Worldwide Saver', '65'],
|
35
|
-
['US', 'domestic', 'UPS 2nd Day Air', '02'],
|
36
|
-
['US', 'domestic', 'UPS 2nd Day Air A.M.', '59'],
|
37
|
-
['US', 'domestic', 'UPS 3 Day Select', '12'],
|
38
|
-
['US', 'domestic', 'UPS Ground', '03'],
|
39
|
-
['US', 'domestic', 'UPS Next Day Air', '01'],
|
40
|
-
['US', 'domestic', 'UPS Next Day Air Early', '14'],
|
41
|
-
['US', 'domestic', 'UPS Next Day Air Saver', '13'],
|
42
|
-
['US', 'domestic', 'UPS SurePost Less than 1LB', '92'],
|
43
|
-
['US', 'domestic', 'UPS SurePost 1LB or greater', '93'],
|
44
|
-
['US', 'domestic', 'UPS SurePost BPM', '94'],
|
45
|
-
['US', 'domestic', 'UPS SurePost Media Mail', '95'],
|
46
|
-
['CA', 'domestic', 'UPS Expedited Canadian domestic shipments', '02'],
|
47
|
-
['CA', 'domestic', 'UPS Express Saver Canadian domestic shipments', '13'],
|
48
|
-
['CA', 'domestic', 'UPS 3 Day Select Shipments originating in Canada to CA and US 48', '12'],
|
49
|
-
['CA', 'international', 'UPS 3 Day Select Shipments originating in Canada to CA and US 48', '12'],
|
50
|
-
['CA', 'domestic', 'UPS Access Point Economy Canadian domestic shipments', '70'],
|
51
|
-
['CA', 'domestic', 'UPS Express Canadian domestic shipments', '01'],
|
52
|
-
['CA', 'domestic', 'UPS Express Early Canadian domestic shipments', '14'],
|
53
|
-
['CA', 'international', 'UPS Express Saver International shipments originating in Canada', '65'],
|
54
|
-
['CA', 'international', 'UPS Standard Shipments originating in Canada (Domestic and Int’l)', '11'],
|
55
|
-
['CA', 'domestic', 'UPS Standard Shipments originating in Canada (Domestic and Int’l)', '11'],
|
56
|
-
['CA', 'international', 'UPS Worldwide Expedited International shipments originating in Canada', '08'],
|
57
|
-
['CA', 'international', 'UPS Worldwide Express International shipments originating in Canada', '07'],
|
58
|
-
['CA', 'international', 'UPS Worldwide Express Plus International shipments originating in Canada', '54'],
|
59
|
-
['CA', 'international', 'UPS Express Early Shipments originating in Canada to CA and US 48', '54'],
|
60
|
-
['CA', 'domestic', 'UPS Express Early Shipments originating in Canada to CA and US 48', '54'],
|
61
|
-
['EU', 'domestic', 'UPS Access Point Economy Shipments within the European Union', '70'],
|
62
|
-
['EU', 'international', 'UPS Expedited Shipments originating in the European Union', '08'],
|
63
|
-
['EU', 'international', 'UPS Express Shipments originating in the European Union', '07'],
|
64
|
-
['EU', 'international', 'UPS Standard Shipments originating in the European Union', '11'],
|
65
|
-
['EU', 'international', 'UPS Worldwide Express Plus Shipments originating in the European Union', '54'],
|
66
|
-
['EU', 'international', 'UPS Worldwide Saver Shipments originating in the European Union', '65'],
|
67
|
-
['MX', 'domestic', 'UPS Access Point Economy Shipments within Mexico', '70'],
|
68
|
-
['MX', 'international', 'UPS Expedited Shipments originating in Mexico', '08'],
|
69
|
-
['MX', 'international', 'UPS Express Shipments originating in Mexico', '07'],
|
70
|
-
['MX', 'international', 'UPS Standard Shipments originating in Mexico', '11'],
|
71
|
-
['MX', 'international', 'UPS Worldwide Express Plus Shipments originating in Mexico', '54'],
|
72
|
-
['MX', 'international', 'UPS Worldwide Saver Shipments originating in Mexico', '65'],
|
73
|
-
['PL', 'domestic', 'UPS Access Point Economy Polish domestic shipments', '70'],
|
74
|
-
['PL', 'domestic', 'UPS Today Dedicated Courier Polish domestic shipments', '83'],
|
75
|
-
['PL', 'domestic', 'UPS Today Express Polish domestic shipments', '85'],
|
76
|
-
['PL', 'domestic', 'UPS Today Express Saver Polish domestic shipments', '86'],
|
77
|
-
['PL', 'domestic', 'UPS Today Standard Polish domestic shipments', '82'],
|
78
|
-
['PL', 'international', 'UPS Expedited Shipments originating in Poland', '08'],
|
79
|
-
['PL', 'international', 'UPS Express Shipments originating in Poland', '07'],
|
80
|
-
['PL', 'international', 'UPS Express Plus Shipments originating in Poland', '54'],
|
81
|
-
['PL', 'international', 'UPS Express Saver Shipments originating in Poland', '65'],
|
82
|
-
['PL', 'international', 'UPS Standard Shipments originating in Poland', '11'],
|
83
|
-
['PR', 'domestic', 'UPS 2nd Day Air', '02'],
|
84
|
-
['PR', 'domestic', 'UPS Ground', '03'],
|
85
|
-
['PR', 'domestic', 'UPS Next Day Air', '01'],
|
86
|
-
['PR', 'domestic', 'UPS Next Day Air Early', '14'],
|
87
|
-
['PR', 'international', 'UPS Worldwide Expedited', '08'],
|
88
|
-
['PR', 'international', 'UPS Worldwide Express', '07'],
|
89
|
-
['PR', 'international', 'UPS Worldwide Express Plus', '54'],
|
90
|
-
['PR', 'international', 'UPS Worldwide Saver', '65'],
|
91
|
-
['DE', 'domestic', 'UPS Express 12:00 German domestic shipments', '74'],
|
92
|
-
['OTHER', 'domestic', 'UPS Express', '07'],
|
93
|
-
['OTHER', 'domestic', 'UPS Standard', '11'],
|
94
|
-
['OTHER', 'international', 'UPS Worldwide Expedited', '08'],
|
95
|
-
['OTHER', 'international', 'UPS Worldwide Express Plus', '54'],
|
96
|
-
['OTHER', 'international', 'UPS Worldwide Saver', '65'],
|
97
|
-
['ALL', 'international', 'UPS Worldwide Express Freight', '96'],
|
98
|
-
['ALL', 'international', 'UPS Worldwide Express Freight Midday', '71']
|
99
|
-
].freeze.map do |origin_country_code, dom_or_intl, name, code|
|
100
|
-
FriendlyShipping::ShippingMethod.new(
|
101
|
-
name: name,
|
102
|
-
service_code: code,
|
103
|
-
domestic: dom_or_intl == 'domestic',
|
104
|
-
international: dom_or_intl == 'international',
|
105
|
-
origin_countries: countries_by_code(origin_country_code),
|
106
|
-
multi_package: true
|
107
|
-
).freeze
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FriendlyShipping
|
4
|
-
module Services
|
5
|
-
class Ups
|
6
|
-
# Options for getting timing information from UPS
|
7
|
-
# @attribute [Time] pickup When the shipment will be picked up
|
8
|
-
# @attribute [Money] invoice_total How much the items in the shipment are worth
|
9
|
-
# As this is not super important for getting timing information, we use a default
|
10
|
-
# value of 50 USD here.
|
11
|
-
# @attribute [Boolean] documents_only Does the shipment only contain documents?
|
12
|
-
# @attribute [String] customer_context A string to connect request and response in the calling code
|
13
|
-
class TimingOptions
|
14
|
-
attr_reader :pickup,
|
15
|
-
:invoice_total,
|
16
|
-
:documents_only,
|
17
|
-
:customer_context
|
18
|
-
|
19
|
-
def initialize(
|
20
|
-
pickup: Time.now,
|
21
|
-
invoice_total: Money.new(5000, 'USD'),
|
22
|
-
documents_only: false,
|
23
|
-
customer_context: nil
|
24
|
-
)
|
25
|
-
@pickup = pickup
|
26
|
-
@invoice_total = invoice_total
|
27
|
-
@documents_only = documents_only
|
28
|
-
@customer_context = customer_context
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|