currency_cloud 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +31 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +2 -4
- data/Gemfile +0 -3
- data/LICENSE.md +16 -17
- data/README.md +5 -3
- data/Rakefile +12 -12
- data/currency_cloud.gemspec +9 -9
- data/examples/server.rb +7 -7
- data/lib/currency_cloud/client.rb +5 -1
- data/lib/currency_cloud/conversion.rb +15 -0
- data/lib/currency_cloud/conversion_cancel_result.rb +5 -0
- data/lib/currency_cloud/conversion_date_change_result.rb +5 -0
- data/lib/currency_cloud/conversion_split_result.rb +5 -0
- data/lib/currency_cloud/errors/api_error.rb +2 -2
- data/lib/currency_cloud/errors/error_utils.rb +4 -4
- data/lib/currency_cloud/errors/unexpected_error.rb +3 -3
- data/lib/currency_cloud/iban.rb +22 -0
- data/lib/currency_cloud/ibans.rb +6 -0
- data/lib/currency_cloud/payer_required_details.rb +5 -0
- data/lib/currency_cloud/payment.rb +10 -0
- data/lib/currency_cloud/payment_authorisation_result.rb +5 -0
- data/lib/currency_cloud/payment_dates.rb +5 -0
- data/lib/currency_cloud/payment_submission.rb +5 -0
- data/lib/currency_cloud/purpose_code.rb +5 -0
- data/lib/currency_cloud/reference.rb +20 -5
- data/lib/currency_cloud/request_handler.rb +1 -3
- data/lib/currency_cloud/response_handler.rb +7 -7
- data/lib/currency_cloud/session.rb +2 -3
- data/lib/currency_cloud/transfer.rb +8 -0
- data/lib/currency_cloud/version.rb +1 -1
- data/lib/currency_cloud/virtual_account.rb +22 -0
- data/lib/currency_cloud/virtual_accounts.rb +6 -0
- data/spec/currency_cloud_spec.rb +9 -9
- data/spec/integration/authentication_spec.rb +2 -2
- data/spec/integration/conversions_spec.rb +94 -0
- data/spec/integration/error_utils_spec.rb +12 -12
- data/spec/integration/errors_spec.rb +84 -102
- data/spec/integration/ibans_spec.rb +42 -0
- data/spec/integration/payment_spec.rb +31 -0
- data/spec/integration/payments_spec.rb +67 -0
- data/spec/integration/reference_spec.rb +37 -14
- data/spec/integration/transfers_spec.rb +39 -0
- data/spec/integration/virtual_accounts_spec.rb +37 -0
- data/spec/spec_helper.rb +9 -1
- data/spec/support/vcr_cassettes/Authentication/can_be_closed.yml +1 -1
- data/spec/support/vcr_cassettes/Authentication/handles_session_timeout_error.yml +1 -1
- data/spec/support/vcr_cassettes/Authentication/happens_lazily.yml +1 -1
- data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/with_notes/has_a_non-empty_notes_attribute.yml +158 -0
- data/spec/support/vcr_cassettes/Conversions/can_cancel_conversion/without_notes/has_a_empty_notes_attribute.yml +157 -0
- data/spec/support/vcr_cassettes/Conversions/can_date_change_conversion.yml +157 -0
- data/spec/support/vcr_cassettes/Conversions/can_split_conversion.yml +157 -0
- data/spec/support/vcr_cassettes/Error/contains_full_details_for_api_error.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_a_bad_request.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_a_forbidden_request.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_an_internal_server_error.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_on_incorrect_authentication_details.yml +1 -1
- data/spec/support/vcr_cassettes/Error/is_raised_when_too_many_requests_have_been_issued.yml +1 -1
- data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_a_specific_subaccount.yml +109 -0
- data/spec/support/vcr_cassettes/IBANs/can_IBANs_for_subaccounts.yml +108 -0
- data/spec/support/vcr_cassettes/IBANs/can_find.yml +114 -0
- data/spec/support/vcr_cassettes/Payments/can_authorise/when_payment_ids_are_valid.yml +263 -0
- data/spec/support/vcr_cassettes/Payments/can_create.yml +155 -0
- data/spec/support/vcr_cassettes/Payments/can_get_the_submission.yml +205 -0
- data/spec/support/vcr_cassettes/Reference/can_retrieve_beneficiary_required_details.yml +77 -12
- data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +183 -22
- data/spec/support/vcr_cassettes/Reference/can_retrieve_currencies.yml +110 -22
- data/spec/support/vcr_cassettes/Reference/can_retrieve_payer_required_details.yml +103 -0
- data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_dates.yml +110 -0
- data/spec/support/vcr_cassettes/Reference/can_retrieve_payment_purpose_codes.yml +128 -0
- data/spec/support/vcr_cassettes/Reference/can_retrieve_settlement_accounts.yml +76 -11
- data/spec/support/vcr_cassettes/Settlements/can_add_conversion.yml +56 -6
- data/spec/support/vcr_cassettes/Settlements/can_release.yml +55 -5
- data/spec/support/vcr_cassettes/Settlements/can_remove_conversion.yml +55 -5
- data/spec/support/vcr_cassettes/Settlements/can_unrelease.yml +55 -5
- data/spec/support/vcr_cassettes/Transfers/can_create.yml +101 -0
- data/spec/support/vcr_cassettes/Transfers/can_find.yml +151 -0
- data/spec/support/vcr_cassettes/Transfers/can_retrieve.yml +151 -0
- data/spec/support/vcr_cassettes/VirtualAccounts/can_find.yml +108 -0
- data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_a_specific_subaccount.yml +108 -0
- data/spec/support/vcr_cassettes/VirtualAccounts/can_find_VANs_for_subaccounts.yml +108 -0
- metadata +82 -20
- data/Guardfile +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebec99730dd5705d4cf2c166f6df611617818e42
|
4
|
+
data.tar.gz: 397acffa929fd40cf630618f28540497bafd53e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff21d17e42f741459e92125e8551a6b93f5e9ee37d59af9dddd24182cbfbc185b9491fc6b39b9564ab94afcd1491ebc502e35ca2fa8019bcd88249a78b448394
|
7
|
+
data.tar.gz: 1e69916dc9465acbeadfead6d459c097b1281066ca984a2916d11678473e6a1a7390a2bb60c1e28ba5cceb8e19dd0726d82c70b79d69ddb952305ae0b824baf4
|
data/.gitignore
CHANGED
@@ -1,3 +1,34 @@
|
|
1
1
|
.DS_Store
|
2
|
+
|
2
3
|
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
.env
|
16
|
+
.byebug_history
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
3
29
|
Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015
|
3
|
+
Copyright (c) 2015-2018 Currencycloud
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
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:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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
|
21
|
+
THE SOFTWARE. OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
# Currencycloud
|
4
4
|
|
5
|
-
This is the official Ruby SDK for
|
6
|
-
|
5
|
+
This is the official Ruby SDK for the Currencycloud API. Additional documentation for each API endpoint can be found at [developer.currencycloud.com][docs].
|
6
|
+
|
7
|
+
If you have any queries or you require support, please contact our development team at development@currencycloud.com Please quote your login id in any correspondence as this makes it easier for us to locate your account and give you the support you need.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -91,7 +92,7 @@ platform: Ruby 1.9.3
|
|
91
92
|
request:
|
92
93
|
parameters:
|
93
94
|
login_id: non-existent-login-id
|
94
|
-
api_key:
|
95
|
+
api_key: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
|
95
96
|
verb: post
|
96
97
|
url: https://devapi.currencycloud.com/v2/authenticate/api
|
97
98
|
response:
|
@@ -130,6 +131,7 @@ Test cases can be run with: `bundle exec rspec`. There is also a `Guardfile` tha
|
|
130
131
|
is useful for continuously rerunning tests while you develop.
|
131
132
|
|
132
133
|
## Dependencies
|
134
|
+
|
133
135
|
* [HTTParty][httparty]
|
134
136
|
* [json][json]
|
135
137
|
|
data/Rakefile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
desc
|
1
|
+
desc 'Run an IRB session'
|
2
2
|
task :console do
|
3
|
-
exec
|
3
|
+
exec 'irb -I lib -r irb/completion -r currency_cloud'
|
4
4
|
end
|
5
5
|
|
6
6
|
def play
|
7
7
|
sleep 1
|
8
|
-
puts
|
8
|
+
puts '...'
|
9
9
|
IRB.conf[:MAIN_CONTEXT].irb
|
10
|
-
IRB.conf[:MAIN_CONTEXT].io.prompt =
|
10
|
+
IRB.conf[:MAIN_CONTEXT].io.prompt = 'HELLO'
|
11
11
|
end
|
12
12
|
|
13
|
-
desc
|
13
|
+
desc 'Run an IRB session in kiosk mode'
|
14
14
|
task :kiosk do
|
15
|
-
Thread.abort_on_exception=true
|
16
|
-
#exec "irb -I lib -r irb/completion -r currency_cloud -r currency_cloud/kiosk"
|
15
|
+
Thread.abort_on_exception = true
|
16
|
+
# exec "irb -I lib -r irb/completion -r currency_cloud -r currency_cloud/kiosk"
|
17
17
|
require 'irb'
|
18
18
|
IRB.setup nil
|
19
19
|
IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
|
@@ -22,9 +22,9 @@ task :kiosk do
|
|
22
22
|
@irb = IRB.irb nil, self
|
23
23
|
end
|
24
24
|
|
25
|
-
desc
|
25
|
+
desc 'Test and build gem'
|
26
26
|
task :build do
|
27
|
-
sh(
|
28
|
-
sh(
|
29
|
-
sh(
|
30
|
-
end
|
27
|
+
sh('rm -f currency_cloud*.gem')
|
28
|
+
sh('rspec')
|
29
|
+
sh('gem build currency_cloud.gemspec')
|
30
|
+
end
|
data/currency_cloud.gemspec
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
2
|
|
3
3
|
require 'currency_cloud/version'
|
4
4
|
|
5
|
-
|
5
|
+
Gem::Specification.new do |s|
|
6
6
|
s.name = 'currency_cloud'
|
7
7
|
s.version = CurrencyCloud::VERSION
|
8
8
|
s.summary = 'Ruby SDK for the Currency Cloud API'
|
9
|
-
s.description = 'Ruby SDK for the Currency Cloud API - https://
|
9
|
+
s.description = 'Ruby SDK for the Currency Cloud API - https://www.currencycloud.com/developers/overview/'
|
10
10
|
s.authors = ['Liam McAndrew', 'Richard Nienaber']
|
11
11
|
s.email = ['liam.mcandrew@currencycloud.com', 'richard.nienaber@currencycloud.com']
|
12
|
-
s.homepage = 'https://
|
12
|
+
s.homepage = 'https://github.com/Currencycloud/currencycloud-ruby/'
|
13
13
|
s.licenses = ['MIT']
|
14
14
|
s.required_ruby_version = '>= 1.9'
|
15
15
|
|
16
16
|
s.add_dependency('httparty', '0.14.0')
|
17
17
|
s.add_dependency('json', '~> 1.8')
|
18
18
|
|
19
|
-
s.add_development_dependency('rspec', '~> 3.1')
|
20
|
-
s.add_development_dependency('rake', '~> 10.3')
|
21
|
-
s.add_development_dependency('webmock', '~> 1.21')
|
22
|
-
s.add_development_dependency('vcr', '~> 2.9')
|
23
19
|
s.add_development_dependency('addressable', '<= 2.4.0')
|
20
|
+
s.add_development_dependency('rake', '~> 10.3')
|
21
|
+
s.add_development_dependency('rspec', '~> 3.1')
|
22
|
+
s.add_development_dependency('vcr', '~> 3.0.3')
|
23
|
+
s.add_development_dependency('webmock', '~> 2.3.2')
|
24
24
|
|
25
25
|
s.files = `git ls-files`.split("\n")
|
26
26
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
27
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
28
28
|
s.require_paths = ['lib']
|
29
29
|
end
|
data/examples/server.rb
CHANGED
@@ -3,13 +3,13 @@ require_relative 'currency_cloud'
|
|
3
3
|
require 'sinatra'
|
4
4
|
|
5
5
|
get '/conversion' do
|
6
|
-
conversion = CurrencyCloud::Conversion.create(
|
7
|
-
buy_currency: params[:buy_currency],
|
6
|
+
conversion = CurrencyCloud::Conversion.create(
|
7
|
+
buy_currency: params[:buy_currency],
|
8
8
|
sell_currency: params[:sell_currency],
|
9
|
-
amount: params[:amount],
|
10
|
-
fixed_side: 'buy',
|
11
|
-
reason: 'test',
|
9
|
+
amount: params[:amount],
|
10
|
+
fixed_side: 'buy',
|
11
|
+
reason: 'test',
|
12
12
|
term_agreement: true
|
13
|
-
|
13
|
+
)
|
14
14
|
"Conversion created: #{conversion.short_reference}"
|
15
|
-
end
|
15
|
+
end
|
@@ -4,5 +4,20 @@ module CurrencyCloud
|
|
4
4
|
|
5
5
|
resource :conversions
|
6
6
|
actions :create, :retrieve, :find
|
7
|
+
|
8
|
+
def cancel(params = {})
|
9
|
+
attrs = client.post("#{id}/cancel", params)
|
10
|
+
ConversionCancelResult.new(attrs)
|
11
|
+
end
|
12
|
+
|
13
|
+
def date_change(params)
|
14
|
+
attrs = client.post("#{id}/date_change", params)
|
15
|
+
ConversionDateChangeResult.new(attrs)
|
16
|
+
end
|
17
|
+
|
18
|
+
def split(params)
|
19
|
+
attrs = client.post("#{id}/split", params)
|
20
|
+
ConversionSplitResult.new(attrs)
|
21
|
+
end
|
7
22
|
end
|
8
23
|
end
|
@@ -33,7 +33,7 @@ module CurrencyCloud
|
|
33
33
|
errors = raw_response.parsed_response
|
34
34
|
@code = errors['error_code']
|
35
35
|
@messages = []
|
36
|
-
|
36
|
+
|
37
37
|
return unless errors['error_messages']
|
38
38
|
|
39
39
|
errors['error_messages'].each do |field, messages|
|
@@ -62,7 +62,7 @@ module CurrencyCloud
|
|
62
62
|
},
|
63
63
|
'errors' => messages.map(&:to_h)
|
64
64
|
}
|
65
|
-
"#{class_name}#{
|
65
|
+
"#{class_name}#{$INPUT_RECORD_SEPARATOR}#{YAML.dump(error_details)}"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -4,15 +4,15 @@ module CurrencyCloud
|
|
4
4
|
base = "ruby-#{RUBY_VERSION}"
|
5
5
|
implementation = case RUBY_ENGINE
|
6
6
|
when 'ruby' then ''
|
7
|
-
when 'jruby' then
|
8
|
-
when 'rbx' then
|
9
|
-
else
|
7
|
+
when 'jruby' then " (jruby-#{JRUBY_VERSION})"
|
8
|
+
when 'rbx' then " (rbx-#{Rubinius::VERSION})"
|
9
|
+
else " (#{RUBY_ENGINE})"
|
10
10
|
end
|
11
11
|
"#{base}#{implementation}"
|
12
12
|
end
|
13
13
|
|
14
14
|
REDACTED_PARAMS = [:api_key, :login_id, :token].freeze
|
15
|
-
REDACTED_STRING =
|
15
|
+
REDACTED_STRING = 'REDACTED'.freeze
|
16
16
|
|
17
17
|
def redacted_params(params)
|
18
18
|
redacted = params.dup
|
@@ -4,11 +4,11 @@ module CurrencyCloud
|
|
4
4
|
|
5
5
|
attr_reader :inner_error
|
6
6
|
|
7
|
-
def initialize(verb, route, params,
|
7
|
+
def initialize(verb, route, params, inner)
|
8
8
|
@verb = verb
|
9
9
|
@route = route
|
10
10
|
@params = redacted_params(params)
|
11
|
-
@inner_error =
|
11
|
+
@inner_error = inner
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_s
|
@@ -25,7 +25,7 @@ module CurrencyCloud
|
|
25
25
|
},
|
26
26
|
'inner_error' => inner_error.to_s
|
27
27
|
}
|
28
|
-
"#{class_name}#{
|
28
|
+
"#{class_name}#{$INPUT_RECORD_SEPARATOR}#{YAML.dump(error_details)}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module CurrencyCloud
|
2
|
+
class IBAN
|
3
|
+
include CurrencyCloud::Resource
|
4
|
+
|
5
|
+
resource :ibans
|
6
|
+
|
7
|
+
def self.find(params = {})
|
8
|
+
result = client.get('/', params)
|
9
|
+
IBANs.new(:ibans, self, result)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.for_subaccount(subaccount_id, params = {})
|
13
|
+
result = client.get("subaccounts/#{subaccount_id}", params)
|
14
|
+
IBANs.new(:ibans, self, result)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.for_subaccounts(params = {})
|
18
|
+
result = client.get('subaccounts/find', params)
|
19
|
+
IBANs.new(:ibans, self, result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -4,5 +4,15 @@ module CurrencyCloud
|
|
4
4
|
|
5
5
|
resource :payments
|
6
6
|
actions :create, :retrieve, :find, :delete, :update
|
7
|
+
|
8
|
+
def submission(params = {})
|
9
|
+
result = client.get("#{id}/submission", params)
|
10
|
+
PaymentSubmission.new(result)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.authorise(*ids)
|
14
|
+
result = client.post("authorise", payment_ids: ids)['authorisations']
|
15
|
+
result.map { |pa| PaymentAuthorisationResult.new(pa) }
|
16
|
+
end
|
7
17
|
end
|
8
18
|
end
|