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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -2
  4. data/README.md +3 -3
  5. data/currency_cloud.gemspec +3 -3
  6. data/lib/currency_cloud.rb +2 -2
  7. data/lib/currency_cloud/{resources/account.rb → account.rb} +4 -2
  8. data/lib/currency_cloud/actions.rb +13 -0
  9. data/lib/currency_cloud/actions/create.rb +4 -3
  10. data/lib/currency_cloud/actions/current.rb +3 -2
  11. data/lib/currency_cloud/actions/delete.rb +7 -12
  12. data/lib/currency_cloud/actions/find.rb +5 -7
  13. data/lib/currency_cloud/actions/instance_delete.rb +10 -0
  14. data/lib/currency_cloud/actions/retrieve.rb +5 -4
  15. data/lib/currency_cloud/actions/save.rb +5 -4
  16. data/lib/currency_cloud/actions/update.rb +6 -2
  17. data/lib/currency_cloud/{resources/balance.rb → balance.rb} +5 -3
  18. data/lib/currency_cloud/{resources/beneficiary.rb → beneficiary.rb} +7 -8
  19. data/lib/currency_cloud/client.rb +27 -0
  20. data/lib/currency_cloud/{resources/contact.rb → contact.rb} +4 -2
  21. data/lib/currency_cloud/{resources/conversion.rb → conversion.rb} +4 -6
  22. data/lib/currency_cloud/conversion_dates.rb +5 -0
  23. data/lib/currency_cloud/currency.rb +5 -0
  24. data/lib/currency_cloud/pagination.rb +1 -4
  25. data/lib/currency_cloud/{resources/payer.rb → payer.rb} +4 -2
  26. data/lib/currency_cloud/{resources/payment.rb → payment.rb} +4 -5
  27. data/lib/currency_cloud/rate.rb +21 -0
  28. data/lib/currency_cloud/rates.rb +5 -0
  29. data/lib/currency_cloud/reference.rb +26 -0
  30. data/lib/currency_cloud/request_handler.rb +9 -10
  31. data/lib/currency_cloud/resource.rb +52 -50
  32. data/lib/currency_cloud/response_handler.rb +6 -8
  33. data/lib/currency_cloud/session.rb +19 -19
  34. data/lib/currency_cloud/{resources/settlement.rb → settlement.rb} +20 -16
  35. data/lib/currency_cloud/settlement_account.rb +5 -0
  36. data/lib/currency_cloud/{resources/transaction.rb → transaction.rb} +4 -3
  37. data/lib/currency_cloud/version.rb +2 -4
  38. data/spec/currency_cloud/resource_spec.rb +7 -5
  39. data/spec/integration/actions_spec.rb +3 -3
  40. data/spec/integration/authentication_spec.rb +3 -3
  41. data/spec/integration/errors_spec.rb +6 -6
  42. data/spec/integration/rates_spec.rb +3 -3
  43. data/spec/integration/reference_spec.rb +5 -5
  44. data/spec/integration/settlements_spec.rb +8 -8
  45. metadata +20 -15
  46. data/.ruby-gemset +0 -1
  47. data/.ruby-version +0 -1
  48. data/lib/currency_cloud/resources/rate.rb +0 -21
  49. data/lib/currency_cloud/resources/reference.rb +0 -29
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Resource' do
4
4
  before(:all) do
5
- class Person < CurrencyCloud::Resource
5
+ class Person
6
+ include CurrencyCloud::Resource
6
7
  resource :people
7
8
  actions :update, :delete
8
9
  end
@@ -11,16 +12,16 @@ describe 'Resource' do
11
12
  describe "#save" do
12
13
  it "only updates changed records" do
13
14
  person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
14
- allow(person).to receive(:post).with(1, name: 'John')
15
+ allow(Person.client).to receive(:post).with(1, name: 'John').and_return(id: 1, name: 'John', surname: 'Nienaber')
15
16
  person.name = 'John'
