easypost 4.12.0 → 4.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a3e6fa9af948ab36d6bb75ebf7d744f5580f4225b1181fb1d31bc7f834501bb
4
- data.tar.gz: 5befe3b07667cb4494249eb6524c5ec8584e3f746475ec9162ae8cc6831ffaab
3
+ metadata.gz: 656588820c3668029b926bac6eaa73fb57aad0d074be9b4ea0eb59d22444c3ae
4
+ data.tar.gz: 40050887f75ea9287cd6c5a5d71a22d6ec70508f0170bf9685f0c8c1d515caed
5
5
  SHA512:
6
- metadata.gz: 41e81f89a10321e694087652862c373b41c88a704a02584c5978ba1a72c1554f79d45277bea81c679a4211072e6b9d56b2829c8c2d6b832c74177018dc469b5e
7
- data.tar.gz: 2f4180afe87daf91d6128e555b1ffb3d3befb1a07f8879dea7918887b0f394723901767c394de5e0f3530d03e24f7c355fdf97c68648b2a5c2f6ef47a09daf69
6
+ metadata.gz: 4d7f27ead8d8687e6e592bbd5669c0a6d22adf8f2aa721c49dc8522030af86297403ccbddd2f030b87ba867c0c880441fb274c6ef1e7afb6d7c086c77875e3c1
7
+ data.tar.gz: 7a7c9fd6c0160ac5a8453cb3cf82bae9b7f82d2288e960d1e991bf7a022fd05084196799d049dc4bac65d0308d96af025f49f7345a70f44b5f2c6320e47e5d48
@@ -1,4 +1,4 @@
1
- name: "CI"
1
+ name: 'CI'
2
2
 
3
3
  on:
4
4
  push:
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- rubyversion: ["2.5", "2.6", "2.7", "3.0", "3.1"]
14
+ rubyversion: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
15
15
  steps:
16
16
  - name: Checkout Repository
17
17
  uses: actions/checkout@v3
@@ -19,7 +19,7 @@ jobs:
19
19
  uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.rubyversion }}
22
- rubygems: "3.0.0"
22
+ rubygems: '3.0.0'
23
23
  bundler-cache: true
24
24
  - name: Install Dependencies
25
25
  run: make install
@@ -30,7 +30,7 @@ jobs:
30
30
  uses: coverallsapp/github-action@master
31
31
  with:
32
32
  github-token: ${{ secrets.GITHUB_TOKEN }}
33
- path-to-lcov: "./coverage/lcov/easypost-ruby.lcov"
33
+ path-to-lcov: './coverage/lcov/easypost-ruby.lcov'
34
34
  lint:
35
35
  runs-on: ubuntu-latest
36
36
  steps:
@@ -39,8 +39,8 @@ jobs:
39
39
  - name: Set up Ruby
40
40
  uses: ruby/setup-ruby@v1
41
41
  with:
42
- ruby-version: "3.1"
43
- rubygems: "3.0.0"
42
+ ruby-version: '3.2'
43
+ rubygems: '3.0.0'
44
44
  bundler-cache: true
45
45
  - name: Install Dependencies
46
46
  run: make install
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.13.0 (2023-04-04)
4
+
5
+ - Adds `get_next_page` function to each object which retrieves the next page of a collection when the `has_more` key is present in the response
6
+
3
7
  ## v4.12.0 (2023-02-21)
4
8
 
5
9
  - Adds beta `retrieve_stateless_rates` function
data/README.md CHANGED
@@ -117,6 +117,12 @@ Library documentation can be found on the web at: <https://easypost.github.io/ea
117
117
 
118
118
  Upgrading major versions of this project? Refer to the [Upgrade Guide](UPGRADE_GUIDE.md).
119
119
 
