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 +4 -4
- data/lib/payoneer/client.rb +20 -9
- data/payoneer-client.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a0562e4e086ea99c5724aa55b51fe8548b6759
|
4
|
+
data.tar.gz: e9a1a284f2dfd95ce72fe081990e74a21d85ed17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bff19483810c325edd15ae292369fc6d3fae3585119364cca9d02805583f543c59464851b340c3656a196d0db4f30d58beac6f1c500be26090c9bfeeb6ed9b7
|
7
|
+
data.tar.gz: 26f76baa623fb57591c12870114bceb7a31c4ad07e042f503024b6d979c3c228bb53b94289e50e6f70d645bc1f22314db34e76149ea8a3c56243b653f1d0e566
|
data/lib/payoneer/client.rb
CHANGED
@@ -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
|
-
|
73
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
data/payoneer-client.gemspec
CHANGED
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:
|
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-
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|