payoneer_ruby_sdk 0.1.3 → 0.1.4
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/README.md +2 -1
- data/lib/payoneer/api/core.rb +23 -1
- data/lib/payoneer/configuration.rb +18 -1
- data/lib/payoneer/version.rb +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: e157dfc6e430bda6a7c4af180e75792afeccd0af
|
4
|
+
data.tar.gz: c09dd594c046f92793b6782c31881d51c0770c42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a36cebe97264dabc45576117a1876275e7587a2a8ec542e6419c79d748c24bebc5f263f2b60d98fc1360e3853fcd7fdbfd8a7302fafda9ffb6b91955fcc059
|
7
|
+
data.tar.gz: 50afdede823c22ffa7e5f428ca4b03a38c86e3a89d21bcefe318168465832aa40f4ce80b8986a91e18b43840e9c4ea08bc427099a048a13f4eafe4e78cfb08b1
|
data/README.md
CHANGED
data/lib/payoneer/api/core.rb
CHANGED
@@ -25,13 +25,35 @@ module Payoneer
|
|
25
25
|
|
26
26
|
request_params = default_params.merge(mname: method_name).merge(params)
|
27
27
|
|
28
|
-
|
28
|
+
request = Request.new(config)
|
29
|
+
response = request.execute(request_params)
|
29
30
|
|
30
31
|
fail Errors::ApiError.new(response.code, response.body) unless response.code == 200
|
31
32
|
|
32
33
|
to_response(response)
|
33
34
|
end
|
34
35
|
|
36
|
+
class Request
|
37
|
+
attr_accessor :max_attempts, :num_attempts, :config
|
38
|
+
def initialize(config)
|
39
|
+
self.config = config
|
40
|
+
self.max_attempts = config.proxy.size
|
41
|
+
self.num_attempts = 0
|
42
|
+
end
|
43
|
+
def execute(request_params)
|
44
|
+
self.num_attempts += 1
|
45
|
+
config.setup_proxy_if_set
|
46
|
+
RestClient.post(config.api_url, request_params)
|
47
|
+
rescue RestClient::RequestTimeout => e
|
48
|
+
# if Net::OpenTimeout === e.original_exception &&
|
49
|
+
if self.max_attempts > self.num_attempts
|
50
|
+
config.rotate_proxy
|
51
|
+
retry
|
52
|
+
end
|
53
|
+
raise e
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
35
57
|
def config
|
36
58
|
::Payoneer.config
|
37
59
|
end
|
@@ -22,12 +22,18 @@ module Payoneer
|
|
22
22
|
class Config
|
23
23
|
SANDBOX_API_URL = 'https://api.sandbox.payoneer.com/Payouts/HttpApi/API.aspx'
|
24
24
|
PRODUCTION_API_URL = 'https://api.payoneer.com/Payouts/HttpApi/API.aspx'
|
25
|
-
attr_accessor :partner_username, :partner_api_password, :partner_id, :program_id, :env
|
25
|
+
attr_accessor :partner_username, :partner_api_password, :partner_id, :program_id, :env, :proxy, :proxy_index
|
26
26
|
|
27
27
|
def initialize(options)
|
28
28
|
options.each do |key, value|
|
29
29
|
send("#{key}=", value)
|
30
30
|
end
|
31
|
+
self.normalize_proxies
|
32
|
+
end
|
33
|
+
|
34
|
+
def normalize_proxies
|
35
|
+
self.proxy = self.proxy ? Array(proxy) : []
|
36
|
+
self.proxy_index = 0
|
31
37
|
end
|
32
38
|
|
33
39
|
def validate!
|
@@ -41,6 +47,17 @@ module Payoneer
|
|
41
47
|
def api_url
|
42
48
|
production? ? PRODUCTION_API_URL : SANDBOX_API_URL
|
43
49
|
end
|
50
|
+
|
51
|
+
def setup_proxy_if_set
|
52
|
+
return if self.proxy.size == 0
|
53
|
+
# TODO New in 2.0: Specify a per-request proxy https://github.com/rest-client/rest-client#proxy
|
54
|
+
RestClient.proxy = self.proxy[self.proxy_index]
|
55
|
+
end
|
56
|
+
|
57
|
+
def rotate_proxy
|
58
|
+
self.proxy_index = (self.proxy_index + 1) % self.proxy.size
|
59
|
+
end
|
60
|
+
|
44
61
|
end
|
45
62
|
end
|
46
63
|
end
|
data/lib/payoneer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payoneer_ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kissrobber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|