easypost 6.1.0 → 6.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e4fdfe13e13bd17de295a018e87a4b05c015b9c7b0d523b15720647bd2c9301
4
- data.tar.gz: 6fa130eae97f8b84172683a51f03c29c31dc983dc0b47efa2462b906e8d7ce07
3
+ metadata.gz: ae0d691e3f798606f4153ba71f6d148e3d12eeade8dddec8ab8b06cbd9420173
4
+ data.tar.gz: 92ad3799e9d50460a99844d28c456050fe58ad78d3b440520a429623adc851a5
5
5
  SHA512:
6
- metadata.gz: 4ebe1b2763c764ca26f5515deb1616f9caf6df8b23c446ed4ee3fd0752fd704f51d3ded775f1f3bcfb751c4de2c8b8b631eb013f168a6feaf503e47d84c14be3
7
- data.tar.gz: de858e402e5121112ff2466f44dad3f9a94bd529bcc6916c5d92406fdbeaf8c46e077ac7582b1cdcb50b4e3b345a3dc4ff08cdc879e12a16791406db31b7f091
6
+ metadata.gz: 417aea06119816b367ae0e7eeaada243b1c3a266fb784f36df681130a617bf37bfe6d80a02c0c6aa72c4b1e210f2a220ce67aec37803dc9b04735df08c073b78
7
+ data.tar.gz: 5f550b00033885606ac1f9438696549b40b5602368c39985dded593b666782eaaf05887cbbe3a28afe996e05163c2f30e1740825c27c14e08a1c46f591d01e2e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v6.2.0 (2024-04-10)
4
+
5
+ - Fix payment method funding and deletion failures due to undetermined payment method type
6
+ - Add `refund` function in Insurance service for requesting a refund for standalone insurance.
7
+
8
+ ## v6.1.1 (2024-01-23)
9
+
10
+ - Fix issues funding wallet due to invalid internal function call
11
+
3
12
  ## v6.1.0 (2024-01-08)
4
13
 
5
14
  - Add `all_children` and `get_next_page_of_children` in `user` service
data/Makefile CHANGED
@@ -40,8 +40,9 @@ publish:
40
40
 
41
41
  ## release - Cuts a release for the project on GitHub (requires GitHub CLI)
42
42
  # tag = The associated tag title of the release
43
+ # target = Target branch or full commit SHA
43
44
  release:
