payoneer-client 0.5.0 → 0.6.0
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 +15 -1
- data/lib/payoneer/configuration.rb +18 -12
- data/payoneer-client.gemspec +1 -1
- data/spec/client_spec.rb +15 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4311a1281df1509604f1d4300f3357a45fb655a61c25a6f503e8f7b47c018e13
|
4
|
+
data.tar.gz: 259187134b61decaac84f751f582ce8b442655b5c0ad28025a3f82a65e847d0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 529857afc92ecd7353975770a3f4cb27f501239f2d6f7e506a0e610b2478fcca58c442ba9989c06dc2dbe405bedb2f031ea649c4ba558ee31ebcc9bc11da6b17
|
7
|
+
data.tar.gz: a9b71a24fabe1468200609a53f8b7865a3e6531878180d80d48babd947ca2bbad507ff841b3c75d91f55b1e0420336802888215d16b6e5b2cc98af79525c99d1
|
data/README.md
CHANGED
@@ -66,7 +66,21 @@ client.payee_details('fake-payee-id').body
|
|
66
66
|
|
67
67
|
```
|
68
68
|
|
69
|
-
##### Advanced
|
69
|
+
##### Advanced Options
|
70
|
+
|
71
|
+
If you need to interact with an API host other than the default Payoneer
|
72
|
+
production/sandbox API URLs, you can pass a `host` option to the configuration:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
client = Payoneer::Client.new(
|
76
|
+
Payoneer::Configuration.new(
|
77
|
+
username: 'fake-username',
|
78
|
+
api_password: 'fake-api-password',
|
79
|
+
partner_id: 'fake-partner-id',
|
80
|
+
host: 'myspecial.api.payoneer.com'
|
81
|
+
)
|
82
|
+
)
|
83
|
+
```
|
70
84
|
|
71
85
|
If you need to do additional configuration on the underlying HTTP client (RestClient), you can pass additional config under an `http_client_options` key and this will be passed through directly to the HTTP client.
|
72
86
|
|
@@ -2,29 +2,35 @@ module Payoneer
|
|
2
2
|
class Configuration
|
3
3
|
attr_reader :partner_id, :username, :api_password, :auto_approve_sandbox_accounts, :http_client_options
|
4
4
|
|
5
|
-
def initialize(partner_id:, username:, api_password:, environment: 'development',
|
5
|
+
def initialize(partner_id:, username:, api_password:, environment: 'development', protocol: 'https', host: nil, http_client_options: {}, auto_approve_sandbox_accounts: true)
|
6
6
|
@partner_id = partner_id
|
7
7
|
@username = username
|
8
8
|
@api_password = api_password
|
9
|
-
@
|
10
|
-
@auto_approve_sandbox_accounts = auto_approve_sandbox_accounts && environment != 'production'
|
11
|
-
@http_client_options = http_client_options
|
12
|
-
end
|
9
|
+
@environment = environment
|
13
10
|
|
14
|
-
|
15
|
-
@
|
16
|
-
|
11
|
+
@protocol = protocol
|
12
|
+
@host = host || default_host
|
13
|
+
@http_client_options = http_client_options
|
17
14
|
|
18
|
-
|
19
|
-
@host || 'api.payoneer.com'
|
15
|
+
@auto_approve_sandbox_accounts = auto_approve_sandbox_accounts && environment != 'production'
|
20
16
|
end
|
21
17
|
|
22
18
|
def xml_base_uri
|
23
|
-
|
19
|
+
"#{@protocol}://#{@host}/Payouts/HttpApi/API.aspx"
|
24
20
|
end
|
25
21
|
|
26
22
|
def json_base_uri
|
27
|
-
|
23
|
+
"#{@protocol}://#{@host}/v2/programs/#{@partner_id}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def default_host
|
29
|
+
if @environment == 'production'
|
30
|
+
'api.payoneer.com'
|
31
|
+
else
|
32
|
+
'api.sandbox.payoneer.com'
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/payoneer-client.gemspec
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -142,12 +142,23 @@ describe Payoneer::Client do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
describe 'configuration' do
|
145
|
-
let(:config_options) { default_config_options.merge(http_client_options: { verify_ssl: true }) }
|
146
145
|
let(:xml) { "<?xml version='1.0' encoding='ISO-8859-1' ?><PayoneerResponse><Status>000</Status><Description>Echo Ok - All systems are up.</Description></PayoneerResponse>" }
|
147
146
|
|
148
|
-
|
149
|
-
|
150
|
-
client
|
147
|
+
describe 'http_client_options' do
|
148
|
+
let(:config_options) { default_config_options.merge(http_client_options: { verify_ssl: true }) }
|
149
|
+
it 'passes HTTP client options to HTTP client' do
|
150
|
+
expect(RestClient::Request).to receive(:execute).with(hash_including(verify_ssl: true)).and_return(response)
|
151
|
+
client.status
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe 'host' do
|
156
|
+
let(:config_options) { default_config_options.merge(host: 'api.example.com') }
|
157
|
+
it 'allows using a custom API host' do
|
158
|
+
expected_url = 'https://api.example.com/Payouts/HttpApi/API.aspx'
|
159
|
+
expect(RestClient::Request).to receive(:execute).with(hash_including(url: expected_url)).and_return(response)
|
160
|
+
client.status
|
161
|
+
end
|
151
162
|
end
|
152
163
|
end
|
153
164
|
end
|