easypost 4.7.1 → 4.8.1

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: 33802b8af58e7efc3e5592c6559dd48dfa5a58cc9338f719c78bc97639f73c51
4
- data.tar.gz: 1ec9df3da15eb1169817db4d3610f78826388836995615ec928a80d60e17fcf1
3
+ metadata.gz: 9ad992fe480aa1a1c8b1fc7e85dd06c7af4478bca9bcc3a2f083daaeeedcc39e
4
+ data.tar.gz: f37a2a32dac1dcc1efa0121dce6b6edbf14e3aa690308d393815ecaabddedda4
5
5
  SHA512:
6
- metadata.gz: 8f66b559d5f34005ad16151f3b32b168254efaff625ab06eba13a97ebe1aade1ff40f3d281fed9f32f80016bf662337be2053dc9a74d0f748bff47c67c3f6dd8
7
- data.tar.gz: a22e6a0c850f686807aae90db0d81a24f963c045e043dbd497a5078b9b4f5806124782906d78b3e30b760a13cd78daf9c99b4252c58760205d5b7364472f3310
6
+ metadata.gz: 6f0e9c8cbfb299608c58c865a2193e163739ca3543fb5bbea44026930bbecf34ae8d772fc2377909492a89d8c7d3d1440c7a9f7ebf25935927db35bc6ba1b7c3
7
+ data.tar.gz: 8b02eee4c36c0c918e4a3f4884694c48d453bbf3aba7db653669618462d67bad30c0cf0ceec96ee44de0b335626e0992b493ad06e4457feeb5f661ebe55ceb70
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  branches: [master]
6
6
  pull_request: ~
7
+ workflow_dispatch: ~
7
8
 
8
9
  jobs:
9
10
  run-tests:
@@ -32,6 +33,7 @@ jobs:
32
33
  uses: ruby/setup-ruby@v1
33
34
  with:
34
35
  ruby-version: "3.1"
36
+ bundler-cache: true
35
37
  - name: Install Dependencies
36
38
  run: make install
37
39
  - name: Lint Project
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  inherit_from: easycop.yml
2
2
 
3
+ AllCops:
4
+ SuggestExtensions: false
3
5
  # We are ignoring RSpec/FilePath because Simplecov doesn't play nice with nested spec files
4
6
  RSpec/FilePath:
5
7
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.8.1 (2022-10-24)
4
+
5
+ - Concatenates `error.message` if it incorrectly comes back from the API as an array
6
+ - Treats any HTTP status outside the `2xx` range as an error. Impact expected is minimal as this change only affects `1xx` and `3xx` HTTP status codes
7
+
8
+ ## v4.8.0 (2022-09-21)
9
+
10
+ - Adds support to buy a shipment by passing in `end_shipper_id`
11
+ - `with_carbon_offset` can now alternatively be passed in the `params` parameter of the `shipment.buy` function
12
+ - Migrates Partner White Label (Referrals) to general library namespace and deprecates beta functions
13
+
3
14
  ## v4.7.1 (2022-09-06)
4
15
 
5
16
  - Makes not implemented `all` calls match the `EasyPost::Resource` interface so that one can call `.to_json` on them and receive the proper error
data/Makefile CHANGED
@@ -14,7 +14,7 @@ clean:
14
14
 
15
15
  ## fix - Fix Rubocop errors
16
16
  fix:
17
- rubocop -A
17
+ bundle exec rubocop -A
18
18
 
19
19
  ## install - Install globally from source
20
20
  install:
@@ -24,7 +24,7 @@ install:
24
24
 
25
25
  ## lint - Lint the project
26
26
  lint:
27
- rubocop
27
+ bundle exec rubocop
28
28
 
29
29
  ## publish - Publishes the built gem to Rubygems
30
30
  publish:
@@ -37,11 +37,11 @@ release:
37
37
 
38
38
  ## scan - Runs security analysis on the project with Brakeman
39
39
  scan:
40
- brakeman lib --force
40
+ bundle exec brakeman lib --force
41
41
 
42
- ## test - Test the project
42
+ ## test - Test the project (and ignore warnings for test output)
43
43
  test:
44
- bundle exec rspec
44
+ RUBYOPT="-W0" bundle exec rspec
45
45
 
46
46
  ## update - Updates dependencies
47
47
  update:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.7.1
1
+ 4.8.1
@@ -28,20 +28,12 @@ class EasyPost::Address < EasyPost::Resource
28
28
  wrapped_params[class_name.to_sym] = params
29
29
  response = EasyPost.make_request(:post, "#{url}/create_and_verify", api_key, wrapped_params)
30
30
 
31
- raise EasyPost::Error.new('Unable to verify address.') unless response.key?('address')
32
-
33
31
  EasyPost::Util.convert_to_easypost_object(response['address'], api_key)
34
32
  end
35
33
 
36
34
  # Verify an Address.
37
35
  def verify
38
- begin
39
- response = EasyPost.make_request(:get, "#{url}/verify", @api_key)
40
- rescue StandardError
41
- raise EasyPost::Error.new('Unable to verify address.')
42
- end
43
-
44
- raise EasyPost::Error.new('Unable to verify address.') unless response.key?('address')
36
+ response = EasyPost.make_request(:get, "#{url}/verify", @api_key)
45
37
 
46
38
  EasyPost::Util.convert_to_easypost_object(response['address'], api_key)
47
39
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # EndShipper objects are fully-qualified Address objects that require all parameters and get verified upon creation.
4
4
  class EasyPost::Beta::EndShipper < EasyPost::Resource
5
+ # Create an EndShipper object.
5
6
  # <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
6
7
  def self.create(params = {}, api_key = nil)
7
8
  warn '[DEPRECATION] Please use `EndShipper.create` in the main namespace instead.'
@@ -10,6 +11,7 @@ class EasyPost::Beta::EndShipper < EasyPost::Resource
10
11
  end
11
12
 
12
13
  # Retrieves an EndShipper object.
14
+ # <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
13
15
  def self.retrieve(id, params = {}, api_key = nil)
14
16
  warn '[DEPRECATION] Please use `EndShipper.retrieve` in the main namespace instead.'
15
17
  response = EasyPost.make_request(:get, "/beta/end_shippers/#{id}", api_key, params)
@@ -17,6 +19,7 @@ class EasyPost::Beta::EndShipper < EasyPost::Resource
17
19
  end
18
20
 
19
21
  # Retrieves a list of EndShipper objects.
22
+ # <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
20
23
  def self.all(params = {}, api_key = nil)
21
24
  warn '[DEPRECATION] Please use `EndShipper.all` in the main namespace instead.'
22
25
  response = EasyPost.make_request(:get, '/beta/end_shippers', api_key, params)
@@ -24,6 +27,7 @@ class EasyPost::Beta::EndShipper < EasyPost::Resource
24
27
  end
25
28
 
26
29
  # Updates (saves) an EndShipper object. This requires all parameters to be set.
30
+ # <b>DEPRECATED:</b> Please use <tt>EndShipper</tt> in the main namespace instead.
27
31
  def save
28
32
  warn '[DEPRECATION] Please use `endShipper.save` in the main namespace instead.'
29
33
  if @unsaved_values.length.positive?
@@ -2,14 +2,71 @@
2
2
 
3
3
  # Referral objects are User objects created from a Partner user.
4
4
  class EasyPost::Beta::Referral < EasyPost::Resource
