ups 0.0.3 → 0.0.4
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/lib/ups/models/package.rb +1 -1
- data/lib/ups/models/rate_request.rb +1 -1
- data/lib/ups/models/ship_request.rb +1 -1
- data/lib/ups/rating.rb +14 -5
- data/lib/ups/shipping.rb +5 -5
- 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: 6f299fda5bfe8460f0531eb9d9e63415485e2cbbcd765a354987b4fde149c6e3
|
4
|
+
data.tar.gz: 0fac23629a457243445d9dffd7f88fcb30aece68d93c1abce23712295289b121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1248beb741ad2d3761602dd0f3e24794d480d90d7e35622572eb096b03b86694cfbf49dbc7934687125e19a3a3f2ff57c4042e25510d67e0d04c05468268e4b
|
7
|
+
data.tar.gz: fd11af41e93dcb64e62d44c0602181ad774b805ad7a38c1ac374663d1c283b6c4ee241d2a859b88c1fd25f046a45d75bb37aa87605d420ff29f7c3dc695a06ea
|
data/lib/ups/models/package.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ups
|
2
2
|
class Package
|
3
|
-
attr_accessor :description, :packaging_type, :length, :width, :height, :weight, :dimension_unit, :weight_unit, :
|
3
|
+
attr_accessor :description, :packaging_type, :length, :width, :height, :weight, :dimension_unit, :weight_unit, :insurance, :delivery_confirmation
|
4
4
|
|
5
5
|
def initialize(attrs = {})
|
6
6
|
attrs.map{|k,v| send("#{k}=", v) if respond_to?("#{k}=") }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ups
|
2
2
|
class RateRequest
|
3
|
-
attr_accessor :shipper, :ship_to, :ship_from, :packages, :service_code, :reference
|
3
|
+
attr_accessor :shipper, :ship_to, :ship_from, :packages, :service_code, :reference
|
4
4
|
|
5
5
|
def initialize(attrs = {})
|
6
6
|
attrs.map{|k, v| send("#{k}=", v) if respond_to?("#{k}=") }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ups
|
2
2
|
class ShipRequest
|
3
|
-
attr_accessor :shipper, :ship_to, :ship_from, :packages, :service_code, :reference, :description, :label_format
|
3
|
+
attr_accessor :shipper, :ship_to, :ship_from, :packages, :service_code, :reference, :description, :label_format
|
4
4
|
|
5
5
|
def initialize(attrs = {})
|
6
6
|
attrs.map{|k, v| send("#{k}=", v) if respond_to?("#{k}=") }
|
data/lib/ups/rating.rb
CHANGED
@@ -48,7 +48,7 @@ module Ups
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
},
|
51
|
-
Package: rate_request.packages.map { |pkg| package_hash(pkg
|
51
|
+
Package: rate_request.packages.map { |pkg| package_hash(pkg) },
|
52
52
|
Service: {
|
53
53
|
Code: rate_request.service_code || "03"
|
54
54
|
}
|
@@ -67,7 +67,7 @@ module Ups
|
|
67
67
|
}
|
68
68
|
end
|
69
69
|
|
70
|
-
def package_hash(package
|
70
|
+
def package_hash(package)
|
71
71
|
base = {
|
72
72
|
PackagingType: {
|
73
73
|
Code: package.packaging_type || "02"
|
@@ -89,15 +89,24 @@ module Ups
|
|
89
89
|
PackageServiceOptions: {
|
90
90
|
DeclaredValue: {
|
91
91
|
CurrencyCode: "USD",
|
92
|
-
MonetaryValue: package.
|
92
|
+
MonetaryValue: package.insurance
|
93
93
|
}
|
94
94
|
}
|
95
95
|
}
|
96
|
-
base.deep_merge!(signature_required(
|
96
|
+
base.deep_merge!(signature_required(package.delivery_confirmation)) if [2,3].include?(package&.delivery_confirmation.to_i)
|
97
97
|
base
|
98
98
|
end
|
99
99
|
|
100
|
-
def signature_required(type
|
100
|
+
def signature_required(type)
|
101
|
+
# https://github.com/UPS-API/api-documentation/blob/main/Rating.yaml
|
102
|
+
# DCISType fails if the value is nil, 0, or 1...
|
103
|
+
# but 2 and 3 work as expected. So we need to omit
|
104
|
+
# the key altogether if the value is not one of 2 or 3.
|
105
|
+
# {
|
106
|
+
# 1 => 'Unsupported', # this fails for some reason, so ignore it
|
107
|
+
# 2 => 'Delivery Confirmation Signature Required',
|
108
|
+
# 3 => 'Delivery Confirmation Adult Signature Required'
|
109
|
+
# }
|
101
110
|
{
|
102
111
|
PackageServiceOptions: {
|
103
112
|
DeliveryConfirmation: {
|
data/lib/ups/shipping.rb
CHANGED
@@ -66,7 +66,7 @@ module Ups
|
|
66
66
|
Code: ship_request.service_code || "02",
|
67
67
|
Description: "Service Code"
|
68
68
|
},
|
69
|
-
Package: ship_request.packages.map { |pkg| package_hash(pkg
|
69
|
+
Package: ship_request.packages.map { |pkg| package_hash(pkg) }
|
70
70
|
},
|
71
71
|
LabelSpecification: {
|
72
72
|
LabelImageFormat: {
|
@@ -88,7 +88,7 @@ module Ups
|
|
88
88
|
}
|
89
89
|
end
|
90
90
|
|
91
|
-
def package_hash(package
|
91
|
+
def package_hash(package)
|
92
92
|
base = {
|
93
93
|
Description: package.description || "Package",
|
94
94
|
Packaging: {
|
@@ -111,15 +111,15 @@ module Ups
|
|
111
111
|
PackageServiceOptions: {
|
112
112
|
DeclaredValue: {
|
113
113
|
CurrencyCode: "USD",
|
114
|
-
MonetaryValue: package.
|
114
|
+
MonetaryValue: package.insurance
|
115
115
|
}
|
116
116
|
},
|
117
117
|
InsuredValue: {
|
118
118
|
CurrencyCode: "USD",
|
119
|
-
MonetaryValue: package.
|
119
|
+
MonetaryValue: package.insurance
|
120
120
|
}
|
121
121
|
}
|
122
|
-
base.deep_merge!(signature_required(
|
122
|
+
base.deep_merge!(signature_required(package.delivery_confirmation)) if [2,3].include?(package&.delivery_confirmation.to_i)
|
123
123
|
base
|
124
124
|
end
|
125
125
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JD Warren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|