payoneer-client 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 19a0562e4e086ea99c5724aa55b51fe8548b6759
4
- data.tar.gz: e9a1a284f2dfd95ce72fe081990e74a21d85ed17
2
+ SHA256:
3
+ metadata.gz: 40d1016bcb66c53acdd28ac3237841db3668a089a276a3d809396b480bb6994e
4
+ data.tar.gz: 0dd7222c3da2b4a95cb0f9cbbdb00809bd67c3495855616f059e08dd9c443f14
5
5
  SHA512:
6
- metadata.gz: 8bff19483810c325edd15ae292369fc6d3fae3585119364cca9d02805583f543c59464851b340c3656a196d0db4f30d58beac6f1c500be26090c9bfeeb6ed9b7
7
- data.tar.gz: 26f76baa623fb57591c12870114bceb7a31c4ad07e042f503024b6d979c3c228bb53b94289e50e6f70d645bc1f22314db34e76149ea8a3c56243b653f1d0e566
6
+ metadata.gz: 46b6432e3ce7da68809383ea0289bd441df39e529943005dc04b86105b4a7bb3a699cfac02915d94c11c04aa9c33df5d49a031548ea56b80a2e111e70ab0c42f
7
+ data.tar.gz: 636441a67541364fb12089b76e8fccee0319540d5ccfaccd9bb6be668aeb5a8ad9299bf6f7a4424282fd99383df6fbd7eec2f0502537212eb3a8bb82da8b8e19
data/README.md CHANGED
@@ -66,6 +66,23 @@ client.payee_details('fake-payee-id').body
66
66
 
67
67
  ```
68
68
 
69
+ ##### Advanced HTTP Client Options
70
+
71
+ 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
+
73
+ ```ruby
74
+ client = Payoneer::Client.new(
75
+ Payoneer::Configuration.new(
76
+ username: 'fake-username',
77
+ api_password: 'fake-api-password',
78
+ partner_id: 'fake-partner-id',
79
+ http_client_options: {
80
+ verify_ssl: true
81
+ }
82
+ )
83
+ )
84
+ ```
85
+
69
86
  ##### Performing a normal payout:
70
87
  ```ruby
71
88
  response = client.payout(
@@ -65,10 +65,18 @@ module Payoneer
65
65
  }
66
66
  }
67
67
 
68
- encoded_credentials = 'Basic ' + Base64.encode64("#{configuration.username}:#{configuration.api_password}").chomp
69
-
70
68
  begin
71
- response = RestClient.post "#{configuration.json_base_uri}/payouts", params.to_json, content_type: 'application/json', accept: :json, Authorization: encoded_credentials
69
+ response = RestClient::Request.execute(
70
+ method: :post,
71
+ url: "#{configuration.json_base_uri}/payouts",
72
+ payload: params.to_json,
73
+ headers: {
74
+ content_type: 'application/json',
75
+ accept: :json,
76
+ Authorization: 'Basic ' + Base64.encode64("#{configuration.username}:#{configuration.api_password}").chomp
77
+ },
78
+ **configuration.http_client_options
79
+ )
72
80
 
73
81
  hash = JSON.parse(response.body)
74
82
  hash['PaymentID'] = hash['payout_id'] # Keep consistent with the normal payout response body
@@ -89,12 +97,17 @@ module Payoneer
89
97
  private
90
98
 
91
99
  def post(method_name, params = {})
92
- response = RestClient.post(configuration.xml_base_uri, {
93
- mname: method_name,
94
- p1: configuration.username,
95
- p2: configuration.api_password,
96
- p3: configuration.partner_id
97
- }.merge(params))
100
+ response = RestClient::Request.execute(
101
+ method: :post,
102
+ url: configuration.xml_base_uri,
103
+ payload: {
104
+ mname: method_name,
105
+ p1: configuration.username,
106
+ p2: configuration.api_password,
107
+ p3: configuration.partner_id
108
+ }.merge(params),
109
+ **configuration.http_client_options
110
+ )
98
111
 
99
112
  raise ResponseError.new(code: response.code, body: response.body) if response.code != 200
100
113
 
@@ -1,13 +1,14 @@
1
1
  module Payoneer
2
2
  class Configuration