5
+ class << self
6
+ protected
7
+
8
+ # Retrieve EasyPost's Stripe public API key.
9
+ def retrieve_easypost_stripe_api_key
10
+ response = EasyPost.make_request(:get, '/beta/partners/stripe_public_key', @api_key)
11
+ response['public_key']
12
+ end
13
+
14
+ # Get credit card token from Stripe.
15
+ def create_stripe_token(number, expiration_month, expiration_year,
16
+ cvc, easypost_stripe_token)
17
+ headers = {
18
+ # This Stripe endpoint only accepts URL form encoded bodies.
19
+ Authorization: "Bearer #{easypost_stripe_token}",
20
+ 'Content-type': 'application/x-www-form-urlencoded',
21
+ }
22
+
23
+ credit_card_hash = {
24
+ card: {
25
+ number: number,
26
+ exp_month: expiration_month,
27
+ exp_year: expiration_year,
28
+ cvc: cvc,
29
+ },
30
+ }
31
+
32
+ form_encoded_params = EasyPost::Util.form_encode_params(credit_card_hash)
33
+
34
+ uri = URI.parse('https://api.stripe.com/v1/tokens')
35
+ http = Net::HTTP.new(uri.host, uri.port)
36
+ http.use_ssl = true
37
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
38
+ query = URI.encode_www_form(form_encoded_params)
39
+
40
+ response = http.request(request, query)
41
+ response_json = JSON.parse(response.body)
42
+ response_json['id']
43
+ end
44
+
45
+ # Submit Stripe credit card token to EasyPost.
46
+ def create_easypost_credit_card(referral_api_key, stripe_object_id, priority = 'primary')
47
+ wrapped_params = {
48
+ credit_card: {
49
+ stripe_object_id: stripe_object_id,
50
+ priority: priority,
51
+ },
52
+ }
53
+ response = EasyPost.make_request(:post, '/beta/credit_cards', referral_api_key, wrapped_params)
54
+ EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
55
+ end
56
+ end
57
+
5
58
  # Create a referral user. This function requires the Partner User's API key.
59
+ # <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
6
60
  def self.create(params = {}, api_key = nil)
61
+ warn '[DEPRECATION] Please use `Referral.create` in the main namespace instead.'
7
62
  response = EasyPost.make_request(:post, '/beta/referral_customers', api_key, { user: params })
8
63
  EasyPost::Util.convert_to_easypost_object(response, api_key)
9
64
  end
10
65
 
11
66
  # Update a referral user. This function requires the Partner User's API key.
67
+ # <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
12
68
  def self.update_email(email, user_id, api_key = nil)
