easypost 5.3.0 → 6.1.0
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/CHANGELOG.md +10 -0
- data/UPGRADE_GUIDE.md +31 -0
- data/VERSION +1 -1
- data/lib/easypost/client.rb +1 -3
- data/lib/easypost/models/base.rb +3 -1
- data/lib/easypost/models.rb +0 -1
- data/lib/easypost/services/address.rb +22 -7
- data/lib/easypost/services/api_key.rb +3 -1
- data/lib/easypost/services/base.rb +13 -13
- data/lib/easypost/services/batch.rb +23 -15
- data/lib/easypost/services/beta_rate.rb +2 -1
- data/lib/easypost/services/beta_referral_customer.rb +9 -5
- data/lib/easypost/services/billing.rb +4 -3
- data/lib/easypost/services/carrier_account.rb +9 -4
- data/lib/easypost/services/carrier_metadata.rb +2 -2
- data/lib/easypost/services/carrier_type.rb +3 -1
- data/lib/easypost/services/customs_info.rb +5 -2
- data/lib/easypost/services/customs_item.rb +6 -2
- data/lib/easypost/services/end_shipper.rb +10 -4
- data/lib/easypost/services/event.rb +18 -5
- data/lib/easypost/services/insurance.rb +15 -4
- data/lib/easypost/services/order.rb +12 -4
- data/lib/easypost/services/parcel.rb +6 -2
- data/lib/easypost/services/pickup.rb +21 -6
- data/lib/easypost/services/rate.rb +3 -1
- data/lib/easypost/services/referral_customer.rb +22 -6
- data/lib/easypost/services/refund.rb +15 -4
- data/lib/easypost/services/report.rb +18 -6
- data/lib/easypost/services/scan_form.rb +15 -4
- data/lib/easypost/services/shipment.rb +41 -26
- data/lib/easypost/services/tracker.rb +21 -9
- data/lib/easypost/services/user.rb +34 -6
- data/lib/easypost/services/webhook.rb +12 -4
- data/lib/easypost/utilities/constants.rb +1 -0
- data/lib/easypost/utilities/json.rb +7 -1
- data/lib/easypost/utilities/static_mapper.rb +0 -1
- metadata +2 -3
- data/lib/easypost/models/carbon_offset.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e4fdfe13e13bd17de295a018e87a4b05c015b9c7b0d523b15720647bd2c9301
|
4
|
+
data.tar.gz: 6fa130eae97f8b84172683a51f03c29c31dc983dc0b47efa2462b906e8d7ce07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ebe1b2763c764ca26f5515deb1616f9caf6df8b23c446ed4ee3fd0752fd704f51d3ded775f1f3bcfb751c4de2c8b8b631eb013f168a6feaf503e47d84c14be3
|
7
|
+
data.tar.gz: de858e402e5121112ff2466f44dad3f9a94bd529bcc6916c5d92406fdbeaf8c46e077ac7582b1cdcb50b4e3b345a3dc4ff08cdc879e12a16791406db31b7f091
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v6.1.0 (2024-01-08)
|
4
|
+
|
5
|
+
- Add `all_children` and `get_next_page_of_children` in `user` service
|
6
|
+
|
7
|
+
## v6.0.0 (2023-12-06)
|
8
|
+
|
9
|
+
- Removes `with_carbon_offset` parameter from `create`, `buy` and `regenerate_rates` methods in the shipment service since now EasyPost offers carbon neutral shipments by default for free
|
10
|
+
- Fixes a bug where the original filtering criteria of `all` calls wasn't passed along to `get_next_page` calls. Now, these are persisted via `_params` key on response objects
|
11
|
+
- Removes the undocumented `create_and_buy` function from the Batch service. The proper usage is to create a batch first and buy it separately
|
12
|
+
|
3
13
|
## v5.3.0 (2023-10-11)
|
4
14
|
|
5
15
|
- Migrate API Key-related functions out of `user` service into `api_key` service, deprecating the old and introducing the new
|
data/UPGRADE_GUIDE.md
CHANGED
@@ -2,11 +2,42 @@
|
|
2
2
|
|
3
3
|
Use the following guide to assist in the upgrade process of the `easypost-ruby` library between major versions.
|
4
4
|
|
5
|
+
- [Upgrading from 5.x to 6.0](#upgrading-from-5x-to-60)
|
5
6
|
- [Upgrading from 4.x to 5.0](#upgrading-from-4x-to-50)
|
6
7
|
- [Upgrading from 3.x to 4.0](#upgrading-from-3x-to-40)
|
7
8
|
|
9
|
+
## Upgrading from 5.x to 6.0
|
10
|
+
|
11
|
+
### 6.0 High Impact Changes
|
12
|
+
|
13
|
+
- [Carbon Offset Removed](#60-carbon-offset-removed)
|
14
|
+
|
15
|
+
### 6.0 Low Impact Changes
|
16
|
+
|
17
|
+
- [Create and Buy Batch Function Removed](#60-create-and-buy-batch-function-removed)
|
18
|
+
|
19
|
+
## 6.0 Carbon Offset Removed
|
20
|
+
|
21
|
+
*Likelihood of Impact: **High***
|
22
|
+
|
23
|
+
EasyPost now offers Carbon Neutral shipments by default for free! Because of this, there is no longer a need to specify if you want to offset the carbon footprint of a shipment.
|
24
|
+
|
25
|
+
The `with_carbon_offset` parameter of the `create`, `buy`, and `regenerate_rates` shipment functions has been removed.
|
26
|
+
|
27
|
+
This is a high-impact change for those using `EndShippers`, as the signature for the `create` and `buy` shipment function has changed. You will need to inspect these callsites to ensure that the EndShipper parameter is being passed in the correct place.
|
28
|
+
|
29
|
+
## 6.0 Create and Buy Batch Function Removed
|
30
|
+
|
31
|
+
*Likelihood of Impact: **Low***
|
32
|
+
|
33
|
+
The `create_and_buy` batch endpoint has been deprecated, and the `create_and_buy` Batch service function has been removed.
|
34
|
+
|
35
|
+
The correct procedure is to first create a batch and then purchase it with two separate API calls.
|
36
|
+
|
8
37
|
## Upgrading from 4.x to 5.0
|
9
38
|
|
39
|
+
**NOTICE:** v5 is deprecated.
|
40
|
+
|
10
41
|
### 5.0 High Impact Changes
|
11
42
|
|
12
43
|
- [New Client object](#50-thread-safe-with-client-object)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.1.0
|
data/lib/easypost/client.rb
CHANGED
@@ -72,7 +72,6 @@ class EasyPost::Client
|
|
72
72
|
#
|
73
73
|
# @param method [Symbol] the HTTP Verb (get, method, put, post, etc.)
|
74
74
|
# @param endpoint [String] URI path of the resource
|
75
|
-
# @param cls [Class] the class to deserialize to
|
76
75
|
# @param body [Object] (nil) object to be dumped to JSON
|
77
76
|
# @param api_version [String] the version of API to hit
|
78
77
|
# @raise [EasyPost::Error] if the response has a non-2xx status code
|
@@ -80,7 +79,6 @@ class EasyPost::Client
|
|
80
79
|
def make_request(
|
81
80
|
method,
|
82
81
|
endpoint,
|
83
|
-
cls = EasyPost::Models::EasyPostObject,
|
84
82
|
body = nil,
|
85
83
|
api_version = EasyPost::InternalUtilities::Constants::API_VERSION
|
86
84
|
)
|
@@ -89,7 +87,7 @@ class EasyPost::Client
|
|
89
87
|
potential_error = EasyPost::Errors::ApiError.handle_api_error(response)
|
90
88
|
raise potential_error unless potential_error.nil?
|
91
89
|
|
92
|
-
EasyPost::InternalUtilities::Json.
|
90
|
+
EasyPost::InternalUtilities::Json.parse_json(response.body)
|
93
91
|
end
|
94
92
|
|
95
93
|
# Subscribe a request hook
|
data/lib/easypost/models/base.rb
CHANGED
@@ -32,7 +32,9 @@ class EasyPost::Models::Object
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def add_properties(values)
|
35
|
-
values.
|
35
|
+
values.each_key do |key|
|
36
|
+
next if key == EasyPost::InternalUtilities::Constants::FILTERS_KEY
|
37
|
+
|
36
38
|
define_singleton_method(key) { handle_value(@values[key]) } # getter
|
37
39
|
define_singleton_method("#{key}=") { |v| @values[key] = handle_value(v) } # setter
|
38
40
|
end
|
data/lib/easypost/models.rb
CHANGED
@@ -8,7 +8,6 @@ require_relative 'models/address'
|
|
8
8
|
require_relative 'models/api_key'
|
9
9
|
require_relative 'models/batch'
|
10
10
|
require_relative 'models/brand'
|
11
|
-
require_relative 'models/carbon_offset'
|
12
11
|
require_relative 'models/carrier_account'
|
13
12
|
require_relative 'models/carrier_type'
|
14
13
|
require_relative 'models/customs_info'
|
@@ -17,7 +17,9 @@ class EasyPost::Services::Address < EasyPost::Services::Service
|
|
17
17
|
wrapped_params[:verify_strict] = params[:verify_strict]
|
18
18
|
end
|
19
19
|
|
20
|
-
@client.make_request(:post, 'addresses',
|
20
|
+
response = @client.make_request(:post, 'addresses', params)
|
21
|
+
|
22
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
21
23
|
end
|
22
24
|
|
23
25
|
# Create and verify an Address in one call.
|
@@ -25,26 +27,39 @@ class EasyPost::Services::Address < EasyPost::Services::Service
|
|
25
27
|
wrapped_params = {}
|
26
28
|
wrapped_params[:address] = params
|
27
29
|
|
28
|
-
@client.make_request(:post, 'addresses/create_and_verify',
|
30
|
+
response = @client.make_request(:post, 'addresses/create_and_verify', wrapped_params)
|
31
|
+
|
32
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).address
|
29
33
|
end
|
30
34
|
|
31
35
|
# Verify an Address.
|
32
36
|
def verify(id)
|
33
|
-
@client.make_request(:get, "addresses/#{id}/verify"
|
37
|
+
response = @client.make_request(:get, "addresses/#{id}/verify")
|
38
|
+
|
39
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).address
|
34
40
|
end
|
35
41
|
|
36
42
|
# Retrieve an Address.
|
37
43
|
def retrieve(id)
|
38
|
-
@client.make_request(:get, "addresses/#{id}"
|
44
|
+
response = @client.make_request(:get, "addresses/#{id}")
|
45
|
+
|
46
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
39
47
|
end
|
40
48
|
|
41
49
|
# Retrieve all Addresses.
|
42
|
-
def all(
|
43
|
-
|
50
|
+
def all(params = {})
|
51
|
+
filters = { key: 'addresses' }
|
52
|
+
|
53
|
+
get_all_helper('addresses', MODEL_CLASS, params, filters)
|
44
54
|
end
|
45
55
|
|
46
56
|
# Get the next page of addresses.
|
47
57
|
def get_next_page(collection, page_size = nil)
|
48
|
-
|
58
|
+
raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection)
|
59
|
+
|
60
|
+
params = { before_id: collection.addresses.last.id }
|
61
|
+
params[:page_size] = page_size unless page_size.nil?
|
62
|
+
|
63
|
+
all(params)
|
49
64
|
end
|
50
65
|
end
|
@@ -3,7 +3,9 @@
|
|
3
3
|
class EasyPost::Services::ApiKey < EasyPost::Services::Service
|
4
4
|
# Retrieve a list of all ApiKey objects.
|
5
5
|
def all
|
6
|
-
@client.make_request(:get, 'api_keys'
|
6
|
+
response = @client.make_request(:get, 'api_keys')
|
7
|
+
|
8
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::ApiKey)
|
7
9
|
end
|
8
10
|
|
9
11
|
# Retrieve a list of ApiKey objects (works for the authenticated user or a child user).
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../internal_utilities'
|
4
|
+
|
3
5
|
# The base class for all services in the library.
|
4
6
|
class EasyPost::Services::Service
|
5
7
|
def initialize(client)
|
@@ -8,20 +10,18 @@ class EasyPost::Services::Service
|
|
8
10
|
|
9
11
|
protected
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
params[:page_size] = page_size
|
19
|
-
end
|
13
|
+
def get_all_helper(endpoint, cls, params, filters = nil, beta = false)
|
14
|
+
response = @client.make_request(
|
15
|
+
:get, endpoint, params,
|
16
|
+
beta ? 'beta' : EasyPost::InternalUtilities::Constants::API_VERSION,
|
17
|
+
)
|
18
|
+
|
19
|
+
response[EasyPost::InternalUtilities::Constants::FILTERS_KEY] = filters unless filters.nil?
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, cls)
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
def more_pages?(collection)
|
25
|
+
collection&.has_more
|
26
26
|
end
|
27
27
|
end
|
@@ -6,48 +6,56 @@ class EasyPost::Services::Batch < EasyPost::Services::Service
|
|
6
6
|
# Create a Batch.
|
7
7
|
def create(params = {})
|
8
8
|
wrapped_params = { batch: params }
|
9
|
+
response = @client.make_request(:post, 'batches', wrapped_params)
|
9
10
|
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# Create and buy a batch in one call.
|
14
|
-
def create_and_buy(params = {})
|
15
|
-
wrapped_params = { batch: params }
|
16
|
-
|
17
|
-
@client.make_request(:post, 'batches/create_and_buy', MODEL_CLASS, wrapped_params)
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
18
12
|
end
|
19
13
|
|
20
14
|
def all(params = {})
|
21
|
-
|
15
|
+
filters = { key: 'batches' }
|
16
|
+
|
17
|
+
get_all_helper('batches', MODEL_CLASS, params, filters)
|
22
18
|
end
|
23
19
|
|
24
20
|
# Retrieve a Batch
|
25
21
|
def retrieve(id)
|
26
|
-
@client.make_request(:get, "batches/#{id}"
|
22
|
+
response = @client.make_request(:get, "batches/#{id}")
|
23
|
+
|
24
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
27
25
|
end
|
28
26
|
|
29
27
|
# Buy a Batch.
|
30
28
|
def buy(id, params = {})
|
31
|
-
@client.make_request(:post, "batches/#{id}/buy",
|
29
|
+
response = @client.make_request(:post, "batches/#{id}/buy", params)
|
30
|
+
|
31
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
32
32
|
end
|
33
33
|
|
34
34
|
# Convert the label format of a Batch.
|
35
35
|
def label(id, params = {})
|
36
|
-
@client.make_request(:post, "batches/#{id}/label",
|
36
|
+
response = @client.make_request(:post, "batches/#{id}/label", params)
|
37
|
+
|
38
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
37
39
|
end
|
38
40
|
|
39
41
|
# Remove Shipments from a Batch.
|
40
42
|
def remove_shipments(id, params = {})
|
41
|
-
@client.make_request(:post, "batches/#{id}/remove_shipments",
|
43
|
+
response = @client.make_request(:post, "batches/#{id}/remove_shipments", params)
|
44
|
+
|
45
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
42
46
|
end
|
43
47
|
|
44
48
|
# Add Shipments to a Batch.
|
45
49
|
def add_shipments(id, params = {})
|
46
|
-
@client.make_request(:post, "batches/#{id}/add_shipments",
|
50
|
+
response = @client.make_request(:post, "batches/#{id}/add_shipments", params)
|
51
|
+
|
52
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
47
53
|
end
|
48
54
|
|
49
55
|
# Create a ScanForm for a Batch.
|
50
56
|
def create_scan_form(id, params = {})
|
51
|
-
@client.make_request(:post, "batches/#{id}/scan_form",
|
57
|
+
response = @client.make_request(:post, "batches/#{id}/scan_form", params)
|
58
|
+
|
59
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
52
60
|
end
|
53
61
|
end
|
@@ -6,7 +6,8 @@ class EasyPost::Services::BetaRate < EasyPost::Services::Service
|
|
6
6
|
wrapped_params = {
|
7
7
|
shipment: params,
|
8
8
|
}
|
9
|
+
response = @client.make_request(:post, 'rates', wrapped_params, 'beta')
|
9
10
|
|
10
|
-
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::Rate).rates
|
11
12
|
end
|
12
13
|
end
|
@@ -10,13 +10,14 @@ class EasyPost::Services::BetaReferralCustomer < EasyPost::Services::Service
|
|
10
10
|
priority: priority.downcase,
|
11
11
|
},
|
12
12
|
}
|
13
|
-
@client.make_request(
|
13
|
+
response = @client.make_request(
|
14
14
|
:post,
|
15
15
|
'referral_customers/payment_method',
|
16
|
-
EasyPost::Models::EasyPostObject,
|
17
16
|
wrapped_params,
|
18
17
|
'beta',
|
19
18
|
)
|
19
|
+
|
20
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Refund a ReferralCustomer Customer's wallet by a specified amount. Refund will be issued to the user's original payment method.
|
@@ -25,8 +26,9 @@ class EasyPost::Services::BetaReferralCustomer < EasyPost::Services::Service
|
|
25
26
|
params = {
|
26
27
|
refund_amount: amount,
|
27
28
|
}
|
28
|
-
@client.make_request(:post, 'referral_customers/refunds',
|
29
|
-
|
29
|
+
response = @client.make_request(:post, 'referral_customers/refunds', params, 'beta')
|
30
|
+
|
31
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response)
|
30
32
|
end
|
31
33
|
|
32
34
|
# Refund a ReferralCustomer Customer's wallet for a specified payment log entry. Refund will be issued to the user's original payment method.
|
@@ -35,6 +37,8 @@ class EasyPost::Services::BetaReferralCustomer < EasyPost::Services::Service
|
|
35
37
|
params = {
|
36
38
|
payment_log_id: payment_log_id,
|
37
39
|
}
|
38
|
-
@client.make_request(:post, 'referral_customers/refunds',
|
40
|
+
response = @client.make_request(:post, 'referral_customers/refunds', params, 'beta')
|
41
|
+
|
42
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response)
|
39
43
|
end
|
40
44
|
end
|
@@ -44,7 +44,7 @@ class EasyPost::Services::Billing < EasyPost::Services::Service
|
|
44
44
|
payment_id = payment_info[1]
|
45
45
|
|
46
46
|
wrapped_params = { amount: amount }
|
47
|
-
@client.make_request(:post, "#{endpoint}/#{payment_id}/charges",
|
47
|
+
@client.make_request(:post, "#{endpoint}/#{payment_id}/charges", wrapped_params)
|
48
48
|
|
49
49
|
# Return true if succeeds, an error will be thrown if it fails
|
50
50
|
true
|
@@ -65,11 +65,12 @@ class EasyPost::Services::Billing < EasyPost::Services::Service
|
|
65
65
|
# Retrieve all payment methods.
|
66
66
|
def retrieve_payment_methods
|
67
67
|
response = @client.make_request(:get, '/v2/payment_methods')
|
68
|
+
payment_methods = EasyPost::InternalUtilities::Json.convert_json_to_object(response)
|
68
69
|
|
69
|
-
if
|
70
|
+
if payment_methods['id'].nil?
|
70
71
|
raise EasyPost::Errors::InvalidObjectError.new(EasyPost::Constants::NO_PAYMENT_METHODS)
|
71
72
|
end
|
72
73
|
|
73
|
-
|
74
|
+
payment_methods
|
74
75
|
end
|
75
76
|
end
|
@@ -14,24 +14,29 @@ class EasyPost::Services::CarrierAccount < EasyPost::Services::Service
|
|
14
14
|
else
|
15
15
|
'carrier_accounts'
|
16
16
|
end
|
17
|
+
response = @client.make_request(:post, create_url, wrapped_params)
|
17
18
|
|
18
|
-
|
19
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
19
20
|
end
|
20
21
|
|
21
22
|
# Retrieve a carrier account
|
22
23
|
def retrieve(id)
|
23
|
-
@client.make_request(:get, "carrier_accounts/#{id}"
|
24
|
+
response = @client.make_request(:get, "carrier_accounts/#{id}")
|
25
|
+
|
26
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
24
27
|
end
|
25
28
|
|
26
29
|
# Retrieve all carrier accounts
|
27
30
|
def all(params = {})
|
28
|
-
|
31
|
+
get_all_helper('carrier_accounts', MODEL_CLASS, params)
|
29
32
|
end
|
30
33
|
|
31
34
|
# Update a carrier account
|
32
35
|
def update(id, params = {})
|
33
36
|
wrapped_params = { carrier_account: params }
|
34
|
-
@client.make_request(:put, "carrier_accounts/#{id}",
|
37
|
+
response = @client.make_request(:put, "carrier_accounts/#{id}", wrapped_params)
|
38
|
+
|
39
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
35
40
|
end
|
36
41
|
|
37
42
|
# Delete a carrier account
|
@@ -4,7 +4,6 @@ class EasyPost::Services::CarrierMetadata < EasyPost::Services::Service
|
|
4
4
|
# Retrieve metadata for carrier(s).
|
5
5
|
def retrieve(carriers = [], types = [])
|
6
6
|
path = '/metadata/carriers?'
|
7
|
-
|
8
7
|
params = {}
|
9
8
|
|
10
9
|
if carriers.length.positive?
|
@@ -16,7 +15,8 @@ class EasyPost::Services::CarrierMetadata < EasyPost::Services::Service
|
|
16
15
|
end
|
17
16
|
|
18
17
|
path += URI.encode_www_form(params)
|
18
|
+
response = @client.make_request(:get, path, params)
|
19
19
|
|
20
|
-
|
20
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response).carriers
|
21
21
|
end
|
22
22
|
end
|
@@ -5,6 +5,8 @@ class EasyPost::Services::CarrierType < EasyPost::Services::Service
|
|
5
5
|
|
6
6
|
# Retrieve all carrier types
|
7
7
|
def all
|
8
|
-
@client.make_request(:get, 'carrier_types'
|
8
|
+
response = @client.make_request(:get, 'carrier_types')
|
9
|
+
|
10
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
9
11
|
end
|
10
12
|
end
|
@@ -6,12 +6,15 @@ class EasyPost::Services::CustomsInfo < EasyPost::Services::Service
|
|
6
6
|
# Create a CustomsInfo object
|
7
7
|
def create(params)
|
8
8
|
wrapped_params = { customs_info: params }
|
9
|
+
response = @client.make_request(:post, 'customs_infos', wrapped_params)
|
9
10
|
|
10
|
-
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
11
12
|
end
|
12
13
|
|
13
14
|
# Retrieve a CustomsInfo object
|
14
15
|
def retrieve(id)
|
15
|
-
@client.make_request(:get, "customs_infos/#{id}"
|
16
|
+
response = @client.make_request(:get, "customs_infos/#{id}")
|
17
|
+
|
18
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
16
19
|
end
|
17
20
|
end
|
@@ -5,11 +5,15 @@ class EasyPost::Services::CustomsItem < EasyPost::Services::Service
|
|
5
5
|
|
6
6
|
# Create a CustomsItem object
|
7
7
|
def create(params)
|
8
|
-
@client.make_request(:post, 'customs_items',
|
8
|
+
response = @client.make_request(:post, 'customs_items', params)
|
9
|
+
|
10
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
9
11
|
end
|
10
12
|
|
11
13
|
# Retrieve a CustomsItem object
|
12
14
|
def retrieve(id)
|
13
|
-
@client.make_request(:get, "customs_items/#{id}"
|
15
|
+
response = @client.make_request(:get, "customs_items/#{id}")
|
16
|
+
|
17
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
14
18
|
end
|
15
19
|
end
|
@@ -6,25 +6,31 @@ class EasyPost::Services::EndShipper < EasyPost::Services::Service
|
|
6
6
|
# Create an EndShipper object.
|
7
7
|
def create(params = {})
|
8
8
|
wrapped_params = { address: params }
|
9
|
+
response = @client.make_request(:post, 'end_shippers', wrapped_params)
|
9
10
|
|
10
|
-
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
11
12
|
end
|
12
13
|
|
13
14
|
# Retrieve an EndShipper object.
|
14
15
|
def retrieve(id)
|
15
|
-
@client.make_request(:get, "end_shippers/#{id}"
|
16
|
+
response = @client.make_request(:get, "end_shippers/#{id}")
|
17
|
+
|
18
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
16
19
|
end
|
17
20
|
|
18
21
|
# Retrieve all EndShipper objects.
|
19
22
|
def all(params = {})
|
20
|
-
@client.make_request(:get, 'end_shippers',
|
23
|
+
response = @client.make_request(:get, 'end_shippers', params)
|
24
|
+
|
25
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
21
26
|
end
|
22
27
|
|
23
28
|
# Updates an EndShipper object. This requires all parameters to be set.
|
24
29
|
def update(id, params)
|
25
30
|
wrapped_params = { address: params }
|
31
|
+
response = @client.make_request(:put, "end_shippers/#{id}", wrapped_params)
|
26
32
|
|
27
|
-
|
33
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
28
34
|
end
|
29
35
|
|
30
36
|
# TODO: Add support for getting the next page of end shippers when the API supports it.
|
@@ -7,26 +7,39 @@ class EasyPost::Services::Event < EasyPost::Services::Service
|
|
7
7
|
|
8
8
|
# Retrieve an Event object
|
9
9
|
def retrieve(id)
|
10
|
-
@client.make_request(:get, "events/#{id}"
|
10
|
+
response = @client.make_request(:get, "events/#{id}")
|
11
|
+
|
12
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
11
13
|
end
|
12
14
|
|
13
15
|
# Retrieve all Event objects
|
14
16
|
def all(params = {})
|
15
|
-
|
17
|
+
filters = { key: 'events' }
|
18
|
+
|
19
|
+
get_all_helper('events', MODEL_CLASS, params, filters)
|
16
20
|
end
|
17
21
|
|
18
22
|
# Retrieve all payloads for an event.
|
19
23
|
def retrieve_all_payloads(event_id)
|
20
|
-
@client.make_request(:get, "events/#{event_id}/payloads"
|
24
|
+
response = @client.make_request(:get, "events/#{event_id}/payloads")
|
25
|
+
|
26
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::Payload)
|
21
27
|
end
|
22
28
|
|
23
29
|
# Retrieve a specific payload for an event.
|
24
30
|
def retrieve_payload(event_id, payload_id)
|
25
|
-
@client.make_request(:get, "events/#{event_id}/payloads/#{payload_id}"
|
31
|
+
response = @client.make_request(:get, "events/#{event_id}/payloads/#{payload_id}")
|
32
|
+
|
33
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, EasyPost::Models::Payload)
|
26
34
|
end
|
27
35
|
|
28
36
|
# Get the next page of events.
|
29
37
|
def get_next_page(collection, page_size = nil)
|
30
|
-
|
38
|
+
raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection)
|
39
|
+
|
40
|
+
params = { before_id: collection.events.last.id }
|
41
|
+
params[:page_size] = page_size unless page_size.nil?
|
42
|
+
|
43
|
+
all(params)
|
31
44
|
end
|
32
45
|
end
|
@@ -6,21 +6,32 @@ class EasyPost::Services::Insurance < EasyPost::Services::Service
|
|
6
6
|
# Create an Insurance object
|
7
7
|
def create(params = {})
|
8
8
|
wrapped_params = { insurance: params }
|
9
|
-
@client.make_request(:post, 'insurances',
|
9
|
+
response = @client.make_request(:post, 'insurances', wrapped_params)
|
10
|
+
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
10
12
|
end
|
11
13
|
|
12
14
|
# Retrieve an Insurance object
|
13
15
|
def retrieve(id)
|
14
|
-
@client.make_request(:get, "insurances/#{id}"
|
16
|
+
response = @client.make_request(:get, "insurances/#{id}")
|
17
|
+
|
18
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
15
19
|
end
|
16
20
|
|
17
21
|
# Retrieve all Insurance objects
|
18
22
|
def all(params = {})
|
19
|
-
|
23
|
+
filters = { key: 'insurances' }
|
24
|
+
|
25
|
+
get_all_helper('insurances', MODEL_CLASS, params, filters)
|
20
26
|
end
|
21
27
|
|
22
28
|
# Get the next page of insurances.
|
23
29
|
def get_next_page(collection, page_size = nil)
|
24
|
-
|
30
|
+
raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection)
|
31
|
+
|
32
|
+
params = { before_id: collection.insurances.last.id }
|
33
|
+
params[:page_size] = page_size unless page_size.nil?
|
34
|
+
|
35
|
+
all(params)
|
25
36
|
end
|
26
37
|
end
|
@@ -6,17 +6,23 @@ class EasyPost::Services::Order < EasyPost::Services::Service
|
|
6
6
|
# Create an Order object
|
7
7
|
def create(params = {})
|
8
8
|
wrapped_params = { order: params }
|
9
|
-
@client.make_request(:post, 'orders',
|
9
|
+
response = @client.make_request(:post, 'orders', wrapped_params)
|
10
|
+
|
11
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
10
12
|
end
|
11
13
|
|
12
14
|
# Retrieve an Order object
|
13
15
|
def retrieve(id)
|
14
|
-
@client.make_request(:get, "orders/#{id}"
|
16
|
+
response = @client.make_request(:get, "orders/#{id}")
|
17
|
+
|
18
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
15
19
|
end
|
16
20
|
|
17
21
|
# Retrieve new rates for an Order object
|
18
22
|
def get_rates(id, params = {})
|
19
|
-
@client.make_request(:get, "orders/#{id}/rates",
|
23
|
+
response = @client.make_request(:get, "orders/#{id}/rates", params)
|
24
|
+
|
25
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
20
26
|
end
|
21
27
|
|
22
28
|
# Buy an Order object
|
@@ -25,6 +31,8 @@ class EasyPost::Services::Order < EasyPost::Services::Service
|
|
25
31
|
params = { carrier: params[:carrier], service: params[:service] }
|
26
32
|
end
|
27
33
|
|
28
|
-
@client.make_request(:post, "orders/#{id}/buy",
|
34
|
+
response = @client.make_request(:post, "orders/#{id}/buy", params)
|
35
|
+
|
36
|
+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
|
29
37
|
end
|
30
38
|
end
|