16
-
17
+
17
18
  expect(person.save).to eq(person)
18
19
  expect(person.changed_attributes).to eq(Set.new)
19
20
  end
20
21
 
21
22
  it "does nothing if nothing has changed" do
22
23
  person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
23
-
24
+
24
25
  expect(person.save).to eq(person)
25
26
  expect(person.changed_attributes).to eq(Set.new)
26
27
  end
@@ -29,7 +30,8 @@ describe 'Resource' do
29
30
  describe "#delete" do
30
31
  it 'removes resource' do
31
32
  person = Person.new(id: 1, name: 'Richard', surname: 'Nienaber')
32
- allow(Person).to receive(:post).with('1/delete')
33
+ # Uses the class method to perform the deletion
34
+ allow(Person).to receive(:delete).with(1)
33
35
 
34
36
  expect(person.delete).to eq(person)
35
37
  end
@@ -55,7 +55,7 @@ describe 'Actions', :vcr => true do
55
55
  beneficiaries = CurrencyCloud::Beneficiary.find
56
56
  expect(beneficiaries).to_not be_empty
57
57
  expect(beneficiaries.length).to eq(1)
58
-
58
+
59
59
  beneficiaries.each do |b|
60
60
  expect(b).to_not be_nil
61
61
  expect(b).to be_a_kind_of(CurrencyCloud::Beneficiary)
@@ -69,7 +69,7 @@ describe 'Actions', :vcr => true do
69
69
  expect(pagination.previous_page).to eq(-1)
70
70
  expect(pagination.next_page).to eq(-1)
71
71
  expect(pagination.order).to eq('created_at')
72
- expect(pagination.order_asc_desc).to eq('asc')
72
+ expect(pagination.order_asc_desc).to eq('asc')
73
73
  end
74
74
 
75
75
  it "can #update" do
@@ -126,4 +126,4 @@ describe 'Actions', :vcr => true do
126
126
  expect(balance.created_at).to eq('2014-12-04T09:50:35+00:00')
127
127
  expect(balance.updated_at).to eq('2015-03-23T14:33:37+00:00')
128
128
  end
129
- end
129
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Authentication', :vcr => true do
4
- before(:each) do
4
+ before do
5
5
  CurrencyCloud.reset_session
6
6
  CurrencyCloud.environment = :demonstration
7
7
  CurrencyCloud.login_id = 'rjnienaber@gmail.com'
@@ -24,7 +24,7 @@ describe 'Authentication', :vcr => true do
24
24
  end
25
25
 
26
26
  it 'can be closed' do
27
- CurrencyCloud.session
27
+ CurrencyCloud.session
28
28
  expect(CurrencyCloud.close_session).to eq(true)
29
29
  end
30
30
 
@@ -37,4 +37,4 @@ describe 'Authentication', :vcr => true do
37
37
  #should have changed after reauthentication
38
38
  expect(CurrencyCloud.token).to eq('038022bcd2f372cac7bab448db7b5c3b')
39
39
  end
40
- end
40
+ end
@@ -141,10 +141,10 @@ inner_error: Timeout::Error
141
141
  CurrencyCloud.token = '656485646b068f6e9c81e3d885fa54f5'
142
142
  error = nil
143
143
  begin
144
- CurrencyCloud::Beneficiary.retrieve('081596c9-02de-483e-9f2a-4cf55dcdf98c')
144
+ CurrencyCloud::Beneficiary.retrieve('081596c9-02de-483e-9f2a-4cf55dcdf98c')
145
145
  raise 'Should fail'
146
146
  rescue CurrencyCloud::NotFoundError => error
147
- end
147
+ end
148
148
 
149
149
  expect(error.code).to eq('beneficiary_not_found')
150
150
  expect(error.raw_response).to_not be_nil
@@ -157,7 +157,7 @@ inner_error: Timeout::Error
157
157
  expect(error_message.message).to eq('Beneficiary was not found for this id')
