shipengine_ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +305 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +111 -0
- data/LICENSE.txt +21 -0
- data/README.md +14 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/shipengine/client.rb +71 -0
- data/lib/shipengine/configuration.rb +26 -0
- data/lib/shipengine/constants.rb +203 -0
- data/lib/shipengine/domains/addresses.rb +33 -0
- data/lib/shipengine/domains/batches.rb +103 -0
- data/lib/shipengine/domains/carriers.rb +67 -0
- data/lib/shipengine/domains/carriers_accounts.rb +49 -0
- data/lib/shipengine/domains/labels.rb +94 -0
- data/lib/shipengine/domains/manifests.rb +49 -0
- data/lib/shipengine/domains/package_pickups.rb +49 -0
- data/lib/shipengine/domains/package_types.rb +58 -0
- data/lib/shipengine/domains/rates.rb +49 -0
- data/lib/shipengine/domains/service_points.rb +31 -0
- data/lib/shipengine/domains/shipments.rb +103 -0
- data/lib/shipengine/domains/shipsurance.rb +49 -0
- data/lib/shipengine/domains/tags.rb +49 -0
- data/lib/shipengine/domains/tokens.rb +22 -0
- data/lib/shipengine/domains/tracking.rb +40 -0
- data/lib/shipengine/domains/warehouses.rb +58 -0
- data/lib/shipengine/domains/webhooks.rb +58 -0
- data/lib/shipengine/domains.rb +19 -0
- data/lib/shipengine/enums/address_residential_indicator_types.rb +20 -0
- data/lib/shipengine/enums/address_status.rb +34 -0
- data/lib/shipengine/enums/batch_status.rb +34 -0
- data/lib/shipengine/enums/carriers_names.rb +91 -0
- data/lib/shipengine/enums/label_status.rb +22 -0
- data/lib/shipengine/enums/message_types.rb +30 -0
- data/lib/shipengine/enums/validate_address_types.rb +19 -0
- data/lib/shipengine/enums/webhooks_types.rb +52 -0
- data/lib/shipengine/enums.rb +9 -0
- data/lib/shipengine/errors/error_code.rb +224 -0
- data/lib/shipengine/errors/error_source.rb +39 -0
- data/lib/shipengine/errors/error_type.rb +49 -0
- data/lib/shipengine/exceptions.rb +79 -0
- data/lib/shipengine/faraday/raise_http_exception.rb +83 -0
- data/lib/shipengine/utils/validate.rb +102 -0
- data/lib/shipengine/utils.rb +3 -0
- data/lib/shipengine/version.rb +7 -0
- data/lib/shipengine.rb +26 -0
- data/shipengine.gemspec +41 -0
- metadata +249 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Constants
|
7
|
+
API_KEY = ENV.fetch("API_KEY", "TEST_35vcTMIX0/e7rs1t86zzYwF+tnq2jrYewIyRZp+pxAs")
|
8
|
+
|
9
|
+
PROD_URL = "https://api.shipengine.com"
|
10
|
+
|
11
|
+
Paths = Struct.new(
|
12
|
+
:v1,
|
13
|
+
keyword_init: true
|
14
|
+
)
|
15
|
+
NamespaceV1 = Struct.new(
|
16
|
+
:addresses,
|
17
|
+
:batches,
|
18
|
+
:carriers_accounts,
|
19
|
+
:carriers,
|
20
|
+
:shipsurance,
|
21
|
+
:labels,
|
22
|
+
:manifests,
|
23
|
+
:package_pickups,
|
24
|
+
:package_types,
|
25
|
+
:rates,
|
26
|
+
:service_points,
|
27
|
+
:shipments,
|
28
|
+
:tags,
|
29
|
+
:tokens,
|
30
|
+
:tracking,
|
31
|
+
:warehouses,
|
32
|
+
:webhooks,
|
33
|
+
keyword_init: true
|
34
|
+
)
|
35
|
+
Addresses = Struct.new(
|
36
|
+
:parse_address,
|
37
|
+
:validate_address,
|
38
|
+
keyword_init: true
|
39
|
+
)
|
40
|
+
Batches = Struct.new(
|
41
|
+
:root,
|
42
|
+
:batch_by_external_id,
|
43
|
+
keyword_init: true
|
44
|
+
)
|
45
|
+
CarriersAccounts = Struct.new(
|
46
|
+
:root,
|
47
|
+
keyword_init: true
|
48
|
+
)
|
49
|
+
Carriers = Struct.new(
|
50
|
+
:root,
|
51
|
+
keyword_init: true
|
52
|
+
)
|
53
|
+
Shipsurance = Struct.new(
|
54
|
+
:root,
|
55
|
+
:add_funds,
|
56
|
+
:balance,
|
57
|
+
keyword_init: true
|
58
|
+
)
|
59
|
+
Labels = Struct.new(
|
60
|
+
:root,
|
61
|
+
:label_by_external_shipment_id,
|
62
|
+
:purchase_label_with_rate_id,
|
63
|
+
:purchase_label_with_shipment_id,
|
64
|
+
keyword_init: true
|
65
|
+
)
|
66
|
+
Manifests = Struct.new(
|
67
|
+
:root,
|
68
|
+
:manifest_request,
|
69
|
+
keyword_init: true
|
70
|
+
)
|
71
|
+
PackagePickups = Struct.new(
|
72
|
+
:root,
|
73
|
+
keyword_init: true
|
74
|
+
)
|
75
|
+
PackageTypes = Struct.new(
|
76
|
+
:root,
|
77
|
+
keyword_init: true
|
78
|
+
)
|
79
|
+
Rates = Struct.new(
|
80
|
+
:root,
|
81
|
+
keyword_init: true
|
82
|
+
)
|
83
|
+
ServicePoints = Struct.new(
|
84
|
+
:root,
|
85
|
+
keyword_init: true
|
86
|
+
)
|
87
|
+
Shipments = Struct.new(
|
88
|
+
:root,
|
89
|
+
:shipment_by_external_id,
|
90
|
+
:parse_shipping_info,
|
91
|
+
keyword_init: true
|
92
|
+
)
|
93
|
+
Tags = Struct.new(
|
94
|
+
:root,
|
95
|
+
keyword_init: true
|
96
|
+
)
|
97
|
+
Tokens = Struct.new(
|
98
|
+
:root,
|
99
|
+
keyword_init: true
|
100
|
+
)
|
101
|
+
Tracking = Struct.new(
|
102
|
+
:root,
|
103
|
+
keyword_init: true
|
104
|
+
)
|
105
|
+
Warehouses = Struct.new(
|
106
|
+
:root,
|
107
|
+
keyword_init: true
|
108
|
+
)
|
109
|
+
Webhooks = Struct.new(
|
110
|
+
:root,
|
111
|
+
keyword_init: true
|
112
|
+
)
|
113
|
+
|
114
|
+
PATHS = Paths.new(
|
115
|
+
v1: NamespaceV1.new(
|
116
|
+
addresses: Addresses.new(
|
117
|
+
parse_address: "/v1/addresses/recognize",
|
118
|
+
validate_address: "/v1/addresses/validate",
|
119
|
+
),
|
120
|
+
batches: Batches.new(
|
121
|
+
root: "/v1/batches",
|
122
|
+
batch_by_external_id: "/v1/batches/external_batch_id",
|
123
|
+
),
|
124
|
+
carriers_accounts: CarriersAccounts.new(
|
125
|
+
root: "/v1/connections/carriers",
|
126
|
+
),
|
127
|
+
carriers: Carriers.new(
|
128
|
+
root: "/v1/carriers",
|
129
|
+
),
|
130
|
+
shipsurance: Shipsurance.new(
|
131
|
+
root: "/v1/connections/insurance/shipsurance",
|
132
|
+
add_funds: "/v1/insurance/shipsurance/add_funds",
|
133
|
+
balance: "/v1/insurance/shipsurance/balance",
|
134
|
+
),
|
135
|
+
labels: Labels.new(
|
136
|
+
root: "/v1/labels",
|
137
|
+
label_by_external_shipment_id: "/v1/labels/external_shipment_id",
|
138
|
+
purchase_label_with_rate_id: "/v1/labels/rates",
|
139
|
+
purchase_label_with_shipment_id: "/v1/labels/shipment",
|
140
|
+
),
|
141
|
+
manifests: Manifests.new(
|
142
|
+
root: "/v1/manifests",
|
143
|
+
manifest_request: "/v1/manifests/requests",
|
144
|
+
),
|
145
|
+
package_pickups: PackagePickups.new(
|
146
|
+
root: "/v1/pickups",
|
147
|
+
),
|
148
|
+
package_types: PackageTypes.new(
|
149
|
+
root: "/v1/packages",
|
150
|
+
),
|
151
|
+
rates: Rates.new(
|
152
|
+
root: "/v1/rates",
|
153
|
+
),
|
154
|
+
service_points: ServicePoints.new(
|
155
|
+
root: "/v1/service_points",
|
156
|
+
),
|
157
|
+
shipments: Shipments.new(
|
158
|
+
root: "/v1/shipments",
|
159
|
+
shipment_by_external_id: "/v1/shipments/external_shipment_id",
|
160
|
+
parse_shipping_info: "/v1/shipments/recognize",
|
161
|
+
),
|
162
|
+
tags: Tags.new(
|
163
|
+
root: "/v1/tags",
|
164
|
+
),
|
165
|
+
tokens: Tokens.new(
|
166
|
+
root: "/v1/tokens/ephemeral",
|
167
|
+
),
|
168
|
+
tracking: Tracking.new(
|
169
|
+
root: "/v1/tracking",
|
170
|
+
),
|
171
|
+
warehouses: Warehouses.new(
|
172
|
+
root: "/v1/warehouses",
|
173
|
+
),
|
174
|
+
webhooks: Webhooks.new(
|
175
|
+
root: "/v1/environment/webhooks",
|
176
|
+
)
|
177
|
+
)
|
178
|
+
)
|
179
|
+
|
180
|
+
RETRIES = 1
|
181
|
+
|
182
|
+
TIMEOUT = 30_000
|
183
|
+
|
184
|
+
PAGE_SIZE = 50
|
185
|
+
|
186
|
+
# Regex pattern to match a valid *ISO-8601* string with timezone.
|
187
|
+
VALID_ISO_STRING = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$/.freeze
|
188
|
+
|
189
|
+
# Regex pattern to match a valid *ISO-8601* string with no timezone.
|
190
|
+
VALID_ISO_STRING_WITH_NO_TZ = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?([+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$/.freeze
|
191
|
+
|
192
|
+
module Country
|
193
|
+
# rubocop:disable Layout/LineLength
|
194
|
+
@countries = ["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"].freeze
|
195
|
+
# rubocop:enable Layout/LineLength
|
196
|
+
|
197
|
+
# @param [String] country - 2 letter country code
|
198
|
+
def self.valid?(country)
|
199
|
+
@countries.include?(country.upcase)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class Addresses
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_address(address)
|
13
|
+
response = @client.put(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.addresses.parse_address,
|
15
|
+
options: address
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_address(addresses)
|
22
|
+
clean_addresses = addresses.map(&:compact)
|
23
|
+
|
24
|
+
response = @client.post(
|
25
|
+
path: ShipEngine::Constants::PATHS.v1.addresses.validate_address,
|
26
|
+
options: clean_addresses
|
27
|
+
)
|
28
|
+
|
29
|
+
response.body.map { |address| Hashie::Mash.new(address) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class Batches
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_batches(params: {})
|
13
|
+
response = @client.get(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.batches.root,
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_batch(params:)
|
22
|
+
response = @client.post(
|
23
|
+
path: ShipEngine::Constants::PATHS.v1.batches.root,
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def batch_by_external_id(external_batch_id:, params: {})
|
31
|
+
response = @client.get(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.batch_by_external_id}/#{external_batch_id}",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_batch_by_id(batch_id:, params: {})
|
40
|
+
response = @client.delete(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def batch_by_id(batch_id:, params: {})
|
49
|
+
response = @client.get(
|
50
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}",
|
51
|
+
options: params
|
52
|
+
)
|
53
|
+
|
54
|
+
Hashie::Mash.new(response.body)
|
55
|
+
end
|
56
|
+
|
57
|
+
def update_batch_by_id(batch_id:, params: {})
|
58
|
+
response = @client.put(
|
59
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}",
|
60
|
+
options: params
|
61
|
+
)
|
62
|
+
|
63
|
+
Hashie::Mash.new(response.body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_to_batch(batch_id:, params: {})
|
67
|
+
response = @client.post(
|
68
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}/add",
|
69
|
+
options: params
|
70
|
+
)
|
71
|
+
|
72
|
+
Hashie::Mash.new(response.body)
|
73
|
+
end
|
74
|
+
|
75
|
+
def batch_errors(batch_id:, params: {})
|
76
|
+
response = @client.get(
|
77
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}/errors",
|
78
|
+
options: params
|
79
|
+
)
|
80
|
+
|
81
|
+
Hashie::Mash.new(response.body)
|
82
|
+
end
|
83
|
+
|
84
|
+
def process_batch_id_labels(batch_id:, params: {})
|
85
|
+
response = @client.post(
|
86
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}/process/labels",
|
87
|
+
options: params
|
88
|
+
)
|
89
|
+
|
90
|
+
Hashie::Mash.new(response.body)
|
91
|
+
end
|
92
|
+
|
93
|
+
def remove_from_batch(batch_id:, params: {})
|
94
|
+
response = @client.post(
|
95
|
+
path: "#{ShipEngine::Constants::PATHS.v1.batches.root}/#{batch_id}/remove",
|
96
|
+
options: params
|
97
|
+
)
|
98
|
+
|
99
|
+
Hashie::Mash.new(response.body)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class Carriers
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_carriers(params: {})
|
13
|
+
response = @client.get(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.carriers.root,
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def carrier_by_id(carrier_id:, params: {})
|
22
|
+
response = @client.get(
|
23
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers.root}/#{carrier_id}",
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_funds_to_carrier(carrier_id:, params: {})
|
31
|
+
response = @client.put(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers.root}/#{carrier_id}/add_funds",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def carrier_options(carrier_id:, params: {})
|
40
|
+
response = @client.get(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers.root}/#{carrier_id}/options",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def list_carrier_package_types(carrier_id:, params: {})
|
49
|
+
response = @client.get(
|
50
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers.root}/#{carrier_id}/packages",
|
51
|
+
options: params
|
52
|
+
)
|
53
|
+
|
54
|
+
Hashie::Mash.new(response.body)
|
55
|
+
end
|
56
|
+
|
57
|
+
def list_carrier_services(carrier_id:, params: {})
|
58
|
+
response = @client.get(
|
59
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers.root}/#{carrier_id}/services",
|
60
|
+
options: params
|
61
|
+
)
|
62
|
+
|
63
|
+
Hashie::Mash.new(response.body)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class CarriersAccounts
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def connect_carrier_account(carrier_name:, params: {})
|
13
|
+
response = @client.post(
|
14
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers_accounts.root}/#{carrier_name}",
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def disconnect_carrier_account(carrier_name:, carrier_id:, params: {})
|
22
|
+
response = @client.delete(
|
23
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers_accounts.root}/#{carrier_name}/#{carrier_id}",
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def carrier_settings(carrier_name:, carrier_id:, params: {})
|
31
|
+
response = @client.get(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers_accounts.root}/#{carrier_name}/#{carrier_id}/settings",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_carrier_settings(carrier_name:, carrier_id:, params: {})
|
40
|
+
response = @client.put(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.carriers_accounts.root}/#{carrier_name}/#{carrier_id}/settings",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class Labels
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_labels(params: {})
|
13
|
+
response = @client.get(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.labels.root,
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def purchase_label(params: {})
|
22
|
+
response = @client.post(
|
23
|
+
path: ShipEngine::Constants::PATHS.v1.labels.root,
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def label_by_external_shipment_id(shipment_id:, params: {})
|
31
|
+
response = @client.get(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.label_by_external_shipment_id}/#{shipment_id}",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def purchase_label_with_rate_id(rate_id:, params: {})
|
40
|
+
response = @client.post(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.purchase_label_with_rate_id}/#{rate_id}",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def purchase_label_with_shipment_id(shipment_id:, params: {})
|
49
|
+
response = @client.post(
|
50
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.purchase_label_with_shipment_id}/#{shipment_id}",
|
51
|
+
options: params
|
52
|
+
)
|
53
|
+
|
54
|
+
Hashie::Mash.new(response.body)
|
55
|
+
end
|
56
|
+
|
57
|
+
def label_by_id(label_id:, params: {})
|
58
|
+
response = @client.get(
|
59
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.root}/#{label_id}",
|
60
|
+
options: params
|
61
|
+
)
|
62
|
+
|
63
|
+
Hashie::Mash.new(response.body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_return_label(label_id:, params: {})
|
67
|
+
response = @client.post(
|
68
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.root}/#{label_id}/return",
|
69
|
+
options: params
|
70
|
+
)
|
71
|
+
|
72
|
+
Hashie::Mash.new(response.body)
|
73
|
+
end
|
74
|
+
|
75
|
+
def label_tracking_information(label_id:, params: {})
|
76
|
+
response = @client.get(
|
77
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.root}/#{label_id}/track",
|
78
|
+
options: params
|
79
|
+
)
|
80
|
+
|
81
|
+
Hashie::Mash.new(response.body)
|
82
|
+
end
|
83
|
+
|
84
|
+
def void_label_by_id(label_id:, params: {})
|
85
|
+
response = @client.put(
|
86
|
+
path: "#{ShipEngine::Constants::PATHS.v1.labels.root}/#{label_id}/void",
|
87
|
+
options: params
|
88
|
+
)
|
89
|
+
|
90
|
+
Hashie::Mash.new(response.body)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class Manifests
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_manifests(params: {})
|
13
|
+
response = @client.get(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.manifests.root,
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_manifest(params: {})
|
22
|
+
response = @client.post(
|
23
|
+
path: ShipEngine::Constants::PATHS.v1.manifests.root,
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def manifest_by_id(manifest_id:, params: {})
|
31
|
+
response = @client.get(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.manifests.root}/#{manifest_id}",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def manifest_request_by_id(manifest_request_id:, params: {})
|
40
|
+
response = @client.get(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.manifests.manifest_request}/#{manifest_request_id}",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hashie"
|
4
|
+
|
5
|
+
module ShipEngine
|
6
|
+
module Domain
|
7
|
+
class PackagePickups
|
8
|
+
def initialize
|
9
|
+
@client = ShipEngine::Client.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_package_pickups(params: {})
|
13
|
+
response = @client.get(
|
14
|
+
path: ShipEngine::Constants::PATHS.v1.package_pickups.root,
|
15
|
+
options: params
|
16
|
+
)
|
17
|
+
|
18
|
+
Hashie::Mash.new(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def schedule_pickup(params: {})
|
22
|
+
response = @client.post(
|
23
|
+
path: ShipEngine::Constants::PATHS.v1.package_pickups.root,
|
24
|
+
options: params
|
25
|
+
)
|
26
|
+
|
27
|
+
Hashie::Mash.new(response.body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def pickup_by_id(pickup_id:, params: {})
|
31
|
+
response = @client.get(
|
32
|
+
path: "#{ShipEngine::Constants::PATHS.v1.package_pickups.root}/#{pickup_id}",
|
33
|
+
options: params
|
34
|
+
)
|
35
|
+
|
36
|
+
Hashie::Mash.new(response.body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_schedule_pickup(pickup_id:, params: {})
|
40
|
+
response = @client.delete(
|
41
|
+
path: "#{ShipEngine::Constants::PATHS.v1.package_pickups.root}/#{pickup_id}",
|
42
|
+
options: params
|
43
|
+
)
|
44
|
+
|
45
|
+
Hashie::Mash.new(response.body)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|