easypost 6.1.0 → 6.1.1
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 +4 -0
- data/Makefile +2 -1
- data/VERSION +1 -1
- data/easypost.gemspec +0 -1
- data/lib/easypost/services/billing.rb +39 -37
- metadata +3 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78ff932eb3d904ba184e444260e54f89bc1130fa7a93f5483c3a322071035d99
|
|
4
|
+
data.tar.gz: 51fd77d26ae8bb1351880956a47cdcd1529c84e51f26a209b125e28a67b6fa9f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21b04b15fa14c1f82bdaf7b208201f66f186c8c5b6adc4d1a4e9040e93232b9c4f3793f0a5064eaaafca269818a75e2e7b33c6cb0476793da48735d087045da3
|
|
7
|
+
data.tar.gz: 15525784bb626e44c1469513ebc16663b8f8b0c882c46270514783118f21dc6b7b2afb4ec092fedfb0eae17325acb46a671292db385fae7a2dffca58de7d1ec9
|
data/CHANGELOG.md
CHANGED
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.
|
|
1
|
+
6.1.1
|
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 =
|
|
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 =
|
|
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, '/
|
|
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
|
+
|
|
66
|
+
unless payment_method_id.nil?
|
|
67
|
+
if payment_method_id.start_with?('card_')
|
|
68
|
+
endpoint = '/credit_cards'
|
|
69
|
+
elsif payment_method_id.start_with?('bank_')
|
|
70
|
+
endpoint = '/bank_accounts'
|
|
71
|
+
else
|
|
72
|
+
raise EasyPost::Errors::InvalidObjectError.new(error_string)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
[endpoint, payment_method_id]
|
|
77
|
+
end
|
|
76
78
|
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.
|
|
4
|
+
version: 6.1.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: 2024-01-
|
|
11
|
+
date: 2024-01-23 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
|
|
341
|
+
rubygems_version: 3.5.4
|
|
356
342
|
signing_key:
|
|
357
343
|
specification_version: 4
|
|
358
344
|
summary: EasyPost Ruby Client Library
|