3
- attr_reader :partner_id, :username, :api_password, :auto_approve_sandbox_accounts
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)
5
+ def initialize(partner_id:, username:, api_password:, environment: 'development', auto_approve_sandbox_accounts: true, http_client_options: {})
6
6
  @partner_id = partner_id
7
7
  @username = username
8
8
  @api_password = api_password
9
9
  @host = 'api.sandbox.payoneer.com' if environment != 'production'
10
10
  @auto_approve_sandbox_accounts = auto_approve_sandbox_accounts && environment != 'production'
11
+ @http_client_options = http_client_options
11
12
  end
12
13
 
13
14
  def protocol
@@ -3,11 +3,11 @@
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.1'
6
+ s.version = '0.5.0'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.licenses = ['MIT']
9
- s.authors = ['Chris Estreich']
10
- s.email = ['chris@tophatter.com']
9
+ s.authors = ['Chris Estreich', 'Todd Eichel']
10
+ s.email = ['chris@tophatter.com', 'todd@tophatter.com']
11
11
  s.homepage = 'https://github.com/tophatter/payoneer-api-ruby'
12
12
  s.summary = 'Payoneer SDK for ruby.'
13
13
  s.description = 'Payoneer SDK for ruby.'
data/spec/client_spec.rb CHANGED
@@ -10,7 +10,9 @@ describe Payoneer::Client do
10
10
  end
11
11
 
12
12
  let(:endpoint) { 'https://api.payoneer.com/Payouts/HttpApi/API.aspx' }
13
- let(:configuration) { Payoneer::Configuration.new(username: 'fake-username', api_password: 'fake-password', partner_id: 'fake-partner-id', environment: 'production') }
13
+ let(:default_config_options) { { username: 'fake-username', api_password: 'fake-password', partner_id: 'fake-partner-id', environment: 'production' } }
14
+ let(:config_options) { default_config_options }
15
+ let(:configuration) { Payoneer::Configuration.new(config_options) }
14
16
  let(:client) { Payoneer::Client.new(configuration) }
15
17
 
16
18
  describe '#status' do
@@ -18,7 +20,7 @@ describe Payoneer::Client do
18
20
  let(:xml) { "<?xml version='1.0' encoding='ISO-8859-1' ?><PayoneerResponse><Status>000</Status><Description>Echo Ok - All systems are up.</Description></PayoneerResponse>" }
19
21
 
20
22
  it 'returns a successful response' do
21
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'Echo')).and_return(response)
23
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'Echo')).and_return(response)
22
24
  response = client.status
23
25
  expect(response.ok?).to be_truthy
24
26
  expect(response.body['Description']).to eq('Echo Ok - All systems are up.')
@@ -29,7 +31,7 @@ describe Payoneer::Client do
29
31
  let(:xml) { "<?xml version='1.0' encoding='ISO-8859-1' ?><PayoneerResponse><Code>999</Code><Description>Echo Failure - All systems are down.</Description></PayoneerResponse>" }
30
32
 
31
33
  it 'returns a failure response' do
32
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'Echo')).and_return(response)
34
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'Echo')).and_return(response)
33
35
  response = client.status
34
36
  expect(response.ok?).to be_falsey
35
37
  expect(response.body).to eq('Echo Failure - All systems are down.')
@@ -45,7 +47,7 @@ describe Payoneer::Client do
45
47
  end
46
48
 
47
49
  it 'raises an error' do
48
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'Echo')).and_return(response)
50
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'Echo')).and_return(response)
49
51
  expect { client.status }.to raise_error(Payoneer::ResponseError)
50
52
  end
51
53
  end
@@ -55,7 +57,7 @@ describe Payoneer::Client do
55
57
  let(:xml) { "<?xml version='1.0' encoding='ISO-8859-1' ?><PayoneerResponse><Version>4.15</Version></PayoneerResponse>" }
56
58
 
57
59
  it 'generates the correct request' do
58
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'GetVersion')).and_return(response)
60
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'GetVersion')).and_return(response)
59
61
  response = client.version
60
62
  expect(response.ok?).to be_truthy
61
63
  expect(response.body['Version']).to eq('4.15')