69
+ warn '[DEPRECATION] Please use `Referral.update_email` in the main namespace instead.'
13
70
  wrapped_params = {
14
71
  user: {
15
72
  email: email,
@@ -22,13 +79,17 @@ class EasyPost::Beta::Referral < EasyPost::Resource
22
79
  end
23
80
 
24
81
  # Retrieve a list of referral users. This function requires the Partner User's API key.
82
+ # <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
25
83
  def self.all(params = {}, api_key = nil)
84
+ warn '[DEPRECATION] Please use `Referral.all` in the main namespace instead.'
26
85
  response = EasyPost.make_request(:get, '/beta/referral_customers', api_key, params)
27
86
  EasyPost::Util.convert_to_easypost_object(response, api_key)
28
87
  end
29
88
 
30
89
  # Add credit card to a referral user. This function requires the Referral User's API key.
90
+ # <b>DEPRECATED:</b> Please use <tt>Referral</tt> in the main namespace instead.
31
91
  def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary')
92
+ warn '[DEPRECATION] Please use `Referral.add_credit_card` in the main namespace instead.'
32
93
  easypost_stripe_api_key = retrieve_easypost_stripe_api_key
33
94
 
34
95
  begin
@@ -46,52 +107,4 @@ class EasyPost::Beta::Referral < EasyPost::Resource
46
107
  response = create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority)
47
108
  EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
48
109
  end
49
-
50
- # Retrieve EasyPost's Stripe public API key.
51
- def self.retrieve_easypost_stripe_api_key
52
- response = EasyPost.make_request(:get, '/beta/partners/stripe_public_key', @api_key)
53
- response['public_key']
54
- end
55
-
56
- # Get credit card token from Stripe.
57
- def self.create_stripe_token(number, expiration_month, expiration_year, cvc, easypost_stripe_token)
58
- headers = {
59
- # This Stripe endpoint only accepts URL form encoded bodies.
60
- Authorization: "Bearer #{easypost_stripe_token}",
61
- 'Content-type': 'application/x-www-form-urlencoded',
62
- }
63
-
64
- credit_card_hash = {
65
- card: {
66
- number: number,
67
- exp_month: expiration_month,
68
- exp_year: expiration_year,
69
- cvc: cvc,
70
- },
71
- }
72
-
73
- form_encoded_params = EasyPost::Util.form_encode_params(credit_card_hash)
74
-
75
- uri = URI.parse('https://api.stripe.com/v1/tokens')
76
- http = Net::HTTP.new(uri.host, uri.port)
77
- http.use_ssl = true
78
- request = Net::HTTP::Post.new(uri.request_uri, headers)
79
- query = URI.encode_www_form(form_encoded_params)
80
-
81
- response = http.request(request, query)
82
- response_json = JSON.parse(response.body)
83
- response_json['id']
84
- end
85
-
86
- # Submit Stripe credit card token to EasyPost.
87
- def self.create_easypost_credit_card(referral_api_key, stripe_object_id, priority = 'primary')
88
- wrapped_params = {
89
- credit_card: {
90
- stripe_object_id: stripe_object_id,
91
- priority: priority,
92
- },
93
- }
94
- response = EasyPost.make_request(:post, '/beta/credit_cards', referral_api_key, wrapped_params)
95
- EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
96
- end
97
110
  end
@@ -2,9 +2,41 @@
2
2
 
3
3
  # Billing class that users can manage their payment and fund
4
4
  class EasyPost::Billing < EasyPost::Resource
5
+ class << self
6
+ protected
7
+
8
+ # Get payment method info (type of the payment method and ID of the payment method)
9
+ def get_payment_method_info(primary_or_secondary)
10
+ payment_methods = EasyPost::Billing.retrieve_payment_methods
11
+ payment_method_map = {
12
+ 'primary' => 'primary_payment_method',
13
+ 'secondary' => 'secondary_payment_method',
14
+ }
15
+
16
+ payment_method_to_use = payment_method_map[primary_or_secondary]
17
+
18
+ error_string = 'The chosen payment method is not valid. Please try again.'
19
+ raise EasyPost::Error.new(error_string) if payment_methods[payment_method_to_use].nil?
20
+
21
+ payment_method_id = payment_methods[payment_method_to_use]['id']
22
+
23
+ unless payment_method_id.nil?
24
+ if payment_method_id.start_with?('card_')
25
+ endpoint = '/v2/credit_cards'
26
+ elsif payment_method_id.start_with?('bank_')
27
+ endpoint = '/v2/bank_accounts'
28
+ else
29
+ raise EasyPost::Error.new(error_string)
30
+ end
31
+ end
32
+
33
+ [endpoint, payment_method_id]
34
+ end
35
+ end
36
+
5
37
  # Fund your EasyPost wallet by charging your primary or secondary card on file.
6
38
  def self.fund_wallet(amount, primary_or_secondary = 'primary', api_key = nil)
7
- payment_info = EasyPost::Billing.get_payment_method_info(primary_or_secondary.downcase)
39
+ payment_info = get_payment_method_info(primary_or_secondary.downcase)
8
40
  endpoint = payment_info[0]
9
41
  payment_id = payment_info[1]
10
42
 
@@ -17,7 +49,7 @@ class EasyPost::Billing < EasyPost::Resource
17
49
 
18
50
  # Delete a payment method.
19
51
  def self.delete_payment_method(primary_or_secondary, api_key = nil)
20
- payment_info = EasyPost::Billing.get_payment_method_info(primary_or_secondary.downcase)
52
+ payment_info = get_payment_method_info(primary_or_secondary.downcase)
21
53
  endpoint = payment_info[0]
22
54
  payment_id = payment_info[1]
23
55
 
@@ -37,32 +69,4 @@ class EasyPost::Billing < EasyPost::Resource
37
69
 
38
70
  EasyPost::Util.convert_to_easypost_object(response, api_key)
39
71
  end
40
-
41
- # Get payment method info (type of the payment method and ID of the payment method)
42
- private_class_method def self.get_payment_method_info(primary_or_secondary)
43
- payment_methods = EasyPost::Billing.retrieve_payment_methods
44
- payment_method_map = {
45
- 'primary' => 'primary_payment_method',
46
- 'secondary' => 'secondary_payment_method',
47
- }
48
-
49
- payment_method_to_use = payment_method_map[primary_or_secondary]
50
-
51
- error_string = 'The chosen payment method is not valid. Please try again.'
52
- raise EasyPost::Error.new(error_string) if payment_methods[payment_method_to_use].nil?
53
-
54
- payment_method_id = payment_methods[payment_method_to_use]['id']
55
-
56
- unless payment_method_id.nil?
57
- if payment_method_id.start_with?('card_')
58
- endpoint = '/v2/credit_cards'
59
- elsif payment_method_id.start_with?('bank_')
60
- endpoint = '/v2/bank_accounts'
61
- else
62
- raise EasyPost::Error.new(error_string)
63
- end
64
- end
65
-
66
- [endpoint, payment_method_id]
67
- end
68
72
  end
@@ -52,7 +52,7 @@ EasyPost::Connection = Struct.new(:uri, :config, keyword_init: true) do
52
52
  request.body = JSON.dump(EasyPost::Util.objects_to_ids(body)) if body
53
53
 
54
54
  EasyPost.default_headers.each_pair { |h, v| request[h] = v }
55
- request['Authorization'] = EasyPost.authorization(api_key) if api_key
55
+ request['Authorization'] = EasyPost.authorization(api_key)
56
56
 
57
57
  response = connection.request(request)
58
58
  response_is_json = response['Content-Type'] ? response['Content-Type'].start_with?('application/json') : false
@@ -6,7 +6,8 @@ class EasyPost::Error < StandardError
6
6
 
7
7
  # Initialize a new EasyPost Error
8
8
  def initialize(message = nil, status = nil, code = nil, errors = nil, http_body = nil)
9
- @message = message
9
+ # message should be a string but can sometimes incorrectly come back as an array
10
+ @message = message.is_a?(Array) ? message.join(', ') : message
10
11
  @status = status
11
12
  @code = code
12
13
  @errors = errors
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Referral objects are User objects created from a Partner user.
4
+ class EasyPost::Referral < EasyPost::Resource
5
+ class << self
6
+ protected
7
+
8
+ # Retrieve EasyPost's Stripe public API key.
9
+ def retrieve_easypost_stripe_api_key
10
+ response = EasyPost.make_request(:get, '/beta/partners/stripe_public_key', @api_key)
11
+ response['public_key']
12
+ end
13
+
14
+ # Get credit card token from Stripe.
15
+ def create_stripe_token(number, expiration_month, expiration_year,
16
+ cvc, easypost_stripe_token)
17
+ headers = {
18
+ # This Stripe endpoint only accepts URL form encoded bodies.
19
+ Authorization: "Bearer #{easypost_stripe_token}",
20
+ 'Content-type': 'application/x-www-form-urlencoded',
21
+ }
22
+
23
+ credit_card_hash = {
24
+ card: {
25
+ number: number,
26
+ exp_month: expiration_month,
27
+ exp_year: expiration_year,
28
+ cvc: cvc,
29
+ },
30
+ }
31
+
32
+ form_encoded_params = EasyPost::Util.form_encode_params(credit_card_hash)
33
+
34
+ uri = URI.parse('https://api.stripe.com/v1/tokens')
35
+ http = Net::HTTP.new(uri.host, uri.port)
36
+ http.use_ssl = true
37
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
38
+ query = URI.encode_www_form(form_encoded_params)
39
+
40
+ response = http.request(request, query)
41
+ response_json = JSON.parse(response.body)
42
+ response_json['id']
43
+ end
44
+
45
+ # Submit Stripe credit card token to EasyPost.
46
+ def create_easypost_credit_card(referral_api_key, stripe_object_id, priority = 'primary')
47
+ wrapped_params = {
48
+ credit_card: {
49
+ stripe_object_id: stripe_object_id,
50
+ priority: priority,
51
+ },
52
+ }
53
+ response = EasyPost.make_request(:post, '/beta/credit_cards', referral_api_key, wrapped_params)
54
+ EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
55
+ end
56
+ end
57
+
58
+ # Create a referral user. This function requires the Partner User's API key.
59
+ def self.create(params = {}, api_key = nil)
60
+ response = EasyPost.make_request(:post, '/v2/referral_customers', api_key, { user: params })
61
+ EasyPost::Util.convert_to_easypost_object(response, api_key)
62
+ end
63
+
64
+ # Update a referral user. This function requires the Partner User's API key.
65
+ def self.update_email(email, user_id, api_key = nil)
66
+ wrapped_params = {
67
+ user: {
68
+ email: email,
69
+ },
70
+ }
71
+ EasyPost.make_request(:put, "/v2/referral_customers/#{user_id}", api_key, wrapped_params)
72
+
73
+ # return true if API succeeds, else an error is throw if it fails.
74
+ true
75
+ end
76
+
77
+ # Retrieve a list of referral users. This function requires the Partner User's API key.
78
+ def self.all(params = {}, api_key = nil)
79
+ response = EasyPost.make_request(:get, '/v2/referral_customers', api_key, params)
80
+ EasyPost::Util.convert_to_easypost_object(response, api_key)
81
+ end
82
+
83
+ # Add credit card to a referral user. This function requires the Referral User's API key.
84
+ def self.add_credit_card(referral_api_key, number, expiration_month, expiration_year, cvc, priority = 'primary')
85
+ easypost_stripe_api_key = retrieve_easypost_stripe_api_key
86
+
87
+ begin
88
+ stripe_credit_card_token = create_stripe_token(
89
+ number,
90
+ expiration_month,
91
+ expiration_year,
92
+ cvc,
93
+ easypost_stripe_api_key,
94
+ )
95
+ rescue StandardError
96
+ raise EasyPost::Error.new('Could not send card details to Stripe, please try again later.')
97
+ end
98
+
99
+ response = create_easypost_credit_card(referral_api_key, stripe_credit_card_token, priority)
100
+ EasyPost::Util.convert_to_easypost_object(response, referral_api_key)
101
+ end
102
+ end
@@ -48,6 +48,7 @@ class EasyPost::Resource < EasyPost::EasyPostObject
48
48
  EasyPost::Util.convert_to_easypost_object(response, api_key)
49
49
  end
50
50
 
51
+ # Filter all results based on criteria.
51
52
  def self.each(filters = {}, api_key = EasyPost.api_key, &block)
52
53
  return to_enum(:each, filters, api_key) unless block_given?
53
54
 
@@ -35,14 +35,23 @@ class EasyPost::Shipment < EasyPost::Resource
35
35
  end
36
36
 
37
37
  # Buy a Shipment.
38
- def buy(params = {}, with_carbon_offset = false)
38
+ def buy(params = {}, with_carbon_offset = false, end_shipper_id = nil)
39
39
  if params.instance_of?(EasyPost::Rate)
40
40
  temp = params.clone
41
41
  params = {}
42
42
  params[:rate] = temp
43
43
  end
44
44
 
45
- params[:carbon_offset] = with_carbon_offset
45
+ if params[:with_carbon_offset]
46
+ params[:carbon_offset] = params[:with_carbon_offset]
47
+ params.delete(:with_carbon_offset)
48
+ else
49
+ params[:carbon_offset] = with_carbon_offset
50
+ end
51
+
52
+ if end_shipper_id
53
+ params[:end_shipper_id] = end_shipper_id
54
+ end
46
55
 
47
56
  response = EasyPost.make_request(:post, "#{url}/buy", @api_key, params)
48
57
  refresh_from(response, @api_key)
data/lib/easypost.rb CHANGED
@@ -26,10 +26,12 @@ require 'easypost/event'
26
26
  require 'easypost/insurance'
27
27
  require 'easypost/order'
28
28
  require 'easypost/parcel'
29
+ require 'easypost/payment_method' # deprecated
29
30
  require 'easypost/pickup_rate'
30
31
  require 'easypost/pickup'
31
32
  require 'easypost/postage_label'
32
33
  require 'easypost/rate'
34
+ require 'easypost/referral'
33
35
  require 'easypost/refund'
34
36
  require 'easypost/report'
35
37
  require 'easypost/scan_form'
@@ -132,7 +134,7 @@ module EasyPost
132
134
  end
133
135
 
134
136
  def self.parse_response(status:, body:, json:)
135
- if status >= 400
137
+ if status < 200 || status >= 300
136
138
  error = JSON.parse(body)['error']
137
139
 
138
140
  raise EasyPost::Error.new(
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.7.1
4
+ version: 4.8.1
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-09-06 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brakeman
@@ -208,6 +208,7 @@ files:
208
208
  - lib/easypost/pickup_rate.rb
209
209
  - lib/easypost/postage_label.rb
210
210
  - lib/easypost/rate.rb
211
+ - lib/easypost/referral.rb
211
212
  - lib/easypost/refund.rb
212
213
  - lib/easypost/report.rb
213
214
  - lib/easypost/resource.rb