easypost 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +19 -5
- data/VERSION +1 -1
- data/lib/easypost/beta/end_shipper.rb +36 -0
- data/lib/easypost/beta/referral.rb +2 -1
- data/lib/easypost/beta.rb +1 -0
- data/lib/easypost/connection.rb +6 -1
- data/lib/easypost/user.rb +6 -0
- data/lib/easypost/util.rb +4 -1
- data/lib/easypost/webhook.rb +1 -1
- data/lib/easypost.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02404008f0fc1078e49e1e418c5a208fbca5d646f31886c3c7fab55d932def70'
|
4
|
+
data.tar.gz: b8a2f7d514f9f22fa5b7ec3daf010adbfcc793c689954102b6ccbaafd7742e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c9af835a6ff8ccb7574fd5a14ef96f850784e6600249a8441d23a521763ad3fb40d826cdce0f758cd4b87213a65c6ee733476d34824dabbb7fb09db2af0de0
|
7
|
+
data.tar.gz: c492ad0635133598e8535a2a0c72949b0acd6f0095b511bb91011c50cec67e6d8999b5358da8aa7ae4543e38a30bc029367d8c0cfd791e4944f46fac3cdf75d9
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v4.3.0 (2022-05-19)
|
4
|
+
|
5
|
+
- Adds the `EndShipper` Beta class with `create`, `retrieve`, `all`, and `save` functions
|
6
|
+
- Requests will now fail fast with an error if an API key is not provided instead of making a live API call with no key
|
7
|
+
- Fixes a bug where the library could not properly parse the response of deleting a child user
|
8
|
+
- Fixes a bug where you could not update a webhook due to a `wrong number of arguments` error
|
9
|
+
|
3
10
|
## v4.2.1 (2022-05-11)
|
4
11
|
|
5
12
|
- Corrects the `Beta` namespace for the new Referral class
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://github.com/EasyPost/easypost-ruby/workflows/CI/badge.svg)](https://github.com/EasyPost/easypost-ruby/actions?query=workflow%3ACI)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/easypost.svg)](https://badge.fury.io/rb/easypost)
|
5
5
|
|
6
|
-
EasyPost, the simple shipping solution. You can sign up for an account at https://easypost.com
|
6
|
+
EasyPost, the simple shipping solution. You can sign up for an account at <https://easypost.com>.
|
7
7
|
|
8
8
|
## Install
|
9
9
|
|
@@ -110,7 +110,7 @@ end
|
|
110
110
|
|
111
111
|
## Documentation
|
112
112
|
|
113
|
-
API Documentation can be found at: https://easypost.com/docs/api
|
113
|
+
API Documentation can be found at: <https://easypost.com/docs/api>.
|
114
114
|
|
115
115
|
## Development
|
116
116
|
|
@@ -126,8 +126,22 @@ EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... bundle exec rspec
|
|
126
126
|
|
127
127
|
The test suite in this project was specifically built to produce consistent results on every run, regardless of when they run or who is running them. This project uses [VCR](https://github.com/vcr/vcr) to record and replay HTTP requests and responses via "cassettes". When the suite is run, the HTTP requests and responses for each test function will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which saves the need to make live API calls on every test run.
|
128
128
|
|
129
|
-
|
129
|
+
**Sensitive Data:** We've made every attempt to include scrubbers for sensitive data when recording cassettes so that PII or sensitive info does not persist in version control; however, please ensure when recording or re-recording cassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the cassette.
|
130
130
|
|
131
|
-
|
131
|
+
**Making Changes:** If you make an addition to this project, the request/response will get recorded automatically for you. When making changes to this project, you'll need to re-record the associated cassette to force a new live API call for that test which will then record the request/response used on the next run.
|
132
132
|
|
133
|
-
**
|
133
|
+
**Test Data:** The test suite has been populated with various helpful fixtures that are available for use, each completely independent from a particular user **with the exception of the USPS carrier account ID** (see [Unit Test API Keys](#unit-test-api-keys) for more information) which has a fallback value of our internal testing user's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).
|
134
|
+
|
135
|
+
#### Unit Test API Keys
|
136
|
+
|
137
|
+
The following are required on every test run:
|
138
|
+
|
139
|
+
- `EASYPOST_TEST_API_KEY`
|
140
|
+
- `EASYPOST_PROD_API_KEY`
|
141
|
+
|
142
|
+
The following are required when you need to re-record cassettes for applicable tests (fallback values are used otherwise):
|
143
|
+
|
144
|
+
- `USPS_CARRIER_ACCOUNT_ID` (eg: one-call buying a shipment for non-EasyPost employees)
|
145
|
+
- `REFERRAL_USER_PROD_API_KEY` (eg: adding a credit card to a referral user)
|
146
|
+
|
147
|
+
Some tests may require a user with a particular set of enabled features such as a `Partner` user when creating referrals. We have attempted to call out these functions in their respective docstrings.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.3.0
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
|
4
|
+
class EasyPost::Beta::EndShipper < EasyPost::Resource
|
5
|
+
# Create an EndShipper object.
|
6
|
+
def self.create(params = {}, api_key = nil)
|
7
|
+
response = EasyPost.make_request(:post, '/beta/end_shippers', api_key, { address: params })
|
8
|
+
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieves an EndShipper object.
|
12
|
+
def self.retrieve(id, params = {}, api_key = nil)
|
13
|
+
response = EasyPost.make_request(:get, "/beta/end_shippers/#{id}", api_key, params)
|
14
|
+
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieves a list of EndShipper objects.
|
18
|
+
def self.all(params = {}, api_key = nil)
|
19
|
+
response = EasyPost.make_request(:get, '/beta/end_shippers', api_key, params)
|
20
|
+
EasyPost::Util.convert_to_easypost_object(response, api_key)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Updates (saves) an EndShipper object. This requires all parameters to be set.
|
24
|
+
def save
|
25
|
+
if @unsaved_values.length.positive?
|
26
|
+
values = {}
|
27
|
+
@unsaved_values.each { |k| values[k] = @values[k] }
|
28
|
+
|
29
|
+
wrapped_params = { address: values }
|
30
|
+
|
31
|
+
response = EasyPost.make_request(:put, "/beta/end_shippers/#{id}", @api_key, wrapped_params)
|
32
|
+
refresh_from(response, api_key)
|
33
|
+
end
|
34
|
+
self
|
35
|
+
end
|
36
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Referral objects are User objects created from a Partner user.
|
3
4
|
class EasyPost::Beta::Referral < EasyPost::Resource
|
4
5
|
# Create a referral user. This function requires the Partner User's API key.
|
5
6
|
def self.create(params = {}, api_key = nil)
|
@@ -14,7 +15,7 @@ class EasyPost::Beta::Referral < EasyPost::Resource
|
|
14
15
|
email: email,
|
15
16
|
},
|
16
17
|
}
|
17
|
-
|
18
|
+
EasyPost.make_request(:put, "/beta/referral_customers/#{user_id}", api_key, wrapped_params)
|
18
19
|
|
19
20
|
# return true if API succeeds, else an error is throw if it fails.
|
20
21
|
true
|
data/lib/easypost/beta.rb
CHANGED
data/lib/easypost/connection.rb
CHANGED
@@ -10,6 +10,10 @@ EasyPost::Connection = Struct.new(:uri, :config, keyword_init: true) do
|
|
10
10
|
# @raise [EasyPost::Error] if the response has a non-2xx status code
|
11
11
|
# @return [Hash] JSON object parsed from the response body
|
12
12
|
def call(method, path, api_key = nil, body = nil)
|
13
|
+
if api_key.nil?
|
14
|
+
raise EasyPost::Error, 'No API key provided.'
|
15
|
+
end
|
16
|
+
|
13
17
|
connection =
|
14
18
|
if config[:proxy]
|
15
19
|
proxy_uri = URI(config[:proxy])
|
@@ -51,11 +55,12 @@ EasyPost::Connection = Struct.new(:uri, :config, keyword_init: true) do
|
|
51
55
|
request['Authorization'] = EasyPost.authorization(api_key) if api_key
|
52
56
|
|
53
57
|
response = connection.request(request)
|
58
|
+
response_is_json = response['Content-Type'] ? response['Content-Type'].start_with?('application/json') : false
|
54
59
|
|
55
60
|
EasyPost.parse_response(
|
56
61
|
status: response.code.to_i,
|
57
62
|
body: response.body,
|
58
|
-
json:
|
63
|
+
json: response_is_json,
|
59
64
|
)
|
60
65
|
end
|
61
66
|
end
|
data/lib/easypost/user.rb
CHANGED
data/lib/easypost/util.rb
CHANGED
@@ -62,6 +62,7 @@ module EasyPost::Util
|
|
62
62
|
'CarrierAccount' => EasyPost::CarrierAccount,
|
63
63
|
'CustomsInfo' => EasyPost::CustomsInfo,
|
64
64
|
'CustomsItem' => EasyPost::CustomsItem,
|
65
|
+
'EndShipper' => EasyPost::Beta::EndShipper,
|
65
66
|
'Event' => EasyPost::Event,
|
66
67
|
'Insurance' => EasyPost::Insurance,
|
67
68
|
'Order' => EasyPost::Order,
|
@@ -71,14 +72,15 @@ module EasyPost::Util
|
|
71
72
|
'PickupRate' => EasyPost::PickupRate,
|
72
73
|
'PostageLabel' => EasyPost::PostageLabel,
|
73
74
|
'Rate' => EasyPost::Rate,
|
75
|
+
'Referral' => EasyPost::Beta::Referral,
|
74
76
|
'Refund' => EasyPost::Refund,
|
75
77
|
'RefundReport' => EasyPost::Report,
|
76
78
|
'Report' => EasyPost::Report,
|
77
79
|
'ScanForm' => EasyPost::ScanForm,
|
78
80
|
'Shipment' => EasyPost::Shipment,
|
79
|
-
'TaxIdentifier' => EasyPost::TaxIdentifier,
|
80
81
|
'ShipmentInvoiceReport' => EasyPost::Report,
|
81
82
|
'ShipmentReport' => EasyPost::Report,
|
83
|
+
'TaxIdentifier' => EasyPost::TaxIdentifier,
|
82
84
|
'Tracker' => EasyPost::Tracker,
|
83
85
|
'TrackerReport' => EasyPost::Report,
|
84
86
|
'User' => EasyPost::User,
|
@@ -92,6 +94,7 @@ module EasyPost::Util
|
|
92
94
|
'ca' => EasyPost::CarrierAccount,
|
93
95
|
'cstinfo' => EasyPost::CustomsInfo,
|
94
96
|
'cstitem' => EasyPost::CustomsItem,
|
97
|
+
'es' => EasyPost::Beta::EndShipper,
|
95
98
|
'evt' => EasyPost::Event,
|
96
99
|
'hook' => EasyPost::Webhook,
|
97
100
|
'ins' => EasyPost::Insurance,
|
data/lib/easypost/webhook.rb
CHANGED
@@ -13,7 +13,7 @@ class EasyPost::Webhook < EasyPost::Resource
|
|
13
13
|
instance_url = "#{self.class.url}/#{CGI.escape(id)}"
|
14
14
|
|
15
15
|
response = EasyPost.make_request(:put, instance_url, @api_key, params)
|
16
|
-
refresh_from(response, api_key
|
16
|
+
refresh_from(response, api_key)
|
17
17
|
|
18
18
|
self
|
19
19
|
end
|
data/lib/easypost.rb
CHANGED
@@ -134,7 +134,7 @@ module EasyPost
|
|
134
134
|
)
|
135
135
|
end
|
136
136
|
|
137
|
-
json ? JSON.parse(body) : body
|
137
|
+
json || !body.nil? && !body.match(/\A\s+\z/) ? JSON.parse(body) : body
|
138
138
|
rescue JSON::ParserError
|
139
139
|
raise "Invalid response object from API, unable to decode.\n#{body}"
|
140
140
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easypost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EasyPost Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/easypost/api_key.rb
|
169
169
|
- lib/easypost/batch.rb
|
170
170
|
- lib/easypost/beta.rb
|
171
|
+
- lib/easypost/beta/end_shipper.rb
|
171
172
|
- lib/easypost/beta/referral.rb
|
172
173
|
- lib/easypost/brand.rb
|
173
174
|
- lib/easypost/carrier_account.rb
|