@@ -66,7 +68,7 @@ describe Payoneer::Client do
66
68
  let(:xml) { '<?xml version="1.0" encoding="UTF-8" ?><PayoneerToken><Token>https://payouts.sandbox.payoneer.com/partners/lp.aspx?token=fake-token</Token></PayoneerToken>' }
67
69
 
68
70
  it 'generates the correct request' do
69
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'GetToken')).and_return(response)
71
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'GetToken')).and_return(response)
70
72
  response = client.payee_signup_url('test')
71
73
  expect(response.ok?).to be_truthy
72
74
  expect(response.body).to eq('https://payouts.sandbox.payoneer.com/partners/lp.aspx?token=fake-token')
@@ -77,7 +79,7 @@ describe Payoneer::Client do
77
79
  let(:xml) { '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><GetPayeeDetails><Payee><FirstName>Foo</FirstName><LastName>Bar</LastName><Email>foo@bar.com</Email><Address1>185 Berry Street</Address1><Address2>Suite 2400</Address2><City>San Francisco</City><State>CA</State><Zip>94107</Zip><Country>US</Country><Phone></Phone><Mobile>15552223333</Mobile><PayeeStatus>Active</PayeeStatus><PayOutMethod>Prepaid Card</PayOutMethod><Cards><Card><CardID>123456789</CardID><Currency>USD</Currency><ActivationStatus>Card Issued, Not Activated</ActivationStatus><CardShipDate>11/25/2015</CardShipDate><CardStatus>Active</CardStatus></Card></Cards><RegDate>10/9/2017 7:58:44 PM</RegDate></Payee><CompanyDetails><CompanyName></CompanyName></CompanyDetails></GetPayeeDetails>' }
78
80
 
79
81
  it 'generates the correct request' do
80
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, hash_including(mname: 'GetPayeeDetails')).and_return(response)
82
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: hash_including(mname: 'GetPayeeDetails')).and_return(response)
81
83
  response = client.payee_details('fake-payee-id')
82
84
  expect(response.ok?).to be_truthy
83
85
  expect(response.body).to include('FirstName' => 'Foo', 'LastName' => 'Bar')
@@ -129,7 +131,7 @@ describe Payoneer::Client do
129
131
  end
130
132
 
131
133
  it 'generates the correct response' do
132
- expect(RestClient).to receive(:post).exactly(1).times.with(endpoint, params.to_json, headers).and_return(response)
134
+ expect(RestClient::Request).to receive(:execute).exactly(1).times.with(method: :post, url: endpoint, payload: params.to_json, headers: headers).and_return(response)
133
135
  response = client.expanded_payout(payee_id: payee_id, client_reference_id: client_reference_id, amount: amount, description: description, currency: currency, seller_id: seller_id, seller_name: seller_name, seller_url: seller_url, path: path, credentials: credentials)
134
136
  expect(response.ok?).to be_truthy
135
137
  expect(response.body).to include('payee_id' => payee_id, 'amount' => amount)
@@ -138,4 +140,14 @@ describe Payoneer::Client do
138
140
  expect(response.body['orders_report']['orders']).to include('path' => path)
139
141
  end
140
142
  end
143
+
144
+ describe 'configuration' do
145
+ let(:config_options) { default_config_options.merge(http_client_options: { verify_ssl: true }) }
146
+ let(:xml) { "<?xml version='1.0' encoding='ISO-8859-1' ?><PayoneerResponse><Status>000</Status><Description>Echo Ok - All systems are up.</Description></PayoneerResponse>" }
147
+
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
151
+ end
152
+ end
141
153
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payoneer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Estreich
8
+ - Todd Eichel
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
12
+ date: 2018-09-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -41,6 +42,7 @@ dependencies:
41
42
  description: Payoneer SDK for ruby.
42
43
  email:
43
44
  - chris@tophatter.com
45
+ - todd@tophatter.com
44
46
  executables:
45
47
  - payoneer-console
46
48
  extensions: []
@@ -86,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
88
  version: '0'
87
89
  requirements: []
88
90
  rubyforge_project:
89
- rubygems_version: 2.6.13
91
+ rubygems_version: 2.7.7
90
92
  signing_key:
91
93
  specification_version: 4
92
94
  summary: Payoneer SDK for ruby.