friendly_shipping 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop-relaxed.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/lib/friendly_shipping/services/ship_engine/label_options.rb +1 -1
- data/lib/friendly_shipping/services/ship_engine/label_package_options.rb +1 -1
- data/lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb +1 -1
- data/lib/friendly_shipping/services/ups/label_item_options.rb +1 -1
- data/lib/friendly_shipping/services/ups/label_options.rb +1 -1
- data/lib/friendly_shipping/services/ups/label_package_options.rb +1 -1
- data/lib/friendly_shipping/services/ups/parse_rate_response.rb +61 -39
- data/lib/friendly_shipping/services/ups_freight/rates_item_options.rb +1 -1
- data/lib/friendly_shipping/services/ups_freight/rates_options.rb +1 -1
- data/lib/friendly_shipping/services/ups_freight/rates_package_options.rb +1 -1
- data/lib/friendly_shipping/services/usps/parse_time_in_transit_response.rb +5 -0
- data/lib/friendly_shipping/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7315eaa32f0429125e0c992d06d2093d324416e0bf36ac79bb5e2a0d1fc7135
|
4
|
+
data.tar.gz: e7a15a667a37321ff006da9c5f2d3478bf9f3089a35ae84db4227a775178438c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f460abf860b45f6079d364a770f1035778ecc0c5d98dcf5409c5a9f4b244326d954dad6ee3d881927470dbcde089114e767fed5a1e884d56133c419af77e9e8d
|
7
|
+
data.tar.gz: b0e92858e9922f8f85b1f93d22d9b5cc13c5af55f864acc6d6e30caddae110b6a65f73c840b12129c1bd34ba65f67f195dcbf0bc756ead50dbd429cc8e184871
|
data/.rubocop-relaxed.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.4.9] - 2020-01-09
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- USPS Service: Add missing Commitment sequence (#68)
|
11
|
+
- Code quality: Add double splats for Ruby 2.7 compatibility (#67)
|
12
|
+
- UPS Service: Add more package-level detail to rate responses (#65)
|
13
|
+
|
7
14
|
## [0.4.8] - 2020-01-06
|
8
15
|
|
9
16
|
### Changed
|
@@ -26,7 +26,7 @@ module FriendlyShipping
|
|
26
26
|
@shipping_method = shipping_method
|
27
27
|
@label_format = label_format
|
28
28
|
@label_download_type = label_download_type
|
29
|
-
super
|
29
|
+
super(**kwargs.merge(package_options_class: LabelPackageOptions))
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -139,7 +139,7 @@ module FriendlyShipping
|
|
139
139
|
@terms_of_shipment = terms_of_shipment
|
140
140
|
@reason_for_export = reason_for_export
|
141
141
|
@invoice_date = invoice_date
|
142
|
-
super
|
142
|
+
super(**kwargs.merge(package_options_class: package_options_class))
|
143
143
|
end
|
144
144
|
|
145
145
|
def delivery_confirmation_code
|
@@ -31,7 +31,7 @@ module FriendlyShipping
|
|
31
31
|
@reference_numbers = reference_numbers
|
32
32
|
@delivery_confirmation = delivery_confirmation
|
33
33
|
@shipper_release = shipper_release
|
34
|
-
super
|
34
|
+
super(**kwargs.merge(item_options_class: LabelItemOptions))
|
35
35
|
end
|
36
36
|
|
37
37
|
def delivery_confirmation_code
|
@@ -7,50 +7,72 @@ module FriendlyShipping
|
|
7
7
|
module Services
|
8
8
|
class Ups
|
9
9
|
class ParseRateResponse
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
class << self
|
11
|
+
def call(request:, response:, shipment:)
|
12
|
+
parsing_result = ParseXMLResponse.call(response.body, 'RatingServiceSelectionResponse')
|
13
|
+
parsing_result.fmap do |xml|
|
14
|
+
FriendlyShipping::ApiResult.new(
|
15
|
+
build_rates(xml, shipment),
|
16
|
+
original_request: request,
|
17
|
+
original_response: response
|
18
|
+
)
|
19
|
+
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
def build_rates(xml, shipment)
|
23
|
+
xml.root.css('> RatedShipment').map do |rated_shipment|
|
24
|
+
service_code = rated_shipment.at('Service/Code').text
|
25
|
+
shipping_method = CARRIER.shipping_methods.detect do |sm|
|
26
|
+
sm.service_code == service_code && shipment.origin.country.in?(sm.origin_countries)
|
27
|
+
end
|
28
|
+
days_to_delivery = rated_shipment.at('GuaranteedDaysToDelivery').text.to_i
|
29
|
+
|
30
|
+
total = ParseMoneyElement.call(rated_shipment.at('TotalCharges')).last
|
31
|
+
insurance_price = ParseMoneyElement.call(rated_shipment.at('ServiceOptionsCharges'))&.last
|
32
|
+
negotiated_rate = ParseMoneyElement.call(
|
33
|
+
rated_shipment.at('NegotiatedRates/NetSummaryCharges/GrandTotal')
|
34
|
+
)&.last
|
35
|
+
|
36
|
+
rated_shipment_warnings = rated_shipment.css('RatedShipmentWarning').map { |e| e.text.strip }
|
37
|
+
if rated_shipment_warnings.any? { |e| e.match?(/to Residential/) }
|
38
|
+
new_address_type = 'residential'
|
39
|
+
elsif rated_shipment_warnings.any? { |e| e.match?(/to Commercial/) }
|
40
|
+
new_address_type = 'commercial'
|
41
|
+
end
|
42
|
+
|
43
|
+
FriendlyShipping::Rate.new(
|
44
|
+
shipping_method: shipping_method,
|
45
|
+
amounts: { total: total },
|
46
|
+
warnings: rated_shipment_warnings,
|
47
|
+
errors: [],
|
48
|
+
data: {
|
49
|
+
insurance_price: insurance_price,
|
50
|
+
negotiated_rate: negotiated_rate,
|
51
|
+
days_to_delivery: days_to_delivery,
|
52
|
+
new_address_type: new_address_type,
|
53
|
+
packages: build_packages(rated_shipment)
|
54
|
+
}.compact
|
55
|
+
)
|
40
56
|
end
|
57
|
+
end
|
41
58
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
59
|
+
private
|
60
|
+
|
61
|
+
def build_packages(rated_shipment)
|
62
|
+
rated_shipment.css('RatedPackage').map do |rated_package|
|
63
|
+
itemized_charges = rated_package.xpath('ItemizedCharges').map do |element|
|
64
|
+
ParseMoneyElement.call(element)
|
65
|
+
end.compact.to_h
|
66
|
+
{
|
67
|
+
transportation_charges: ParseMoneyElement.call(rated_package.at('TransportationCharges')).last,
|
68
|
+
base_service_charge: ParseMoneyElement.call(rated_package.at('BaseServiceCharge')).last,
|
69
|
+
service_options_charges: ParseMoneyElement.call(rated_package.at('ServiceOptionsCharges'))&.last,
|
70
|
+
itemized_charges: itemized_charges,
|
71
|
+
total_charges: ParseMoneyElement.call(rated_package.at('TotalCharges')).last,
|
72
|
+
weight: BigDecimal(rated_package.at('Weight').text),
|
73
|
+
billing_weight: BigDecimal(rated_package.at('BillingWeight/Weight').text)
|
52
74
|
}.compact
|
53
|
-
|
75
|
+
end
|
54
76
|
end
|
55
77
|
end
|
56
78
|
end
|
@@ -54,7 +54,7 @@ module FriendlyShipping
|
|
54
54
|
@pickup_date = pickup_date
|
55
55
|
@pickup_comments = pickup_comments
|
56
56
|
@commodity_information_generator = commodity_information_generator
|
57
|
-
super
|
57
|
+
super(**kwargs.merge(package_options_class: RatesPackageOptions))
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -30,7 +30,7 @@ module FriendlyShipping
|
|
30
30
|
@handling_unit_code = HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:code)
|
31
31
|
@handling_unit_description = HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:description)
|
32
32
|
@handling_unit_tag = "HandlingUnit#{HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:handling_unit_tag)}"
|
33
|
-
super
|
33
|
+
super(**kwargs.merge(item_options_class: RatesItemOptions))
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -168,6 +168,11 @@ module FriendlyShipping
|
|
168
168
|
commitment_time: '10:30 AM',
|
169
169
|
destination_type: :hold_for_pickup
|
170
170
|
},
|
171
|
+
'B0215' => {
|
172
|
+
commitment: '2-Day',
|
173
|
+
commitment_time: '3:00 PM',
|
174
|
+
destination_type: :hold_for_pickup
|
175
|
+
},
|
171
176
|
'C0100' => {
|
172
177
|
commitment: '1-Day',
|
173
178
|
destination_type: :street
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_shipping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: data_uri
|