currency_cloud 0.7.1 → 0.7.2
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/.gitignore +1 -0
- data/Gemfile +1 -2
- data/README.md +3 -3
- data/currency_cloud.gemspec +3 -3
- data/lib/currency_cloud.rb +2 -2
- data/lib/currency_cloud/{resources/account.rb → account.rb} +4 -2
- data/lib/currency_cloud/actions.rb +13 -0
- data/lib/currency_cloud/actions/create.rb +4 -3
- data/lib/currency_cloud/actions/current.rb +3 -2
- data/lib/currency_cloud/actions/delete.rb +7 -12
- data/lib/currency_cloud/actions/find.rb +5 -7
- data/lib/currency_cloud/actions/instance_delete.rb +10 -0
- data/lib/currency_cloud/actions/retrieve.rb +5 -4
- data/lib/currency_cloud/actions/save.rb +5 -4
- data/lib/currency_cloud/actions/update.rb +6 -2
- data/lib/currency_cloud/{resources/balance.rb → balance.rb} +5 -3
- data/lib/currency_cloud/{resources/beneficiary.rb → beneficiary.rb} +7 -8
- data/lib/currency_cloud/client.rb +27 -0
- data/lib/currency_cloud/{resources/contact.rb → contact.rb} +4 -2
- data/lib/currency_cloud/{resources/conversion.rb → conversion.rb} +4 -6
- data/lib/currency_cloud/conversion_dates.rb +5 -0
- data/lib/currency_cloud/currency.rb +5 -0
- data/lib/currency_cloud/pagination.rb +1 -4
- data/lib/currency_cloud/{resources/payer.rb → payer.rb} +4 -2
- data/lib/currency_cloud/{resources/payment.rb → payment.rb} +4 -5
- data/lib/currency_cloud/rate.rb +21 -0
- data/lib/currency_cloud/rates.rb +5 -0
- data/lib/currency_cloud/reference.rb +26 -0
- data/lib/currency_cloud/request_handler.rb +9 -10
- data/lib/currency_cloud/resource.rb +52 -50
- data/lib/currency_cloud/response_handler.rb +6 -8
- data/lib/currency_cloud/session.rb +19 -19
- data/lib/currency_cloud/{resources/settlement.rb → settlement.rb} +20 -16
- data/lib/currency_cloud/settlement_account.rb +5 -0
- data/lib/currency_cloud/{resources/transaction.rb → transaction.rb} +4 -3
- data/lib/currency_cloud/version.rb +2 -4
- data/spec/currency_cloud/resource_spec.rb +7 -5
- data/spec/integration/actions_spec.rb +3 -3
- data/spec/integration/authentication_spec.rb +3 -3
- data/spec/integration/errors_spec.rb +6 -6
- data/spec/integration/rates_spec.rb +3 -3
- data/spec/integration/reference_spec.rb +5 -5
- data/spec/integration/settlements_spec.rb +8 -8
- metadata +20 -15
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/lib/currency_cloud/resources/rate.rb +0 -21
- data/lib/currency_cloud/resources/reference.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56244f4c79912b074416b099f75d2d8b6b64fae8
|
4
|
+
data.tar.gz: 9e0a5976808d20873f383eface2acecb96a17554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a46e98ba3b1f58a7ea720d6637fd90f9d000b898365fa47328b923d527ac1ff8ab164a326008489889e4d9ac7196a47365446e3e8cd1001fb7875358a909237
|
7
|
+
data.tar.gz: 6d22fdca021e1c1eded5def2e69ae701fa77bdbf9b4c68ff0e2cf723203fbe6437b91e8b4d4d27b8f064e14a1d60f4d70db7e1f54cf7796ceefca9b999efe0d6
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Currency Cloud
|
4
4
|
|
5
|
-
This is the official Ruby SDK for v2 of Currency Cloud's API. Additional documentation
|
5
|
+
This is the official Ruby SDK for v2 of Currency Cloud's API. Additional documentation
|
6
6
|
for each API endpoint can be found at [connect.currencycloud.com][connect]. If you have any queries or you require support, please contact our implementation team at implementation@currencycloud.com.
|
7
7
|
|
8
8
|
## Installation
|
@@ -59,7 +59,7 @@ balances = CurrencyCloud::Balance.find
|
|
59
59
|
```
|
60
60
|
|
61
61
|
## On Behalf Of
|
62
|
-
If you want to make calls on behalf of another user (e.g. someone who has a sub-account with you), you
|
62
|
+
If you want to make calls on behalf of another user (e.g. someone who has a sub-account with you), you
|
63
63
|
can execute certain commands 'on behalf of' the user's contact_id. Here is an example:
|
64
64
|
|
65
65
|
```ruby
|
@@ -126,7 +126,7 @@ error in any correspondence can be very helpful.
|
|
126
126
|
|
127
127
|
# Development
|
128
128
|
|
129
|
-
Test cases can be run with: `bundle exec rspec`. There is also a `Guardfile` that
|
129
|
+
Test cases can be run with: `bundle exec rspec`. There is also a `Guardfile` that
|
130
130
|
is useful for continuously rerunning tests while you develop.
|
131
131
|
|
132
132
|
## Dependencies
|
data/currency_cloud.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'currency_cloud/version'
|
|
4
4
|
|
5
5
|
spec = Gem::Specification.new do |s|
|
6
6
|
s.name = 'currency_cloud'
|
7
|
-
s.version = CurrencyCloud::
|
7
|
+
s.version = CurrencyCloud::VERSION
|
8
8
|
s.summary = 'Ruby SDK for the Currency Cloud API'
|
9
9
|
s.description = 'Ruby SDK for the Currency Cloud API - https://connect.currencycloud.com/'
|
10
10
|
s.authors = ['Liam McAndrew', 'Richard Nienaber']
|
@@ -15,7 +15,7 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency('httparty', '~> 0.13')
|
17
17
|
s.add_dependency('json', '~> 1.8')
|
18
|
-
|
18
|
+
|
19
19
|
s.add_development_dependency('rspec', '~> 3.1')
|
20
20
|
s.add_development_dependency('rake', '~> 10.3')
|
21
21
|
s.add_development_dependency('webmock', '~> 1.21')
|
@@ -25,4 +25,4 @@ spec = Gem::Specification.new do |s|
|
|
25
25
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
26
26
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
27
|
s.require_paths = ['lib']
|
28
|
-
end
|
28
|
+
end
|
data/lib/currency_cloud.rb
CHANGED
@@ -13,7 +13,7 @@ module CurrencyCloud
|
|
13
13
|
class << self
|
14
14
|
attr_accessor :environment, :login_id, :api_key, :token
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def self.session
|
18
18
|
@session ||= CurrencyCloud::Session.new(environment, login_id, api_key, token)
|
19
19
|
end
|
@@ -22,7 +22,7 @@ module CurrencyCloud
|
|
22
22
|
@session.close if @session
|
23
23
|
true
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.reset_session
|
27
27
|
@session = nil
|
28
28
|
@token = nil
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "actions/create"
|
2
|
+
require_relative "actions/current"
|
3
|
+
require_relative "actions/delete"
|
4
|
+
require_relative "actions/find"
|
5
|
+
require_relative "actions/instance_delete"
|
6
|
+
require_relative "actions/retrieve"
|
7
|
+
require_relative "actions/save"
|
8
|
+
require_relative "actions/update"
|
9
|
+
|
10
|
+
module CurrencyCloud
|
11
|
+
module Actions
|
12
|
+
end
|
13
|
+
end
|
@@ -1,21 +1,16 @@
|
|
1
1
|
module CurrencyCloud
|
2
2
|
module Actions
|
3
|
-
|
4
3
|
module Delete
|
4
|
+
def self.extended(base)
|
5
|
+
base.send(:include, InstanceDelete) # Private before Ruby 2.1
|
6
|
+
end
|
5
7
|
|
6
8
|
# TODO: Set state to be deleted
|
7
9
|
# TODO: Disable all actionable methods / freeze?
|
8
|
-
|
9
10
|
def delete(id)
|
10
|
-
post("#{id}/delete")
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
module InstanceDelete
|
15
|
-
def delete
|
16
|
-
self.class.delete(id)
|
17
|
-
self
|
18
|
-
end
|
11
|
+
attrs = client.post("#{id}/delete")
|
12
|
+
new(attrs)
|
13
|
+
end
|
19
14
|
end
|
20
15
|
end
|
21
|
-
end
|
16
|
+
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module CurrencyCloud
|
2
2
|
module Actions
|
3
|
-
|
3
|
+
|
4
4
|
module Find
|
5
5
|
|
6
6
|
def find(params={})
|
7
|
-
response =
|
7
|
+
response = client.get("find", params)
|
8
8
|
mixin_class.new(self.resource, self, response)
|
9
9
|
end
|
10
|
-
|
11
|
-
def first(params={})
|
12
|
-
entities = find((params || {}).merge(per_page: 1))
|
13
|
-
return nil if entities.empty?
|
14
10
|
|
11
|
+
def first(params={})
|
12
|
+
entities = find(params.merge(per_page: 1)) || []
|
15
13
|
entities.first
|
16
14
|
end
|
17
15
|
|
@@ -24,4 +22,4 @@ module CurrencyCloud
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
27
|
-
end
|
25
|
+
end
|
@@ -3,12 +3,13 @@ module CurrencyCloud
|
|
3
3
|
module Save
|
4
4
|
def save
|
5
5
|
return self if changed_attributes.empty?
|
6
|
-
|
7
|
-
params =
|
8
|
-
post(id, params)
|
6
|
+
|
7
|
+
params = attributes.select { |attr| changed_attributes.include?(attr) }
|
8
|
+
attrs = client.post(id, params)
|
9
9
|
changed_attributes.clear
|
10
|
+
self.attributes = attrs
|
10
11
|
self
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
14
|
-
end
|
15
|
+
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
module CurrencyCloud
|
2
2
|
module Actions
|
3
3
|
module Update
|
4
|
+
def self.extended(base)
|
5
|
+
base.send(:include, Save) # Private before Ruby 2.1
|
6
|
+
end
|
4
7
|
|
5
8
|
# TODO: Add .save instance method, which calls update on changed attributes
|
6
9
|
|
7
10
|
def update(id, params)
|
8
|
-
post("#{id}", params)
|
11
|
+
attrs = client.post("#{id}", params)
|
12
|
+
new(attrs)
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
12
|
-
end
|
16
|
+
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module CurrencyCloud
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Beneficiary
|
3
|
+
include CurrencyCloud::Resource
|
4
|
+
|
5
5
|
resource :beneficiaries
|
6
|
-
|
7
6
|
actions :create, :retrieve, :find, :update, :delete
|
8
|
-
|
7
|
+
|
9
8
|
def self.validate(params)
|
10
|
-
post(
|
11
|
-
end
|
9
|
+
new(client.post("validate", params))
|
10
|
+
end
|
12
11
|
end
|
13
|
-
end
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CurrencyCloud
|
2
|
+
class Client
|
3
|
+
def initialize(resource)
|
4
|
+
@resource = resource
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(url, params={})
|
8
|
+
request.get(build_url(url), params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def post(url, params={})
|
12
|
+
request.post(build_url(url), params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_url(url)
|
16
|
+
"#{resource}/#{url}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def request
|
20
|
+
RequestHandler.new
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :resource
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CurrencyCloud
|
2
|
+
class Rate
|
3
|
+
include CurrencyCloud::Resource
|
4
|
+
|
5
|
+
resource :rates
|
6
|
+
|
7
|
+
def self.find(params)
|
8
|
+
response = client.get("find", params)
|
9
|
+
|
10
|
+
rates = response["rates"].map do |currency_pair, (bid, offer)|
|
11
|
+
new(currency_pair: currency_pair, bid: bid, offer: offer)
|
12
|
+
end
|
13
|
+
|
14
|
+
Rates.new(currencies: rates, unavailable: response["unavailable"])
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.detailed(params)
|
18
|
+
new(client.get("detailed", params))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|