158
158
  expect(error_message.params).to be_empty
159
159
  end
160
-
160
+
161
161
  it 'is raised on an internal server error' do
162
162
 
163
163
  error = nil
@@ -178,14 +178,14 @@ inner_error: Timeout::Error
178
178
  expect(error_message.message).to eq('A general application error occurred')
179
179
  expect(error_message.params).to include("request_id" => 2771875643610572878)
180
180
  end
181
-
181
+
182
182
  it 'is raised when too many requests have been issued' do
183
183
  CurrencyCloud.login_id = 'rjnienaber@gmail.com2'
184
184
 
185
185
  error = nil
186
186
  begin
187
187
  CurrencyCloud.session
188
-
188
+
189
189
  raise 'Should have failed'
190
190
  rescue CurrencyCloud::TooManyRequestsError => error
191
191
  end
@@ -201,4 +201,4 @@ inner_error: Timeout::Error
201
201
  expect(error_message.message).to eq('Too many requests have been made to the api. Please refer to the Developer Center for more information')
202
202
  expect(error_message.params).to be_empty
203
203
  end
204
- end
204
+ end
@@ -15,7 +15,7 @@ describe 'Rates', :vcr => true do
15
15
 
16
16
  currencies = rates.currencies
17
17
  expect(currencies.length).to eq(2)
18
-
18
+
19
19
  currencies.each do |b|
20
20
  expect(b).to_not be_nil
21
21
  expect(b).to be_a_kind_of(CurrencyCloud::Rate)
@@ -27,7 +27,7 @@ describe 'Rates', :vcr => true do
27
27
  expect(rate.offer).to eq('0.71508')
28
28
 
29
29
  expect(rates.unavailable).to be_empty
30
- end
30
+ end
31
31
 
32
32
  it 'can provided #detailed rate' do
33
33
  detailed_rate = CurrencyCloud::Rate.detailed(buy_currency: 'GBP', sell_currency: 'USD', fixed_side: 'buy', amount: '10000')
@@ -36,4 +36,4 @@ describe 'Rates', :vcr => true do
36
36
  expect(detailed_rate.client_sell_amount).to eq('15234.00')
37
37
  expect(detailed_rate.settlement_cut_off_time).to eq('2015-04-29T14:00:00Z')
38
38
  end
39
- end
39
+ end
@@ -22,7 +22,7 @@ describe 'Reference', :vcr => true do
22
22
  expect(details["beneficiary_last_name"]).to eq("^.{1,255}")
23
23
  expect(details["acct_number"]).to eq("^[0-9A-Z]{1,50}$")
24
24
  expect(details["sort_code"]).to eq("^\\d{6}$")
25
- end
25
+ end
26
26
 
27
27
  it 'can retrieve #conversion_dates' do
28
28
  dates = CurrencyCloud::Reference.conversion_dates(:conversion_pair => 'GBPUSD')
@@ -32,7 +32,7 @@ describe 'Reference', :vcr => true do
32
32
  expect(invalid_conversion_date).to eq(["2015-05-02", "No trading on Saturday"])
33
33
  expect(dates.first_conversion_date).to eq('2015-04-30')
34
34
  expect(dates.default_conversion_date).to eq('2015-04-30')
35
- end
35
+ end
36
36
 
37
37
  it 'can retrieve #currencies' do
38
38
  currencies = CurrencyCloud::Reference.currencies
@@ -43,7 +43,7 @@ describe 'Reference', :vcr => true do
43
43
  expect(currency.code).to eq('AED')
44
44
  expect(currency.name).to eq('United Arab Emirates Dirham')
45
45
  expect(currency.decimal_places).to eq(2)
46
- end
46
+ end
47
47
 
48
48
  it 'can retrieve #settlement_accounts' do
49
49
  settlement_accounts = CurrencyCloud::Reference.settlement_accounts(:currency => 'GBP')
