paypal-rest 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6a232625846c2f019c3b39ba9e48f3793812867bdcc47c8b2bb58be4849d63d
4
- data.tar.gz: 780a910c3ecd50342a641c64e07e0692e7a6970f201d62928b5c6e8f9db789e7
3
+ metadata.gz: 06b8fc77627f76f8ce2f95ff373a9c4f8fb17670e3f0a097887998761eec117a
4
+ data.tar.gz: 67d2ab3a15577fbca1da0875464ff150df86363c429b50f39a3d57e1690b0ec3
5
5
  SHA512:
6
- metadata.gz: e1fee1827129e2cc2695048c766d386320ea29b9f2730a0f3b908e0a88e60ddb5aff16321ed8101d1475e8abe512401bd5d75b79e452657c8ad9b1b19127a170
7
- data.tar.gz: f82fa4d1d7cb11f68d5e49812ba653a55841cb348315c0e63349d39c734b9f0335320ea539eac42bcdd4bed9de6f122fcecb92d918f25e824fab2a7e4664cef0
6
+ metadata.gz: d3caca7697df2acc86f529657574f0184c0422be027800130e04af9d7059bc75a9d53d11e3227991bc2af540787498f2337df031a3c03608170b55673cc74ae0
7
+ data.tar.gz: abf42d139b20768e5cb8d7b64756593793dfda303c0af00ea6d946b58870cfba7640695baf7bf38f474d080c2ef4d14d432701f97bb8cf6a02a2d9a07d3fc41c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paypal-rest (1.0.0)
4
+ paypal-rest (1.1.1)
5
5
  faraday (~> 2.2)
6
6
  faraday-retry (~> 1.0)
7
7
 
@@ -1,5 +1,5 @@
1
1
  module Paypal
2
2
  class REST
3
- VERSION = "1.1.0".freeze
3
+ VERSION = "1.1.1".freeze
4
4
  end
5
5
  end
data/lib/paypal/rest.rb CHANGED
@@ -46,11 +46,22 @@ module Paypal
46
46
 
47
47
  private
48
48
 
49
+ def get(path)
50
+ request do |connection|
51
+ connection.get(path)
52
+ end
53
+ end
54
+
49
55
  def post(path, params: {}, headers: {})
50
- reset_connection if @bearer_token&.expired?
56
+ request do |connection|
57
+ connection.post(path, params, headers)
58
+ end
59
+ end
51
60
 
52
- response = connection.post(path, params, headers).body
61
+ def request
62
+ reset_connection if @bearer_token&.expired?
53
63
 
64
+ response = yield(connection).body
54
65
  response = JSON.parse(response) if response.is_a?(String)
55
66
  response = Util.deep_symbolize_keys(response)
56
67
 
@@ -58,8 +69,8 @@ module Paypal
58
69
 
59
70
  response
60
71
  rescue JSON::ParserError, Faraday::ClientError => e
61
- Rails.logger.error(["#{self.class} - #{e.class}: #{e.message}", e.backtrace].join($INPUT_RECORD_SEPARATOR))
62
- head :unprocessable_entity
72
+ logger.debug(["#{self.class} - #{e.class}: #{e.message}", e.backtrace].join($INPUT_RECORD_SEPARATOR))
73
+ raise ClientError, e.message
63
74
  end
64
75
 
65
76
  def connection
@@ -76,6 +87,12 @@ module Paypal
76
87
 
77
88
  @bearer_token = BearerToken.new
78
89
  end
90
+
91
+ def logger
92
+ configuration.logger
93
+ end
94
+
95
+ class ClientError < StandardError; end
79
96
  end
80
97
  end
81
98
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Crosby-McCullough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -76,7 +76,7 @@ metadata:
76
76
  allowed_push_host: https://rubygems.org
77
77
  homepage_uri: https://github.com/SmartCasual/paypal-rest
78
78
  source_code_uri: https://github.com/SmartCasual/paypal-rest
79
- changelog_uri: https://github.com/SmartCasual/paypal-rest/blob/1.1.0/CHANGELOG.md
79
+ changelog_uri: https://github.com/SmartCasual/paypal-rest/blob/1.1.1/CHANGELOG.md
80
80
  rubygems_mfa_required: 'true'
81
81
  post_install_message:
82
82
  rdoc_options: []