44
- gh release create ${tag} dist/*
45
+ gh release create ${tag} dist/* --target ${target}
45
46
 
46
47
  ## rubocop - lints the project with rubocop
47
48
  rubocop:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.1.0
1
+ 6.2.0
data/easypost.gemspec CHANGED
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'brakeman', '~> 5.4'
25
25
  spec.add_development_dependency 'faraday', '~> 2.7.5' # used for integration tests
26
26
  spec.add_development_dependency 'pry', '~> 0.14'
27
- spec.add_development_dependency 'psych', '~> 5.1'
28
27
  spec.add_development_dependency 'rake', '~> 13.0'
29
28
  spec.add_development_dependency 'rdoc', '~> 6.5'
30
29
  spec.add_development_dependency 'rspec', '~> 3.12'
@@ -3,43 +3,9 @@
3
3
  require 'easypost/constants'
4
4
 
5
5
  class EasyPost::Services::Billing < EasyPost::Services::Service
6
- # Get payment method info (type of the payment method and ID of the payment method)
7
- def self.get_payment_method_info(priority)
8
- payment_methods = EasyPost::Services::Billing.retrieve_payment_methods
9
- payment_method_map = {
10
- 'primary' => 'primary_payment_method',
11
- 'secondary' => 'secondary_payment_method',
12
- }
13
-
14
- payment_method_to_use = payment_method_map[priority]
15
-
16
- error_string = EasyPost::Constants::INVALID_PAYMENT_METHOD
17
- suggestion = "Please use a valid payment method: #{payment_method_map.keys.join(', ')}"
18
- if payment_methods[payment_method_to_use].nil?
19
- raise EasyPost::Errors::InvalidParameterError.new(
20
- error_string,
21
- suggestion,
22
- )
23
- end
24
-
25
- payment_method_id = payment_methods[payment_method_to_use]['id']
26
-
27
- unless payment_method_id.nil?
28
- if payment_method_id.start_with?('card_')
29
- endpoint = '/v2/credit_cards'
30
- elsif payment_method_id.start_with?('bank_')
31
- endpoint = '/v2/bank_accounts'
32
- else
33
- raise EasyPost::Errors::InvalidObjectError.new(error_string)
34
- end
35
- end
36
-
37
- [endpoint, payment_method_id]
38
- end
39
-
40
6
  # Fund your EasyPost wallet by charging your primary or secondary card on file.
41
7
  def fund_wallet(amount, priority = 'primary')
42
- payment_info = EasyPost::Services::Billing.get_payment_method_info(priority.downcase)
8
+ payment_info = get_payment_method_info(priority.downcase)
43
9
  endpoint = payment_info[0]
44
10
  payment_id = payment_info[1]
45
11
 
@@ -52,7 +18,7 @@ class EasyPost::Services::Billing < EasyPost::Services::Service
52
18
 
53
19
  # Delete a payment method.
54
20
  def delete_payment_method(priority)
55
- payment_info = EasyPost::Services::Billing.get_payment_method_info(priority.downcase)
21
+ payment_info = get_payment_method_info(priority.downcase)
56
22
  endpoint = payment_info[0]
57
23
  payment_id = payment_info[1]
58
24
 
@@ -64,7 +30,7 @@ class EasyPost::Services::Billing < EasyPost::Services::Service
64
30
 
65
31
  # Retrieve all payment methods.
66
32
  def retrieve_payment_methods
67
- response = @client.make_request(:get, '/v2/payment_methods')
33
+ response = @client.make_request(:get, '/payment_methods')
68
34
  payment_methods = EasyPost::InternalUtilities::Json.convert_json_to_object(response)
69
35
 
70
36
  if payment_methods['id'].nil?
@@ -73,4 +39,40 @@ class EasyPost::Services::Billing < EasyPost::Services::Service
73
39
 
74
40
  payment_methods
75
41
  end
42
+
43
+ private
44
+
45
+ # Get payment method info (type of the payment method and ID of the payment method)
46
+ def get_payment_method_info(priority)
47
+ payment_methods = retrieve_payment_methods
48
+ payment_method_map = {
49
+ 'primary' => 'primary_payment_method',
50
+ 'secondary' => 'secondary_payment_method',
51
+ }
52
+
53
+ payment_method_to_use = payment_method_map[priority]
54
+
55
+ error_string = EasyPost::Constants::INVALID_PAYMENT_METHOD
56
+ suggestion = "Please use a valid payment method: #{payment_method_map.keys.join(', ')}"
57
+ if payment_methods[payment_method_to_use].nil?
58
+ raise EasyPost::Errors::InvalidParameterError.new(
59
+ error_string,
60
+ suggestion,
61
+ )
62
+ end
63
+
64
+ payment_method_id = payment_methods[payment_method_to_use]['id']
65
+ payment_method_object_type = payment_methods[payment_method_to_use]['object']
66
+
67
+ if payment_method_object_type == 'CreditCard'
68
+
69
+ endpoint = '/credit_cards'
70
+ elsif payment_method_object_type == 'BankAccount'
71
+ endpoint = '/bank_accounts'
72
+ else
73
+ raise EasyPost::Errors::InvalidObjectError.new(error_string)
74
+ end
75
+
76
+ [endpoint, payment_method_id]
77
+ end
76
78
  end
@@ -34,4 +34,11 @@ class EasyPost::Services::Insurance < EasyPost::Services::Service
34
34
 
35
35
  all(params)
36
36
  end
37
+
38
+ # Refund an Insurance object
39
+ def refund(id)
40
+ response = @client.make_request(:post, "insurances/#{id}/refund")
41
+
42
+ EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
43
+ end
37
44
  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: 6.1.0
4
+ version: 6.2.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: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brakeman
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.14'
55
- - !ruby/object:Gem::Dependency
56
- name: psych
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -352,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
338
  - !ruby/object:Gem::Version
353
339
  version: '0'
354
340
  requirements: []
355
- rubygems_version: 3.4.10
341
+ rubygems_version: 3.5.4
356
342
  signing_key:
357
343
  specification_version: 4
358
344
  summary: EasyPost Ruby Client Library