payoneer-client 0.5.0 → 0.6.0

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
  SHA256:
3
- metadata.gz: 40d1016bcb66c53acdd28ac3237841db3668a089a276a3d809396b480bb6994e
4
- data.tar.gz: 0dd7222c3da2b4a95cb0f9cbbdb00809bd67c3495855616f059e08dd9c443f14
3
+ metadata.gz: 4311a1281df1509604f1d4300f3357a45fb655a61c25a6f503e8f7b47c018e13
4
+ data.tar.gz: 259187134b61decaac84f751f582ce8b442655b5c0ad28025a3f82a65e847d0d
5
5
  SHA512:
6
- metadata.gz: 46b6432e3ce7da68809383ea0289bd441df39e529943005dc04b86105b4a7bb3a699cfac02915d94c11c04aa9c33df5d49a031548ea56b80a2e111e70ab0c42f
7
- data.tar.gz: 636441a67541364fb12089b76e8fccee0319540d5ccfaccd9bb6be668aeb5a8ad9299bf6f7a4424282fd99383df6fbd7eec2f0502537212eb3a8bb82da8b8e19
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 HTTP Client Options
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', auto_approve_sandbox_accounts: true, http_client_options: {})
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
- @host = 'api.sandbox.payoneer.com' if environment != 'production'
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
- def protocol
15
- @protocol || 'https'
16
- end
11
+ @protocol = protocol
12
+ @host = host || default_host
13
+ @http_client_options = http_client_options
17
14
 
18
- def host
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
- @xml_base_uri || "#{protocol}://#{host}/Payouts/HttpApi/API.aspx"
19
+ "#{@protocol}://#{@host}/Payouts/HttpApi/API.aspx"
24
20
  end
25
21
 
26
22
  def json_base_uri
27
- @json_base_uri || "#{protocol}://#{host}/v2/programs/#{@partner_id}"
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
@@ -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.5.0'
6
+ s.version = '0.6.0'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.licenses = ['MIT']
9
9
  s.authors = ['Chris Estreich', 'Todd Eichel']
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
- it 'passes HTTP client options to HTTP client' do
149
- expect(RestClient::Request).to receive(:execute).with(hash_including(verify_ssl: true)).and_return(response)
150
- client.status
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payoneer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Estreich