@@ -53,5 +53,5 @@ describe 'Reference', :vcr => true do
53
53
  expect(settlement_account).to be_a_kind_of(CurrencyCloud::SettlementAccount)
54
54
  expect(settlement_account.bank_account_holder_name).to eq("The Currency Cloud GBP - Client Seg A/C")
55
55
  expect(settlement_account.bank_address).to be_empty
56
- end
57
- end
56
+ end
57
+ end
@@ -14,7 +14,7 @@ describe 'Settlements', :vcr => true do
14
14
  reason: 'mortgage payment',
15
15
  term_agreement: true
16
16
  }
17
-
17
+
18
18
  end
19
19
 
20
20
  it 'can #add_conversion' do
@@ -24,7 +24,7 @@ describe 'Settlements', :vcr => true do
24
24
  updated_settlement = settlement.add_conversion(conversion.id)
25
25
 
26
26
  expect(settlement).to eq(updated_settlement)
27
-
27
+
28
28
  expect(settlement.conversion_ids).to eq( ["24d2ee7f-c7a3-4181-979e-9c58dbace992"])
29
29
  expect(settlement.entries).to_not be_empty
30
30
 
@@ -44,7 +44,7 @@ describe 'Settlements', :vcr => true do
44
44
  expect(deleted_settlement).to_not be_nil
45
45
  expect(deleted_settlement.type).to eq('bulk')
46
46
  expect(deleted_settlement.created_at).to eq('2015-05-04T20:29:16+00:00')
47
- expect(deleted_settlement.status).to eq('open')
47
+ expect(deleted_settlement.status).to eq('open')
48
48
  end
49
49
 
50
50
  it 'can #release' do
@@ -52,8 +52,8 @@ describe 'Settlements', :vcr => true do
52
52
  released_settlement = settlement.release
53
53
 
54
54
  expect(released_settlement).to eq(settlement)
55
- expect(released_settlement.released_at).to eq('2015-05-04T21:44:23+00:00')
56
- expect(released_settlement.status).to eq('released')
55
+ expect(released_settlement.released_at).to eq('2015-05-04T21:44:23+00:00')
56
+ expect(released_settlement.status).to eq('released')
57
57
  end
58
58
 
59
59
  it 'can #unrelease' do
@@ -61,7 +61,7 @@ describe 'Settlements', :vcr => true do
61
61
  unreleased_settlement = settlement.unrelease
62
62
 
63
63
  expect(unreleased_settlement).to eq(settlement)
64
- expect(unreleased_settlement.released_at).to eq('')
65
- expect(unreleased_settlement.status).to eq('open')
64
+ expect(unreleased_settlement.released_at).to eq('')
65
+ expect(unreleased_settlement.status).to eq('open')
66
66
  end
67
- end
67
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam McAndrew
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-30 00:00:00.000000000 Z
12
+ date: 2015-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -104,8 +104,6 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
- - ".ruby-gemset"
108
- - ".ruby-version"
109
107
  - ".travis.yml"
110
108
  - Gemfile
111
109
  - Guardfile
@@ -115,34 +113,41 @@ files:
115
113
  - currency_cloud.gemspec
116
114
  - examples/server.rb
117
115
  - lib/currency_cloud.rb
116
+ - lib/currency_cloud/account.rb
117
+ - lib/currency_cloud/actions.rb
118
118
  - lib/currency_cloud/actions/create.rb
119
119
  - lib/currency_cloud/actions/current.rb
120
120
  - lib/currency_cloud/actions/delete.rb
121
121
  - lib/currency_cloud/actions/find.rb
122
+ - lib/currency_cloud/actions/instance_delete.rb
122
123
  - lib/currency_cloud/actions/retrieve.rb
123
124
  - lib/currency_cloud/actions/save.rb
124
125
  - lib/currency_cloud/actions/update.rb
