payoneer_api_client 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9177ecafa6e938da0af2fc84e5309906c55c6aa
4
+ data.tar.gz: 5f44a0f12edd585633ad2c43a3a042c0ba51af36
5
+ SHA512:
6
+ metadata.gz: e9a611f3415d09f34427c5fe1951c3a3bef214f365d3150b7764d254214f74cf540a20589288bc962d0eb6d5e34c0f76c93bb3e53940e85e3dbcc818d96eaa17
7
+ data.tar.gz: e6a77aacb96443d6f852c549d97ebae0aac280a4e6a0d6275ac8eed0b501568edebba3af4bbb080d557228bf3e5cd74b663723417bdd06f40faa0528b1851a4f
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /Gemfile.lock
2
+ /test.rb
3
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ script: bundle exec rake spec
4
+ rvm:
5
+ - 2.3.1
6
+ - 2.4.1
7
+ - 2.4.2
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'pry'
8
+ gem 'rake'
9
+ end
10
+
11
+ group :test do
12
+ gem 'rspec'
13
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Kirill Holodyuk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # PayoneerApiClient
2
+
3
+ [![Build Status](https://travis-ci.org/Drengel1990/payoneer_api_client.svg)](https://travis-ci.org/Drengel1990/payoneer_api_client)
4
+
5
+ **_PayoneerApiClient_** - uses REST API payout services Payoneer.
6
+
7
+ Payoneer provides a complete and easy-to-implement solution for disbursing funds to
8
+ payees globally. Integrating the solution involves two steps: <br>
9
+ 1. Payee registration–Clients call `payees/login-link` or `payees/registration-link` to retrieve a unique URL for a payee to on-board Payoneer. On-boarding is implemented with client branded web pages that are hosted by Payoneer. <br>
10
+ 2. Submitting payment instructions to Payoneer,via one of two supported interfaces: <br><br>
11
+ 2.1 Automated interface: Clients can implement the REST HTTPS Request/Response interface for automating data submission including payment instructions and retrieving information. The REST APIs are described in section 4 of this document. Credentials for submitting API calls to sandbox and production environments will be provided during account setup. <br><br>
12
+ 2.2 Manual interface: Clients can use the Payoneer Administration Console to manually submit payment instructions and other data to Payoneer’s system and to access reports. The Payments tab in the console supports initiating single payments and uploading payment batch files to Payoneer. <br>
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'payoneer_api_client'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install payoneer_api_client
29
+
30
+ ## Usage
31
+
32
+ ```ruby
33
+
34
+ require 'payoneer_api_client'
35
+
36
+ PayoneerApiClient.configure do |conf|
37
+ conf.environment = 'development'
38
+ conf.partner_id = 'XXXXXXXX'
39
+ conf.partner_username = 'XXXXXXXX'
40
+ conf.partner_api_password = 'XXXXXXXX'
41
+ end
42
+
43
+ # Echo
44
+ PayoneerApiClient::System.status.ok?
45
+ => true
46
+
47
+ # Query Account Balance
48
+ PayoneerApiClient::Balance.status.other
49
+ => {"balance"=>212.68, "currency"=>"USD", "fees_due"=>0.0}
50
+
51
+ # Get Version
52
+ PayoneerApiClient::ApiVersion.status.other
53
+ => {"version"=>"4.18"}
54
+
55
+ # Create Login Link
56
+ PayoneerApiClient::Login.create_url('ID123', 'ABC123', 'https://www.yoursite.com').other
57
+ => {"login_link"=>"https://payouts.sandbox.payoneer.com/partners/lp.aspx?token=0a7ece12cfa64ea1baa66c0c778XXXXXXXXXXXX"}
58
+
59
+ # Create Registration Link
60
+ PayoneerApiClient::Registration.create_url('ID124', 'ABC124', 'https://www.yoursite.com').other
61
+ => {"registration_link"=>"https://payouts.sandbox.payoneer.com/partners/lp.aspx?token=eaad141d0123448a820b6dc926XXXXXXXXXXXXX"}
62
+
63
+ # Get Payee Status
64
+ PayoneerApiClient::PayeeStatus.status('ID123').other
65
+ => {"status"=>"ACTIVE"}
66
+
67
+ # Get Payee Details
68
+ PayoneerApiClient::PayeeDetails.status('ID123').other
69
+ => {"type"=>"INDIVIDUAL", "status"=>"ACTIVE", "registration_date"=>"2016-01-22", "contact"=>{"first_name"=>"Test", "last_name"=>"Test", "email"=>"test@gmail.com", "mobile"=>"XXXXXXXXXXX", "phone"=>""}, "address"=>{"country"=>"XX", "state"=>"", "zip_code"=>"XXXXX", "address_line_1"=>"Test", "address_line_2"=>"Test", "city"=>"Test"}, "payout_method"=>{"type"=>"BANK", "currency"=>"USD"}}
70
+
71
+ # Submit Payout
72
+ pay = PayoneerApiClient::Payout.new({
73
+ payee_id: 'ID123',
74
+ amount: 25.22,
75
+ client_reference_id: 'test123456',
76
+ description: 'TEST',
77
+ currency: 'USD'
78
+ })
79
+ puts pay.send_payouts.other
80
+ => {"payout_id"=>"9023269", "amount"=>25.22, "currency"=>"USD"}
81
+
82
+ # Cancel Payout
83
+ PayoneerApiClient::Payout.cancel('test123456').other
84
+ => {"payout_id"=>"9023269"}
85
+
86
+ # Get Payout Details
87
+ PayoneerApiClient::Payout.details('test123456').other
88
+ => {"payout_id"=>"9023269", "status"=>"Cancelled", "payee_id"=>"ID123", "payout_date"=>"2018-01-24T08:40:06.053", "amount"=>25.22, "currency"=>"USD"}
89
+
90
+ # Get Single Reports
91
+ PayoneerApiClient::Reports.single_payee('ID123').other
92
+ => {"payee_id"=>"ID123", "status"=>"Active", "registration_date"=>"2018-01-19", "payout_method"=>"iACH", "company"=>{}, "total_amount"=>282.08, "payouts"=>[{"client_reference_id"=>"ABC123", "date"=>"2018-01-23T09:21:28", "amount"=>55.1, "currency"=>"USD", "description"=>"TEST", "status"=>"Funded"}, {"client_reference_id"=>"test1234", "date"=>"2018-01-24T08:12:30", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Funded"}, {"client_reference_id"=>"1234tttt", "date"=>"2018-01-23T02:10:01", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test1234567890", "date"=>"2018-01-24T07:54:32", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test12", "date"=>"2018-01-24T08:09:20", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test123456", "date"=>"2018-01-24T08:40:06", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"1234tttt", "date"=>"2018-01-23T02:17:31", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment 1234tttt refunded", "status"=>"Refund"}, {"client_reference_id"=>"test1234567890", "date"=>"2018-01-24T07:54:33", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test1234567890 refunded", "status"=>"Refund"}, {"client_reference_id"=>"test12", "date"=>"2018-01-24T08:09:21", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test12 refunded", "status"=>"Refund"}, {"client_reference_id"=>"test123456", "date"=>"2018-01-24T08:41:03", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test123456 refunded", "status"=>"Refund"}]}
93
+
94
+
95
+ # Get Reports
96
+ start_date = Date.today.prev_month.strftime('%Y-%m-%d')
97
+ end_date = Date.today.strftime('%Y-%m-%d')
98
+
99
+ PayoneerApiClient::Reports.payee_status(start_date, end_date).other
100
+ => {"payees"=>[{"payee_id"=>"ID123", "status"=>"Active", "registration_date"=>"2018-01-19", "payout_method"=>"BANK", "total_amount"=>282.08, "payouts"=>[{"client_reference_id"=>"ABC123", "date"=>"2018-01-23T09:21:28", "amount"=>55.1, "currency"=>"USD", "description"=>"TEST", "status"=>"Funded"}, {"client_reference_id"=>"test1234", "date"=>"2018-01-24T08:12:30", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Funded"}, {"client_reference_id"=>"1234tttt", "date"=>"2018-01-23T02:10:01", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test1234567890", "date"=>"2018-01-24T07:54:32", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test12", "date"=>"2018-01-24T08:09:20", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"test123456", "date"=>"2018-01-24T08:40:06", "amount"=>25.22, "currency"=>"USD", "description"=>"TEST", "status"=>"Cancelled"}, {"client_reference_id"=>"1234tttt", "date"=>"2018-01-23T02:17:31", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment 1234tttt refunded", "status"=>"Refund"}, {"client_reference_id"=>"test1234567890", "date"=>"2018-01-24T07:54:33", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test1234567890 refunded", "status"=>"Refund"}, {"client_reference_id"=>"test12", "date"=>"2018-01-24T08:09:21", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test12 refunded", "status"=>"Refund"}, {"client_reference_id"=>"test123456", "date"=>"2018-01-24T08:41:03", "amount"=>25.22, "currency"=>"USD", "description"=>"Payment test123456 refunded", "status"=>"Refund"}]}]}
101
+ ```
102
+
103
+ ## Contributing
104
+
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Drengel1990/payoneer_api_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106
+
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'payoneer_api_client'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,74 @@
1
+ require 'rest-client'
2
+ require 'json/ext'
3
+
4
+
5
+ # Version
6
+ require 'payoneer_api_client/version'
7
+
8
+ # Configuration
9
+ require 'payoneer_api_client/configuration'
10
+
11
+ # Resources
12
+ require 'payoneer_api_client/balance'
13
+ require 'payoneer_api_client/api_version'
14
+ require 'payoneer_api_client/system'
15
+ require 'payoneer_api_client/response'
16
+ require 'payoneer_api_client/reports'
17
+ require 'payoneer_api_client/registration'
18
+ require 'payoneer_api_client/payout'
19
+ require 'payoneer_api_client/payee_status'
20
+ require 'payoneer_api_client/payee_details'
21
+ require 'payoneer_api_client/login'
22
+
23
+ # Errors
24
+ require 'payoneer_api_client/errors/global_error'
25
+ require 'payoneer_api_client/errors/configuration_error'
26
+
27
+
28
+ module PayoneerApiClient
29
+
30
+ METHOD_NAME = { balance: 'balance',
31
+ system: 'echo',
32
+ version: 'api-version',
33
+ login: 'payees/login-link',
34
+ registration: 'payees/registration-link',
35
+ payouts: 'payouts',
36
+ report_single: 'reports/payee_details',
37
+ report_to_date: 'reports/payees_status' }.freeze
38
+
39
+ PAYOUT_METHODS = { prepaid_card: 'PREPAID_CARD', bank: 'BANK', paypal: 'PAYPAL' }.freeze
40
+
41
+ RESP_FIELD = { code: 'code', desc: 'description', audit: 'audit_id' }.freeze
42
+
43
+ FORMAT_DATE = '%Y-%m-%d'
44
+
45
+ class << self
46
+
47
+ def configure
48
+ yield(configuration)
49
+ end
50
+
51
+ def make_api_request(method_name, method = :post, params = {})
52
+ configuration.validate!
53
+ begin
54
+ response = RestClient::Request.execute(method: method,
55
+ url: build_url(method_name),
56
+ user: configuration.partner_username,
57
+ password: configuration.partner_api_password,
58
+ headers: { accept: :json, content_type: :json },
59
+ payload: params.to_json)
60
+ rescue RestClient::Exception => e
61
+ response = e.response
62
+ end
63
+ Response.new(JSON.parse(response))
64
+ end
65
+
66
+ def configuration
67
+ @configuration ||= Configuration.new
68
+ end
69
+
70
+ def build_url(method_name)
71
+ "#{configuration.api_url}/#{method_name}"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,11 @@
1
+ module PayoneerApiClient
2
+
3
+ class ApiVersion
4
+ class << self
5
+ def status
6
+ PayoneerApiClient.make_api_request(METHOD_NAME[:version], :get)
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ module PayoneerApiClient
2
+
3
+ class Balance
4
+ class << self
5
+ def status
6
+ PayoneerApiClient.make_api_request(METHOD_NAME[:balance], :get)
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,33 @@
1
+ module PayoneerApiClient
2
+
3
+ class Configuration
4
+
5
+ DEVELOPMENT_ENVIRONMENT = 'development'
6
+ PRODUCTION_ENVIRONMENT = 'production'
7
+ DEVELOPMENT_API_URL = 'https://api.sandbox.payoneer.com/v2/programs'
8
+ PRODUCTION_API_URL = 'https://api.payoneer.com/v2/programs'
9
+
10
+ attr_accessor :environment, :partner_id, :partner_username, :partner_api_password
11
+
12
+ def initialize
13
+ @environment = DEVELOPMENT_ENVIRONMENT
14
+ end
15
+
16
+ def production?
17
+ environment == PRODUCTION_ENVIRONMENT
18
+ end
19
+
20
+ def api_url
21
+ create_url(production? ? PRODUCTION_API_URL : DEVELOPMENT_API_URL)
22
+ end
23
+
24
+ def create_url(url)
25
+ "#{url}/#{partner_id}"
26
+ end
27
+
28
+ def validate!
29
+ raise Errors::ConfigurationError unless partner_id && partner_username && partner_api_password
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,9 @@
1
+ module PayoneerApiClient
2
+ module Errors
3
+ class ConfigurationError < StandardError
4
+ def initialize
5
+ super 'Not all config vars were set. Payoneer requires partner_id, partner_username, and partner_api_password.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module PayoneerApiClient
2
+ module Errors
3
+ class GlobalError < StandardError; end
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module PayoneerApiClient
2
+
3
+ class Login
4
+ class << self
5
+ def create_url(payee_id, client_session = nil, url = nil, time = 10)
6
+ params = {
7
+ payee_id: payee_id,
8
+ client_session_id: client_session,
9
+ redirect_url: url,
10
+ redirect_time: time
11
+ }
12
+ PayoneerApiClient.make_api_request(METHOD_NAME[:login], :post, params)
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ module PayoneerApiClient
2
+
3
+ class PayeeDetails
4
+ class << self
5
+ def status(payee_id)
6
+ PayoneerApiClient.make_api_request("payees/#{payee_id}/details", :get)
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ module PayoneerApiClient
2
+
3
+ class PayeeStatus
4
+ class << self
5
+ def status(payee_id)
6
+ PayoneerApiClient.make_api_request("payees/#{payee_id}/status", :get)
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,64 @@
1
+ module PayoneerApiClient
2
+
3
+ class Payout
4
+ attr_reader :payee_id, :amount, :client_reference_id
5
+
6
+ def initialize(pr = {})
7
+ @payee_id ||= pr[:payee_id]
8
+ @amount ||= pr[:amount]
9
+ @client_reference_id ||= pr[:client_reference_id]
10
+ @description ||= pr[:description]
11
+ @payout_date ||= pr[:payout_date]
12
+ @currency ||= pr[:currency]
13
+ @group_id ||= pr[:group_id]
14
+ end
15
+
16
+ def send_payouts
17
+ PayoneerApiClient.make_api_request(METHOD_NAME[:payouts], :post, params_payout) if payouts_valid?
18
+ end
19
+
20
+ def payouts_valid?
21
+ if @payee_id.nil? && @amount.nil? && @client_reference_id.nil?
22
+ show_error
23
+ else
24
+ true
25
+ end
26
+ end
27
+
28
+ class << self
29
+ def details(client_reference_id)
30
+ PayoneerApiClient.make_api_request("payouts/#{client_reference_id}", :get)
31
+ end
32
+
33
+ def cancel(client_reference_id)
34
+ PayoneerApiClient.make_api_request("payouts/#{client_reference_id}/cancel", :post)
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def params_payout(pr = {})
41
+ pr[:payee_id] = @payee_id unless @payee_id.nil?
42
+ pr[:amount] = normal_amount
43
+ pr[:client_reference_id] = @client_reference_id unless @client_reference_id.nil?
44
+ pr[:description] = @description unless @description.nil?
45
+ pr[:payout_date] = normal_payout_date
46
+ pr[:currency] = @currency unless @currency.nil?
47
+ pr[:group_id] = @group_id unless @group_id.nil?
48
+ pr
49
+ end
50
+
51
+ def normal_payout_date
52
+ @payout_date.nil? ? Time.now.strftime(FORMAT_DATE) : @payout_date
53
+ end
54
+
55
+ def normal_amount
56
+ format('%.2f', @amount)
57
+ end
58
+
59
+ def show_error
60
+ raise Errors::GlobalError, 'Please input field payee_id, amount and client_reference_id'
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,18 @@
1
+ module PayoneerApiClient
2
+
3
+ class Registration
4
+ class << self
5
+ def create_url(payee_id, client_session = nil, url = nil, time = 10, payout_methods = PAYOUT_METHODS.values)
6
+ params = {
7
+ payee_id: payee_id,
8
+ client_session_id: client_session,
9
+ redirect_url: url,
10
+ redirect_time: time,
11
+ payout_methods_list: payout_methods
12
+ }
13
+ PayoneerApiClient.make_api_request(METHOD_NAME[:registration], :post, params)
14
+ end
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,39 @@
1
+ module PayoneerApiClient
2
+
3
+ class Reports
4
+ class << self
5
+ def single_payee(payee_id)
6
+ PayoneerApiClient.make_api_request("#{METHOD_NAME[:report_single]}?payee_id=#{payee_id}", :get)
7
+ end
8
+
9
+ def payee_status(start_date, end_date)
10
+ @start_date = start_date
11
+ @end_date = end_date
12
+ PayoneerApiClient.make_api_request(build_url, :get)
13
+ end
14
+
15
+ def validate_date?(date)
16
+ formats = [FORMAT_DATE]
17
+ formats.each do |format|
18
+ begin
19
+ return true if Date.strptime(date, format)
20
+ rescue StandardError
21
+ error_message('Date you have entered is invalid, please enter a valid date')
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def build_url
29
+ return unless validate_date?(@start_date) && validate_date?(@end_date)
30
+ "#{METHOD_NAME[:report_to_date]}?start_date=#{@start_date}&end_date=#{@end_date}"
31
+ end
32
+
33
+ def error_message(msg)
34
+ raise Errors::GlobalError, msg
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,28 @@
1
+ module PayoneerApiClient
2
+
3
+ class Response
4
+ attr_reader :code, :description, :other
5
+
6
+ def initialize(res)
7
+ @code = res[RESP_FIELD[:code]]
8
+ @description = res[RESP_FIELD[:desc]]
9
+ @other = res.delete_if { |v| RESP_FIELD.values.include?(v) }
10
+ errors unless @code.zero?
11
+ end
12
+
13
+ def ok?
14
+ code.zero?
15
+ end
16
+
17
+ def ==(other)
18
+ code == other.code && description == other.description
19
+ end
20
+
21
+ private
22
+
23
+ def errors
24
+ raise Errors::GlobalError, "#{ @description }: #{ @other['hint'] }"
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,11 @@
1
+ module PayoneerApiClient
2
+
3
+ class System
4
+ class << self
5
+ def status
6
+ PayoneerApiClient.make_api_request(METHOD_NAME[:system], :get)
7
+ end
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,3 @@
1
+ module PayoneerApiClient
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'payoneer_api_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'payoneer_api_client'
8
+ spec.version = PayoneerApiClient::VERSION
9
+ spec.authors = ['Kirill Holodyuk']
10
+ spec.email = ['kirill.holodyuk@gmail.com']
11
+
12
+ spec.summary = 'Payoneer SDK for ruby.'
13
+ spec.description = 'Payoneer SDK for ruby.'
14
+ spec.homepage = 'https://github.com/Drengel1990/payoneer_api_client'
15
+ spec.license = 'MIT'
16
+
17
+ spec.extra_rdoc_files = ['README.md']
18
+
19
+ spec.required_ruby_version = '~> 2.2'
20
+
21
+ spec.add_dependency 'rest-client', '~> 2.0'
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.16'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: payoneer_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kirill Holodyuk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Payoneer SDK for ruby.
70
+ email:
71
+ - kirill.holodyuk@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/payoneer_api_client.rb
86
+ - lib/payoneer_api_client/api_version.rb
87
+ - lib/payoneer_api_client/balance.rb
88
+ - lib/payoneer_api_client/configuration.rb
89
+ - lib/payoneer_api_client/errors/configuration_error.rb
90
+ - lib/payoneer_api_client/errors/global_error.rb
91
+ - lib/payoneer_api_client/login.rb
92
+ - lib/payoneer_api_client/payee_details.rb
93
+ - lib/payoneer_api_client/payee_status.rb
94
+ - lib/payoneer_api_client/payout.rb
95
+ - lib/payoneer_api_client/registration.rb
96
+ - lib/payoneer_api_client/reports.rb
97
+ - lib/payoneer_api_client/response.rb
98
+ - lib/payoneer_api_client/system.rb
99
+ - lib/payoneer_api_client/version.rb
100
+ - payoneer_api_client.gemspec
101
+ homepage: https://github.com/Drengel1990/payoneer_api_client
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '2.2'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.6.14
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Payoneer SDK for ruby.
125
+ test_files: []