120
+ ## Support
121
+
122
+ New features and bug fixes are released on the latest major release of this library. If you are on an older major release of this library, we recommend upgrading to the most recent release to take advantage of new features, bug fixes, and security patches. Older versions of this library will continue to work and be available as long as the API version they are tied to remains active; however, they will not receive updates and are considered EOL.
123
+
124
+ For additional support, see our [org-wide support policy](https://github.com/EasyPost/.github/blob/main/SUPPORT.md).
125
+
120
126
  ## Development
121
127
 
122
128
  ```bash
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.12.0
1
+ 4.13.0
@@ -37,4 +37,19 @@ class EasyPost::Address < EasyPost::Resource
37
37
 
38
38
  EasyPost::Util.convert_to_easypost_object(response['address'], api_key)
39
39
  end
40
+
41
+ # Get the next page of addresses.
42
+ def self.get_next_page(collection, page_size = nil)
43
+ get_next_page_exec(method(:all), collection, collection.addresses, page_size)
44
+ end
45
+
46
+ # Build the next page parameters.
47
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
48
+ params = {}
49
+ params[:before_id] = current_page_items.last.id
50
+ unless page_size.nil?
51
+ params[:page_size] = page_size
52
+ end
53
+ params
54
+ end
40
55
  end
@@ -47,4 +47,6 @@ class EasyPost::Batch < EasyPost::Resource
47
47
  def create_scan_form(params = {})
48
48
  EasyPost.make_request(:post, "#{url}/scan_form", @api_key, params)
49
49
  end
50
+
51
+ # TODO: Add support getting the next page of batches when the API supports it.
50
52
  end
@@ -21,4 +21,6 @@ class EasyPost::EndShipper < EasyPost::Resource
21
21
  end
22
22
  self
23
23
  end
24
+
25
+ # TODO: Add support for getting the next page of end shippers when the API supports it.
24
26
  end
@@ -20,4 +20,19 @@ class EasyPost::Event < EasyPost::Resource
20
20
  response = EasyPost.make_request(:get, "#{url}/payloads/#{payload_id}", api_key)
21
21
  EasyPost::Util.convert_to_easypost_object(response, api_key)
22
22
  end
23
+
24
+ # Get the next page of events.
25
+ def self.get_next_page(collection, page_size = nil)
26
+ get_next_page_exec(method(:all), collection, collection.events, page_size)
27
+ end
28
+
29
+ # Build the next page parameters.
30
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
31
+ params = {}
32
+ params[:before_id] = current_page_items.last.id
33
+ unless page_size.nil?
34
+ params[:page_size] = page_size
35
+ end
36
+ params
37
+ end
23
38
  end
@@ -3,4 +3,18 @@
3
3
  # An Insurance object represents insurance for packages purchased both via the EasyPost API as well
4
4
  # as shipments purchased through third parties and later registered with EasyPost.
5
5
  class EasyPost::Insurance < EasyPost::Resource
6
+ # Get the next page of insurances.
7
+ def self.get_next_page(collection, page_size = nil)
8
+ get_next_page_exec(method(:all), collection, collection.insurances, page_size)
9
+ end
10
+
11
+ # Build the next page parameters.
12
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
13
+ params = {}
14
+ params[:before_id] = current_page_items.last.id
15
+ unless page_size.nil?
16
+ params[:page_size] = page_size
17
+ end
18
+ params
19
+ end
6
20
  end
@@ -29,4 +29,19 @@ class EasyPost::Pickup < EasyPost::Resource
29
29
  def lowest_rate(carriers = [], services = [])
30
30
  EasyPost::Util.get_lowest_object_rate(self, carriers, services, 'pickup_rates')
31
31
  end
32
+
33
+ # Get the next page of pickups.
34
+ def self.get_next_page(collection, page_size = nil)
35
+ get_next_page_exec(method(:all), collection, collection.pickups, page_size)
36
+ end
37
+
38
+ # Build the next page parameters.
39
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
40
+ params = {}
41
+ params[:before_id] = current_page_items.last.id
42
+ unless page_size.nil?
43
+ params[:page_size] = page_size
44
+ end
45
+ params
46
+ end
32
47
  end
@@ -80,6 +80,21 @@ class EasyPost::Referral < EasyPost::Resource
80
80
  EasyPost::Util.convert_to_easypost_object(response, api_key)
81
81
  end
82
82
 
83
+ # Get the next page of referral customers.
84
+ def self.get_next_page(collection, page_size = nil)
85
+ get_next_page_exec(method(:all), collection, collection.referral_customers, page_size)
86
+ end
87
+
88
+ # Build the next page parameters.
89
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
90
+ params = {}
91
+ params[:before_id] = current_page_items.last.id
92
+ unless page_size.nil?
93
+ params[:page_size] = page_size
94
+ end
95
+ params
96
+ end
97
+
83
98
  # Add credit card to a referral customer. This function requires the Referral Customer's API key.
84
99
  def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary')
85
100
  easypost_stripe_api_key = retrieve_easypost_stripe_api_key
@@ -2,4 +2,18 @@
2
2
 
3
3
  # The Refund object contains details about the Refund of a Shipment.
4
4
  class EasyPost::Refund < EasyPost::Resource
5
+ # Get the next page of refunds.
6
+ def self.get_next_page(collection, page_size = nil)
7
+ get_next_page_exec(method(:all), collection, collection.refunds, page_size)
8
+ end
9
+
10
+ # Build the next page parameters.
11
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
12
+ params = {}
13
+ params[:before_id] = current_page_items.last.id
14
+ unless page_size.nil?
15
+ params[:page_size] = page_size
16
+ end
17
+ params
18
+ end
5
19
  end
@@ -18,6 +18,27 @@ class EasyPost::Report < EasyPost::Resource
18
18
  url = "#{self.url}/#{filters[:type]}"
19
19
 
20
20
  response = EasyPost.make_request(:get, url, api_key, filters)
21
- EasyPost::Util.convert_to_easypost_object(response, api_key)
21
+ collection = EasyPost::Util.convert_to_easypost_object(response, api_key)
22
+
23
+ # Store the filters used to retrieve the collection.
24
+ collection.refresh_from({ type: filters[:type] }, api_key)
25
+
26
+ collection
27
+ end
28
+
29
+ # Get the next page of addresses.
30
+ def self.get_next_page(collection, page_size = nil)
31
+ get_next_page_exec(method(:all), collection, collection.reports, page_size)
32
+ end
33
+
34
+ # Build the next page parameters.
35
+ def self.build_next_page_params(collection, current_page_items, page_size = nil)
36
+ params = {}
37
+ params[:before_id] = current_page_items.last.id
38
+ unless page_size.nil?
39
+ params[:page_size] = page_size
40
+ end
41
+ params[:type] = collection.type
42
+ params
22
43
  end
23
44
  end
@@ -103,4 +103,22 @@ class EasyPost::Resource < EasyPost::EasyPostObject
103
103
  end
104
104
  self
105
105
  end
106
+
107
+ # Build the next page parameters and call the next page function.
108
+ def self.get_next_page_exec(api_func, collection, current_page_items, page_size = nil)
109
+ has_more = collection.has_more || false
110
+ unless !has_more || current_page_items.nil? || current_page_items.empty?
111
+ # if no issues, then we can get the next page
112
+ params = build_next_page_params(collection, current_page_items, page_size)
113
+ return api_func.call(params)
114
+ end
115
+
116
+ # issue with getting the next page
117
+ raise EasyPost::Error.new('There are no more pages to retrieve.')
118
+ end
119
+
120
+ # Build the next page parameters. This is a stub method that should be overridden by the child class.
121
+ def self.build_next_page_params(_collection, _current_page_items, _page_size = nil)
122
+ {}
123
+ end
106
124
  end
@@ -8,4 +8,19 @@ class EasyPost::ScanForm < EasyPost::Resource
8
8
  response = EasyPost.make_request(:post, url, api_key, params)
9
9
  EasyPost::Util.convert_to_easypost_object(response, api_key)
10
10
  end
11
+
12
+ # Get the next page of scan forms.
13
+ def self.get_next_page(collection, page_size = nil)
14
+ get_next_page_exec(method(:all), collection, collection.scan_forms, page_size)
15
+ end
16
+
17
+ # Build the next page parameters.
18
+ def self.build_next_page_params(_collection, current_page_items, page_size = nil)
19
+ params = {}
20
+ params[:before_id] = current_page_items.last.id
21
+ unless page_size.nil?
22
+ params[:page_size] = page_size
23
+ end
24
+ params
25
+ end
11
26
  end
@@ -34,6 +34,37 @@ class EasyPost::Shipment < EasyPost::Resource
34
34
  response.fetch('result', [])
35
35
  end
36
36
 
37
+ # Retrieve a list of Shipment objects.
38
+ def self.all(filters = {}, api_key = nil)
39
+ collection = super(filters, api_key)
40
+
41
+ # Store the filters used to retrieve the collection.
42
+ collection.refresh_from({ include_children: filters[:include_children], purchased: filters[:purchased] }, api_key)
43
+
44
+ collection
45
+ end
46
+
47
+ # Get the next page of shipments.
48
+ def self.get_next_page(collection, page_size = nil)
49
+ get_next_page_exec(method(:all), collection, collection.shipments, page_size)
50
+ end
51
+
52
+ # Build the next page parameters.
53
+ def self.build_next_page_params(collection, current_page_items, page_size = nil)
54
+ params = {}
55
+ params[:before_id] = current_page_items.last.id
56
+ unless page_size.nil?
57
+ params[:page_size] = page_size
58
+ end
59
+ unless collection.include_children.nil?
60
+ params[:include_children] = collection.include_children
61
+ end
62
+ unless collection.purchased.nil?
63
+ params[:purchased] = collection.purchased
64
+ end
65
+ params
66
+ end
67
+
37
68
  # Buy a Shipment.
38
69
  def buy(params = {}, with_carbon_offset = false, end_shipper_id = nil)
39
70
  if params.instance_of?(EasyPost::Rate)
@@ -9,4 +9,35 @@ class EasyPost::Tracker < EasyPost::Resource
9
9
  EasyPost.make_request(:post, url, api_key, new_params)
10
10
  true # This endpoint does not return a response so we return true here instead
11
11
  end
12
+
13
+ # Retrieve a list of Tracker objects.
14
+ def self.all(filters = {}, api_key = nil)
15
+ collection = super(filters, api_key)
16
+
17
+ # Store the filters used to retrieve the collection.
18
+ collection.refresh_from({ tracking_code: filters[:tracking_code], carrier: filters[:carrier] }, api_key)
19
+
20
+ collection
21
+ end
22
+
23
+ # Get the next page of trackers.
24
+ def self.get_next_page(collection, page_size = nil)
25
+ get_next_page_exec(method(:all), collection, collection.trackers, page_size)
26
+ end
27
+
28
+ # Build the next page parameters.
29
+ def self.build_next_page_params(collection, current_page_items, page_size = nil)
30
+ params = {}
31
+ params[:before_id] = current_page_items.last.id
32
+ unless page_size.nil?
33
+ params[:page_size] = page_size
34
+ end
35
+ unless collection.tracking_code.nil?
36
+ params[:tracking_code] = collection.tracking_code
37
+ end
38
+ unless collection.carrier.nil?
39
+ params[:carrier] = collection.carrier
40
+ end
41
+ params
42
+ end
12
43
  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.12.0
4
+ version: 4.13.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: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brakeman