126
+ - lib/currency_cloud/balance.rb
127
+ - lib/currency_cloud/beneficiary.rb
128
+ - lib/currency_cloud/client.rb
129
+ - lib/currency_cloud/contact.rb
130
+ - lib/currency_cloud/conversion.rb
131
+ - lib/currency_cloud/conversion_dates.rb
132
+ - lib/currency_cloud/currency.rb
125
133
  - lib/currency_cloud/errors/api_error.rb
126
134
  - lib/currency_cloud/errors/error_utils.rb
127
135
  - lib/currency_cloud/errors/general_error.rb
128
136
  - lib/currency_cloud/errors/unexpected_error.rb
129
137
  - lib/currency_cloud/pagination.rb
138
+ - lib/currency_cloud/payer.rb
139
+ - lib/currency_cloud/payment.rb
140
+ - lib/currency_cloud/rate.rb
141
+ - lib/currency_cloud/rates.rb
142
+ - lib/currency_cloud/reference.rb
130
143
  - lib/currency_cloud/request_handler.rb
131
144
  - lib/currency_cloud/resource.rb
132
145
  - lib/currency_cloud/resourceful_collection.rb
133
- - lib/currency_cloud/resources/account.rb
134
- - lib/currency_cloud/resources/balance.rb
135
- - lib/currency_cloud/resources/beneficiary.rb
136
- - lib/currency_cloud/resources/contact.rb
137
- - lib/currency_cloud/resources/conversion.rb
138
- - lib/currency_cloud/resources/payer.rb
139
- - lib/currency_cloud/resources/payment.rb
140
- - lib/currency_cloud/resources/rate.rb
141
- - lib/currency_cloud/resources/reference.rb
142
- - lib/currency_cloud/resources/settlement.rb
143
- - lib/currency_cloud/resources/transaction.rb
144
146
  - lib/currency_cloud/response_handler.rb
145
147
  - lib/currency_cloud/session.rb
148
+ - lib/currency_cloud/settlement.rb
149
+ - lib/currency_cloud/settlement_account.rb
150
+ - lib/currency_cloud/transaction.rb
146
151
  - lib/currency_cloud/version.rb
147
152
  - spec/currency_cloud/request_handler_spec.rb
148
153
  - spec/currency_cloud/resource_spec.rb
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- currencycloud-ruby
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.2.0
@@ -1,21 +0,0 @@
1
- module CurrencyCloud
2
- class Rates < Resource; end
3
-
4
- class Rate < Resource
5
- resource :rates
6
-
7
- def self.find(params)
8
- response = request.get("#{self.resource}/find", params)
9
-
10
- rates = response['rates'].map do |currency_pair, bid_offer|
11
- new(currency_pair: currency_pair, bid: bid_offer[0], offer: bid_offer[1])
12
- end
13
-
14
- Rates.new(currencies: rates, unavailable: response['unavailable'])
15
- end
16
-
17
- def self.detailed(params)
18
- get('detailed', params)
19
- end
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- module CurrencyCloud
2
-
3
- class Currency < Resource; end
4
- class ConversionDates < Resource; end
5
- class SettlementAccount < Resource; end
6
-
7
- class Reference < Resource
8
-
9
- resource :reference
10
-
11
- def self.currencies
12
- response = request.get(build_url("currencies"))
13
- response['currencies'].map { |c| Currency.new(c)}
14
- end
15
-
16
- def self.beneficiary_required_details(params={})
17
- request.get(build_url("beneficiary_required_details"), params)['details']
18
- end
19
-
20
- def self.conversion_dates(params)
21
- ConversionDates.new(request.get(build_url("conversion_dates"), params))
22
- end
23
-
24
- def self.settlement_accounts(params={})
25
- response = request.get(build_url("settlement_accounts"), params)
26
- response['settlement_accounts'].map { |s| SettlementAccount.new(s)}
27
- end
28
- end
29
- end