payoneer-client 0.4 → 0.4.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
  SHA1:
3
- metadata.gz: b979e7078cae676e9250121313b692534a95d0d9
4
- data.tar.gz: aa8d722834abe42c3c3e3ccf01c565e9564c5ed4
3
+ metadata.gz: 19a0562e4e086ea99c5724aa55b51fe8548b6759
4
+ data.tar.gz: e9a1a284f2dfd95ce72fe081990e74a21d85ed17
5
5
  SHA512:
6
- metadata.gz: e91dfb81f67df1ac74223f6b504da96a7fe615f7353e6602d17a5682871bb81bfa3b05aff2063b2de48441e6517077d08db03c340eeb0547c14fff5bf7376357
7
- data.tar.gz: b7b36d1580d962929f35436554337d99151097f0718f9349e5cca330bbcdda498cc7972b924b61621e4b2bcd5de1346d56da35bae43d1507e17def86755ef181
6
+ metadata.gz: 8bff19483810c325edd15ae292369fc6d3fae3585119364cca9d02805583f543c59464851b340c3656a196d0db4f30d58beac6f1c500be26090c9bfeeb6ed9b7
7
+ data.tar.gz: 26f76baa623fb57591c12870114bceb7a31c4ad07e042f503024b6d979c3c228bb53b94289e50e6f70d645bc1f22314db34e76149ea8a3c56243b653f1d0e566
@@ -66,17 +66,19 @@ module Payoneer
66
66
  }
67
67
 
68
68
  encoded_credentials = 'Basic ' + Base64.encode64("#{configuration.username}:#{configuration.api_password}").chomp
69
- response = RestClient.post "#{configuration.json_base_uri}/payouts", params.to_json, content_type: 'application/json', accept: :json, Authorization: encoded_credentials
70
- raise ResponseError.new(code: response.code, body: response.body) if response.code != 200
71
69
 
72
- hash = JSON.parse(response.body)
73
- hash['PaymentID'] = hash['payout_id'] # Keep consistent with the normal payout response body
70
+ begin
71
+ response = RestClient.post "#{configuration.json_base_uri}/payouts", params.to_json, content_type: 'application/json', accept: :json, Authorization: encoded_credentials
74
72
 
75
- if hash.key?('Code')
76
- Response.new(hash['Code'], hash['Description'])
77
- else
78
- hash = block_given? ? yield(hash) : hash
79
- Response.new(Response::OK_STATUS_CODE, hash)
73
+ hash = JSON.parse(response.body)
74
+ hash['PaymentID'] = hash['payout_id'] # Keep consistent with the normal payout response body
75
+
76
+ create_response(hash)
77
+ rescue RestClient::Exception => e
78
+ if e.http_body
79
+ hash = JSON.parse(e.http_body)
80
+ create_response(hash, e.http_code)
81
+ end
80
82
  end
81
83
  end
82
84
 
@@ -106,5 +108,14 @@ module Payoneer
106
108
  Response.new(Response::OK_STATUS_CODE, hash)
107
109
  end
108
110
  end
111
+
112
+ def create_response(hash, http_code = Response::OK_STATUS_CODE)
113
+ if hash.key?('Code')
114
+ Response.new(hash['Code'], hash['Description'])
115
+ else
116
+ hash = block_given? ? yield(hash) : hash
117
+ Response.new(http_code, hash)
118
+ end
119
+ end
109
120
  end
110
121
  end
@@ -3,7 +3,7 @@
3
3
  # gem push payoneer-client-{VERSION}.gem
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'payoneer-client'
6
- s.version = '0.4'
6
+ s.version = '0.4.1'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.licenses = ['MIT']
9
9
  s.authors = ['Chris Estreich']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payoneer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Estreich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport