currency_cloud 0.5

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 (72) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +12 -0
  6. data/Gemfile +7 -0
  7. data/Gemfile.lock +99 -0
  8. data/Guardfile +14 -0
  9. data/LICENSE.md +22 -0
  10. data/README.md +10 -0
  11. data/Rakefile +30 -0
  12. data/currency_cloud.gemspec +27 -0
  13. data/examples/server.rb +15 -0
  14. data/lib/currency_cloud.rb +26 -0
  15. data/lib/currency_cloud/actions/create.rb +9 -0
  16. data/lib/currency_cloud/actions/current.rb +9 -0
  17. data/lib/currency_cloud/actions/delete.rb +15 -0
  18. data/lib/currency_cloud/actions/find.rb +27 -0
  19. data/lib/currency_cloud/actions/retrieve.rb +9 -0
  20. data/lib/currency_cloud/actions/update.rb +12 -0
  21. data/lib/currency_cloud/errors/api_error.rb +38 -0
  22. data/lib/currency_cloud/errors/config_error.rb +5 -0
  23. data/lib/currency_cloud/errors/unexpected_error.rb +10 -0
  24. data/lib/currency_cloud/pagination.rb +7 -0
  25. data/lib/currency_cloud/request_handler.rb +68 -0
  26. data/lib/currency_cloud/resource.rb +73 -0
  27. data/lib/currency_cloud/resourceful_collection.rb +15 -0
  28. data/lib/currency_cloud/resources/account.rb +6 -0
  29. data/lib/currency_cloud/resources/balance.rb +8 -0
  30. data/lib/currency_cloud/resources/beneficiary.rb +14 -0
  31. data/lib/currency_cloud/resources/contact.rb +6 -0
  32. data/lib/currency_cloud/resources/conversion.rb +10 -0
  33. data/lib/currency_cloud/resources/payer.rb +6 -0
  34. data/lib/currency_cloud/resources/payment.rb +11 -0
  35. data/lib/currency_cloud/resources/rate.rb +21 -0
  36. data/lib/currency_cloud/resources/reference.rb +29 -0
  37. data/lib/currency_cloud/resources/settlement.rb +30 -0
  38. data/lib/currency_cloud/resources/transaction.rb +7 -0
  39. data/lib/currency_cloud/response_handler.rb +46 -0
  40. data/lib/currency_cloud/session.rb +62 -0
  41. data/lib/currency_cloud/version.rb +8 -0
  42. data/spec/currency_cloud_spec.rb +78 -0
  43. data/spec/integration/actions_spec.rb +101 -0
  44. data/spec/integration/authentication_spec.rb +37 -0
  45. data/spec/integration/errors_spec.rb +157 -0
  46. data/spec/integration/rates_spec.rb +39 -0
  47. data/spec/integration/reference_spec.rb +57 -0
  48. data/spec/spec_helper.rb +11 -0
  49. data/spec/support/vcr_cassettes/Actions/can_create.yml +38 -0
  50. data/spec/support/vcr_cassettes/Actions/can_current.yml +37 -0
  51. data/spec/support/vcr_cassettes/Actions/can_delete.yml +39 -0
  52. data/spec/support/vcr_cassettes/Actions/can_find.yml +38 -0
  53. data/spec/support/vcr_cassettes/Actions/can_first.yml +75 -0
  54. data/spec/support/vcr_cassettes/Actions/can_retrieve.yml +38 -0
  55. data/spec/support/vcr_cassettes/Actions/can_update.yml +39 -0
  56. data/spec/support/vcr_cassettes/Authentication/can_be_closed.yml +67 -0
  57. data/spec/support/vcr_cassettes/Authentication/can_use_just_a_token.yml +36 -0
  58. data/spec/support/vcr_cassettes/Authentication/handles_session_timeout_error.yml +101 -0
  59. data/spec/support/vcr_cassettes/Authentication/happens_lazily.yml +34 -0
  60. data/spec/support/vcr_cassettes/Error/is_raised_on_a_bad_request.yml +39 -0
  61. data/spec/support/vcr_cassettes/Error/is_raised_on_a_forbidden_request.yml +35 -0
  62. data/spec/support/vcr_cassettes/Error/is_raised_on_an_internal_server_error.yml +69 -0
  63. data/spec/support/vcr_cassettes/Error/is_raised_on_incorrect_authentication_details.yml +39 -0
  64. data/spec/support/vcr_cassettes/Error/is_raised_when_a_resource_is_not_found.yml +37 -0
  65. data/spec/support/vcr_cassettes/Error/is_raised_when_too_many_requests_have_been_issued.yml +34 -0
  66. data/spec/support/vcr_cassettes/Rates/can_find.yml +36 -0
  67. data/spec/support/vcr_cassettes/Rates/can_provided_detailed_rate.yml +36 -0
  68. data/spec/support/vcr_cassettes/Reference/can_retrieve_beneficiary_required_details.yml +36 -0
  69. data/spec/support/vcr_cassettes/Reference/can_retrieve_conversion_dates.yml +46 -0
  70. data/spec/support/vcr_cassettes/Reference/can_retrieve_currencies.yml +47 -0
  71. data/spec/support/vcr_cassettes/Reference/can_retrieve_settlement_accounts.yml +39 -0
  72. metadata +230 -0
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: UTF-8
8
+ string: login_id=rjnienaber%40gmail.com&api_key=ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Sat, 25 Apr 2015 08:44:14 GMT
19
+ Content-Type:
20
+ - application/json;charset=utf-8
21
+ Content-Length:
22
+ - '49'
23
+ Connection:
24
+ - keep-alive
25
+ X-Request-Id:
26
+ - '2771930174889333914'
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{"auth_token":"57ef449f6316f2f54dfec37c2006fe50"}'
32
+ http_version:
33
+ recorded_at: Sat, 25 Apr 2015 08:44:14 GMT
34
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: US-ASCII
8
+ string: login_id=non-existent-login-id&api_key=ef0fd50fca1fb14c1fab3a8436b9ecb57528f0
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 400
17
+ message: Bad Request
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Date:
24
+ - Fri, 24 Apr 2015 20:47:14 GMT
25
+ X-Request-Id:
26
+ - '2771569299808580066'
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Connection:
30
+ - close
31
+ Content-Length:
32
+ - '190'
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ! '{"error_code":"auth_invalid_user_login_details","error_messages":{"api_key":[{"code":"api_key_length_is_invalid","message":"api_key
36
+ should be 64 character(s) long","params":{"length":64}}]}}'
37
+ http_version:
38
+ recorded_at: Fri, 24 Apr 2015 20:47:14 GMT
39
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,35 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: UTF-8
8
+ string: login_id=rjnienaber%40gmail.com&api_key=ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 403
13
+ message: Forbidden
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Sat, 25 Apr 2015 07:04:11 GMT
19
+ Content-Type:
20
+ - application/json;charset=utf-8
21
+ Content-Length:
22
+ - '49'
23
+ Connection:
24
+ - keep-alive
25
+ X-Request-Id:
26
+ - '2771879819392580288'
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ body:
30
+ encoding: UTF-8
31
+ string: ! '{"error_code":"auth_failed","error_messages":{"username":[{"code":"invalid_supplied_credentials","message":"Authentication
32
+ failed with the supplied credentials","params":{}}]}}'
33
+ http_version:
34
+ recorded_at: Sat, 25 Apr 2015 07:04:11 GMT
35
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: UTF-8
8
+ string: login_id=rjnienaber%40gmail.com&api_key=ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 500
13
+ message: Internal Server Error
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Sat, 25 Apr 2015 06:52:42 GMT
19
+ Content-Type:
20
+ - application/json;charset=utf-8
21
+ Content-Length:
22
+ - '49'
23
+ Connection:
24
+ - keep-alive
25
+ X-Request-Id:
26
+ - '2771875643610572878'
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{"error_code":"internal_application_error","error_messages":{"base":[{"code":"internal_application_error","message":"A
32
+ general application error occurred","params":{"request_id":2771875643610572878}}]}}'
33
+ http_version:
34
+ recorded_at: Sat, 25 Apr 2015 06:52:42 GMT
35
+ - request:
36
+ method: get
37
+ uri: https://devapi.thecurrencycloud.com/v2/beneficiaries/081596c9-02de-483e-9f2a-4cf55dcdf98c
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ''
41
+ headers:
42
+ X-Auth-Token:
43
+ - 656485646b068f6e9c81e3d885fa54f5
44
+ response:
45
+ status:
46
+ code: 404
47
+ message: Not Found
48
+ headers:
49
+ Server:
50
+ - nginx
51
+ Date:
52
+ - Sat, 25 Apr 2015 11:21:38 GMT
53
+ Content-Type:
54
+ - application/json;charset=utf-8
55
+ Content-Length:
56
+ - '159'
57
+ Connection:
58
+ - keep-alive
59
+ X-Request-Id:
60
+ - '2772009396693571416'
61
+ X-Content-Type-Options:
62
+ - nosniff
63
+ body:
64
+ encoding: UTF-8
65
+ string: '{"error_code":"beneficiary_not_found","error_messages":{"id":[{"code":"beneficiary_not_found","message":"Beneficiary
66
+ was not found for this id","params":{}}]}}'
67
+ http_version:
68
+ recorded_at: Sat, 25 Apr 2015 11:21:38 GMT
69
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: US-ASCII
8
+ string: login_id=non-existent-login-id&api_key=efb5ae2af84978b7a37f18dd61c8bbe139b403009faea83484405a3dcb64c4d8
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 401
17
+ message: Unauthorized
18
+ headers:
19
+ Server:
20
+ - nginx
21
+ Date:
22
+ - Fri, 24 Apr 2015 20:47:15 GMT
23
+ Content-Type:
24
+ - application/json;charset=utf-8
25
+ Content-Length:
26
+ - '176'
27
+ Connection:
28
+ - keep-alive
29
+ X-Request-Id:
30
+ - '2771569303323356643'
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ! '{"error_code":"auth_failed","error_messages":{"username":[{"code":"invalid_supplied_credentials","message":"Authentication
36
+ failed with the supplied credentials","params":{}}]}}'
37
+ http_version:
38
+ recorded_at: Fri, 24 Apr 2015 20:47:15 GMT
39
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,37 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://devapi.thecurrencycloud.com/v2/beneficiaries/081596c9-02de-483e-9f2a-4cf55dcdf98c
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Auth-Token:
11
+ - 656485646b068f6e9c81e3d885fa54f5
12
+ response:
13
+ status:
14
+ code: 404
15
+ message: Not Found
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Sat, 25 Apr 2015 11:16:53 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '159'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2772007003121723883'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"error_code":"beneficiary_not_found","error_messages":{"id":[{"code":"beneficiary_not_found","message":"Beneficiary
34
+ was not found for this id","params":{}}]}}'
35
+ http_version:
36
+ recorded_at: Sat, 25 Apr 2015 11:16:53 GMT
37
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://devapi.thecurrencycloud.com/v2/authenticate/api
6
+ body:
7
+ encoding: UTF-8
8
+ string: login_id=rjnienaber%40gmail.com2&api_key=ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 429
13
+ message: Too Many Requests
14
+ headers:
15
+ Server:
16
+ - nginx
17
+ Date:
18
+ - Sat, 25 Apr 2015 06:45:44 GMT
19
+ Content-Type:
20
+ - application/json
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Connection:
24
+ - keep-alive
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ body:
28
+ encoding: UTF-8
29
+ string: '{"error_code":"too_many_requests","error_messages":{"base":[{"code":"too_many_requests","message":"Too
30
+ many requests have been made to the api. Please refer to the Developer Center
31
+ for more information","params":{}}]}}'
32
+ http_version:
33
+ recorded_at: Sat, 25 Apr 2015 06:45:44 GMT
34
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://devapi.thecurrencycloud.com/v2/rates/find
6
+ body:
7
+ encoding: UTF-8
8
+ string: currency_pair=GBPUSD%2CEURGBP
9
+ headers:
10
+ X-Auth-Token:
11
+ - 242993ca94b9d1c6c1d8f7d3275a6f36
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Mon, 27 Apr 2015 20:33:51 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '90'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2773736887435072763'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"rates":{"EURGBP":["0.71445","0.71508"],"GBPUSD":["1.52264","1.52334"]},"unavailable":[]}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 20:33:52 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://devapi.thecurrencycloud.com/v2/rates/detailed
6
+ body:
7
+ encoding: UTF-8
8
+ string: buy_currency=GBP&sell_currency=USD&fixed_side=buy&amount=10000
9
+ headers:
10
+ X-Auth-Token:
11
+ - 242993ca94b9d1c6c1d8f7d3275a6f36
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Mon, 27 Apr 2015 20:35:49 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '377'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2773737871964103057'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"settlement_cut_off_time":"2015-04-29T14:00:00Z","currency_pair":"GBPUSD","client_buy_currency":"GBP","client_sell_currency":"USD","client_buy_amount":"10000.00","client_sell_amount":"15234.00","fixed_side":"buy","mid_market_rate":"1.5231","client_rate":"1.5234","partner_rate":null,"core_rate":"1.5234","deposit_required":null,"deposit_amount":"0.0","deposit_currency":"USD"}'
34
+ http_version:
35
+ recorded_at: Mon, 27 Apr 2015 20:35:49 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://devapi.thecurrencycloud.com/v2/reference/beneficiary_required_details
6
+ body:
7
+ encoding: UTF-8
8
+ string: currency=GBP&bank_account_country=GB&beneficiary_country=GB
9
+ headers:
10
+ X-Auth-Token:
11
+ - 1c9da5726314246acfb09ec5651307a5
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 29 Apr 2015 21:04:08 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '1390'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2775201676418056015'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"details":[{"payment_type":"priority","beneficiary_entity_type":"individual","beneficiary_address":"^.{1,255}","beneficiary_city":"^.{1,255}","beneficiary_country":"^[A-z]{2}$","beneficiary_first_name":"^.{1,255}","beneficiary_last_name":"^.{1,255}","acct_number":"^[0-9A-Z]{1,50}$","sort_code":"^\\d{6}$"},{"payment_type":"priority","beneficiary_entity_type":"company","beneficiary_address":"^.{1,255}","beneficiary_city":"^.{1,255}","beneficiary_country":"^[A-z]{2}$","beneficiary_company_name":"^.{1,255}","acct_number":"^[0-9A-Z]{1,50}$","sort_code":"^\\d{6}$"},{"payment_type":"regular","acct_number":"^[0-9A-Z]{1,50}$","sort_code":"^\\d{6}$","beneficiary_entity_type":"individual"},{"payment_type":"regular","acct_number":"^[0-9A-Z]{1,50}$","sort_code":"^\\d{6}$","beneficiary_entity_type":"company"},{"payment_type":"priority","beneficiary_entity_type":"individual","beneficiary_address":"^.{1,255}","beneficiary_city":"^.{1,255}","beneficiary_country":"^[A-z]{2}$","beneficiary_first_name":"^.{1,255}","beneficiary_last_name":"^.{1,255}","iban":"^[0-9A-Z]{1,34}$","bic_swift":"^[0-9A-Z]{8}$|^[0-9A-Z]{11}$"},{"payment_type":"priority","beneficiary_entity_type":"company","beneficiary_address":"^.{1,255}","beneficiary_city":"^.{1,255}","beneficiary_country":"^[A-z]{2}$","beneficiary_company_name":"^.{1,255}","iban":"^[0-9A-Z]{1,34}$","bic_swift":"^[0-9A-Z]{8}$|^[0-9A-Z]{11}$"}]}'
34
+ http_version:
35
+ recorded_at: Wed, 29 Apr 2015 21:04:08 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://devapi.thecurrencycloud.com/v2/reference/conversion_dates
6
+ body:
7
+ encoding: UTF-8
8
+ string: conversion_pair=GBPUSD
9
+ headers:
10
+ X-Auth-Token:
11
+ - 1c9da5726314246acfb09ec5651307a5
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 29 Apr 2015 21:04:08 GMT
21
+ Content-Type:
22
+ - application/json;charset=utf-8
23
+ Content-Length:
24
+ - '845'
25
+ Connection:
26
+ - keep-alive
27
+ X-Request-Id:
28
+ - '2775201681275056976'
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"invalid_conversion_dates":{"2015-05-02":"No trading on Saturday","2015-05-03":"No
34
+ trading on Sunday","2015-05-04":"Early May bank holiday","2015-05-09":"No
35
+ trading on Saturday","2015-05-10":"No trading on Sunday","2015-05-16":"No
36
+ trading on Saturday","2015-05-17":"No trading on Sunday","2015-05-23":"No
37
+ trading on Saturday","2015-05-24":"No trading on Sunday","2015-05-25":"Spring
38
+ bank holiday","2015-05-30":"No trading on Saturday","2015-05-31":"No trading
39
+ on Sunday","2015-06-06":"No trading on Saturday","2015-06-07":"No trading
40
+ on Sunday","2015-06-13":"No trading on Saturday","2015-06-14":"No trading
41
+ on Sunday","2015-06-20":"No trading on Saturday","2015-06-21":"No trading
42
+ on Sunday","2015-06-27":"No trading on Saturday","2015-06-28":"No trading
43
+ on Sunday"},"first_conversion_date":"2015-04-30","default_conversion_date":"2015-04-30"}'
44
+ http_version:
45
+ recorded_at: Wed, 29 Apr 2015 21:04:08 GMT
46
+ recorded_with: VCR 2.9.3