tangocard-raas 1.1.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +28 -175
  3. data/README.md +38 -525
  4. data/lib/raas.rb +32 -19
  5. data/lib/raas/api_helper.rb +146 -54
  6. data/lib/raas/configuration.rb +22 -30
  7. data/lib/raas/controllers/accounts_controller.rb +146 -92
  8. data/lib/raas/controllers/base_controller.rb +32 -29
  9. data/lib/raas/controllers/catalog_controller.rb +31 -14
  10. data/lib/raas/controllers/customers_controller.rb +113 -72
  11. data/lib/raas/controllers/exchange_rates_controller.rb +40 -12
  12. data/lib/raas/controllers/fund_controller.rb +345 -0
  13. data/lib/raas/controllers/orders_controller.rb +166 -105
  14. data/lib/raas/controllers/status_controller.rb +31 -14
  15. data/lib/raas/exceptions/api_exception.rb +4 -2
  16. data/lib/raas/exceptions/raas_client_exception.rb +14 -12
  17. data/lib/raas/exceptions/raas_generic_exception.rb +9 -9
  18. data/lib/raas/exceptions/raas_server_exception.rb +14 -12
  19. data/lib/raas/http/auth/basic_auth.rb +7 -4
  20. data/lib/raas/http/faraday_client.rb +19 -7
  21. data/lib/raas/http/http_call_back.rb +11 -6
  22. data/lib/raas/http/http_client.rb +50 -32
  23. data/lib/raas/http/http_context.rb +5 -2
  24. data/lib/raas/http/http_method_enum.rb +6 -2
  25. data/lib/raas/http/http_request.rb +7 -3
  26. data/lib/raas/http/http_response.rb +3 -1
  27. data/lib/raas/models/account_model.rb +32 -23
  28. data/lib/raas/models/account_summary_model.rb +26 -17
  29. data/lib/raas/models/base_model.rb +11 -9
  30. data/lib/raas/models/billing_address_model.rb +105 -0
  31. data/lib/raas/models/brand_model.rb +39 -35
  32. data/lib/raas/models/catalog_model.rb +15 -13
  33. data/lib/raas/models/create_account_request_model.rb +14 -14
  34. data/lib/raas/models/create_credit_card_request_model.rb +96 -0
  35. data/lib/raas/models/create_customer_request_model.rb +12 -12
  36. data/lib/raas/models/create_order_request_model.rb +45 -35
  37. data/lib/raas/models/credit_card_model.rb +124 -0
  38. data/lib/raas/models/currency_breakdown_model.rb +18 -18
  39. data/lib/raas/models/customer_model.rb +24 -22
  40. data/lib/raas/models/deposit_request_model.rb +60 -0
  41. data/lib/raas/models/deposit_response_model.rb +80 -0
  42. data/lib/raas/models/exchange_rate_model.rb +18 -17
  43. data/lib/raas/models/exchange_rate_response_model.rb +17 -15
  44. data/lib/raas/models/full_name_email_model.rb +42 -0
  45. data/lib/raas/models/get_deposit_response_model.rb +80 -0
  46. data/lib/raas/models/get_orders_response_model.rb +16 -14
  47. data/lib/raas/models/item_model.rb +36 -34
  48. data/lib/raas/models/name_email_model.rb +14 -14
  49. data/lib/raas/models/new_credit_card_model.rb +51 -0
  50. data/lib/raas/models/order_model.rb +124 -92
  51. data/lib/raas/models/order_summary_model.rb +155 -0
  52. data/lib/raas/models/page_model.rb +16 -16
  53. data/lib/raas/models/raas_client_error_model.rb +16 -16
  54. data/lib/raas/models/raas_server_error_model.rb +12 -12
  55. data/lib/raas/models/resend_order_response_model.rb +11 -11
  56. data/lib/raas/models/reward_credential_model.rb +14 -14
  57. data/lib/raas/models/reward_model.rb +16 -14
  58. data/lib/raas/models/system_status_response_model.rb +10 -10
  59. data/lib/raas/models/unregister_credit_card_request_model.rb +51 -0
  60. data/lib/raas/models/unregister_credit_card_response_model.rb +53 -0
  61. data/lib/raas/raas_client.rb +36 -25
  62. data/test/controllers/controller_test_base.rb +31 -0
  63. data/test/controllers/test_accounts_controller.rb +79 -0
  64. data/test/controllers/test_catalog_controller.rb +65 -0
  65. data/test/controllers/test_customers_controller.rb +61 -0
  66. data/test/controllers/test_exchange_rates_controller.rb +35 -0
  67. data/test/controllers/test_fund_controller.rb +108 -0
  68. data/test/controllers/test_orders_controller.rb +86 -0
  69. data/test/controllers/test_status_controller.rb +27 -0
  70. data/test/http_response_catcher.rb +16 -0
  71. data/test/test_helper.rb +91 -0
  72. metadata +32 -10
@@ -1,38 +1,38 @@
1
- # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  require 'date'
4
5
  module Raas
6
+ # Represents a Customer/Group
5
7
  class CustomerModel < BaseModel
6
- # Customer Identifier
8
+ # The customer identifier
7
9
  # @return [String]
8
10
  attr_accessor :customer_identifier
9
11
 
10
- # Display Name
12
+ # The display name
11
13
  # @return [String]
12
14
  attr_accessor :display_name
13
15
 
14
- # Status
16
+ # The status of the customer
15
17
  # @return [String]
16
18
  attr_accessor :status
17
19
 
18
- # Date Created
20
+ # The date the customer was created
19
21
  # @return [DateTime]
20
22
  attr_accessor :created_at
21
23
 
22
- # Accounts
24
+ # An array of AccountSummary objects
23
25
  # @return [List of AccountSummaryModel]
24
26
  attr_accessor :accounts
25
27
 
26
- # A mapping from model property names to API property names
28
+ # A mapping from model property names to API property names.
27
29
  def self.names
28
- if @_hash.nil?
29
- @_hash = {}
30
- @_hash["customer_identifier"] = "customerIdentifier"
31
- @_hash["display_name"] = "displayName"
32
- @_hash["status"] = "status"
33
- @_hash["created_at"] = "createdAt"
34
- @_hash["accounts"] = "accounts"
35
- end
30
+ @_hash = {} if @_hash.nil?
31
+ @_hash['customer_identifier'] = 'customerIdentifier'
32
+ @_hash['display_name'] = 'displayName'
33
+ @_hash['status'] = 'status'
34
+ @_hash['created_at'] = 'createdAt'
35
+ @_hash['accounts'] = 'accounts'
36
36
  @_hash
37
37
  end
38
38
 
@@ -48,23 +48,25 @@ module Raas
48
48
  @accounts = accounts
49
49
  end
50
50
 
51
- # Creates an instance of the object from a hash
51
+ # Creates an instance of the object from a hash.
52
52
  def self.from_hash(hash)
53
53
  return nil unless hash
54
54
 
55
- # Extract variables from the hash
55
+ # Extract variables from the hash.
56
56
  customer_identifier = hash['customerIdentifier']
57
57
  display_name = hash['displayName']
58
58
  status = hash['status']
59
- created_at = DateTime.rfc3339(hash['createdAt']) if hash['createdAt']
59
+ created_at = APIHelper.rfc3339(hash['createdAt']) if hash['createdAt']
60
60
  # Parameter is an array, so we need to iterate through it
61
61
  accounts = nil
62
- if hash['accounts'] != nil
63
- accounts = Array.new
64
- hash['accounts'].each{|structure| accounts << (AccountSummaryModel.from_hash(structure) if structure)}
62
+ unless hash['accounts'].nil?
63
+ accounts = []
64
+ hash['accounts'].each do |structure|
65
+ accounts << (AccountSummaryModel.from_hash(structure) if structure)
66
+ end
65
67
  end
66
68
 
67
- # Create object from extracted values
69
+ # Create object from extracted values.
68
70
  CustomerModel.new(customer_identifier,
69
71
  display_name,
70
72
  status,
@@ -0,0 +1,60 @@
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Raas
5
+ # Represents the request to deposit funds via credit card
6
+ class DepositRequestModel < BaseModel
7
+ # The customer identifier
8
+ # @return [String]
9
+ attr_accessor :customer_identifier
10
+
11
+ # The account identifier
12
+ # @return [String]
13
+ attr_accessor :account_identifier
14
+
15
+ # The credit card token
16
+ # @return [String]
17
+ attr_accessor :credit_card_token
18
+
19
+ # The amount to fund
20
+ # @return [Float]
21
+ attr_accessor :amount
22
+
23
+ # A mapping from model property names to API property names.
24
+ def self.names
25
+ @_hash = {} if @_hash.nil?
26
+ @_hash['customer_identifier'] = 'customerIdentifier'
27
+ @_hash['account_identifier'] = 'accountIdentifier'
28
+ @_hash['credit_card_token'] = 'creditCardToken'
29
+ @_hash['amount'] = 'amount'
30
+ @_hash
31
+ end
32
+
33
+ def initialize(customer_identifier = nil,
34
+ account_identifier = nil,
35
+ credit_card_token = nil,
36
+ amount = nil)
37
+ @customer_identifier = customer_identifier
38
+ @account_identifier = account_identifier
39
+ @credit_card_token = credit_card_token
40
+ @amount = amount
41
+ end
42
+
43
+ # Creates an instance of the object from a hash.
44
+ def self.from_hash(hash)
45
+ return nil unless hash
46
+
47
+ # Extract variables from the hash.
48
+ customer_identifier = hash['customerIdentifier']
49
+ account_identifier = hash['accountIdentifier']
50
+ credit_card_token = hash['creditCardToken']
51
+ amount = hash['amount']
52
+
53
+ # Create object from extracted values.
54
+ DepositRequestModel.new(customer_identifier,
55
+ account_identifier,
56
+ credit_card_token,
57
+ amount)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,80 @@
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ require 'date'
5
+ module Raas
6
+ # Represents the response from a place deposit call
7
+ class DepositResponseModel < BaseModel
8
+ # The funding amount
9
+ # @return [Float]
10
+ attr_accessor :amount
11
+
12
+ # The amount charged, after fees
13
+ # @return [Float]
14
+ attr_accessor :amount_charged
15
+
16
+ # The date the transaction was created
17
+ # @return [DateTime]
18
+ attr_accessor :created_date
19
+
20
+ # The processing fee percentage
21
+ # @return [Float]
22
+ attr_accessor :fee_percent
23
+
24
+ # The deposit reference id
25
+ # @return [String]
26
+ attr_accessor :reference_deposit_id
27
+
28
+ # The status of the transaction
29
+ # @return [String]
30
+ attr_accessor :status
31
+
32
+ # A mapping from model property names to API property names.
33
+ def self.names
34
+ @_hash = {} if @_hash.nil?
35
+ @_hash['amount'] = 'amount'
36
+ @_hash['amount_charged'] = 'amountCharged'
37
+ @_hash['created_date'] = 'createdDate'
38
+ @_hash['fee_percent'] = 'feePercent'
39
+ @_hash['reference_deposit_id'] = 'referenceDepositID'
40
+ @_hash['status'] = 'status'
41
+ @_hash
42
+ end
43
+
44
+ def initialize(amount = nil,
45
+ amount_charged = nil,
46
+ created_date = nil,
47
+ fee_percent = nil,
48
+ reference_deposit_id = nil,
49
+ status = nil)
50
+ @amount = amount
51
+ @amount_charged = amount_charged
52
+ @created_date = created_date
53
+ @fee_percent = fee_percent
54
+ @reference_deposit_id = reference_deposit_id
55
+ @status = status
56
+ end
57
+
58
+ # Creates an instance of the object from a hash.
59
+ def self.from_hash(hash)
60
+ return nil unless hash
61
+
62
+ # Extract variables from the hash.
63
+ amount = hash['amount']
64
+ amount_charged = hash['amountCharged']
65
+ created_date = APIHelper.rfc3339(hash['createdDate']) if
66
+ hash['createdDate']
67
+ fee_percent = hash['feePercent']
68
+ reference_deposit_id = hash['referenceDepositID']
69
+ status = hash['status']
70
+
71
+ # Create object from extracted values.
72
+ DepositResponseModel.new(amount,
73
+ amount_charged,
74
+ created_date,
75
+ fee_percent,
76
+ reference_deposit_id,
77
+ status)
78
+ end
79
+ end
80
+ end
@@ -1,33 +1,33 @@
1
- # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  require 'date'
4
5
  module Raas
6
+ # Represents an Exchange Rate
5
7
  class ExchangeRateModel < BaseModel
6
- # Last Modified
8
+ # When the exchange rate was last updated
7
9
  # @return [DateTime]
8
10
  attr_accessor :last_modified_date
9
11
 
10
- # Reward Currency
12
+ # The reward currency
11
13
  # @return [String]
12
14
  attr_accessor :reward_currency
13
15
 
14
- # Base Currency
16
+ # The base currency
15
17
  # @return [String]
16
18
  attr_accessor :base_currency
17
19
 
18
- # Exchange Rate
20
+ # The exchange rate
19
21
  # @return [Float]
20
22
  attr_accessor :base_fx
21
23
 
22
- # A mapping from model property names to API property names
24
+ # A mapping from model property names to API property names.
23
25
  def self.names
24
- if @_hash.nil?
25
- @_hash = {}
26
- @_hash["last_modified_date"] = "lastModifiedDate"
27
- @_hash["reward_currency"] = "rewardCurrency"
28
- @_hash["base_currency"] = "baseCurrency"
29
- @_hash["base_fx"] = "baseFx"
30
- end
26
+ @_hash = {} if @_hash.nil?
27
+ @_hash['last_modified_date'] = 'lastModifiedDate'
28
+ @_hash['reward_currency'] = 'rewardCurrency'
29
+ @_hash['base_currency'] = 'baseCurrency'
30
+ @_hash['base_fx'] = 'baseFx'
31
31
  @_hash
32
32
  end
33
33
 
@@ -41,17 +41,18 @@ module Raas
41
41
  @base_fx = base_fx
42
42
  end
43
43
 
44
- # Creates an instance of the object from a hash
44
+ # Creates an instance of the object from a hash.
45
45
  def self.from_hash(hash)
46
46
  return nil unless hash
47
47
 
48
- # Extract variables from the hash
49
- last_modified_date = DateTime.rfc3339(hash['lastModifiedDate']) if hash['lastModifiedDate']
48
+ # Extract variables from the hash.
49
+ last_modified_date = APIHelper.rfc3339(hash['lastModifiedDate']) if
50
+ hash['lastModifiedDate']
50
51
  reward_currency = hash['rewardCurrency']
51
52
  base_currency = hash['baseCurrency']
52
53
  base_fx = hash['baseFx']
53
54
 
54
- # Create object from extracted values
55
+ # Create object from extracted values.
55
56
  ExchangeRateModel.new(last_modified_date,
56
57
  reward_currency,
57
58
  base_currency,
@@ -1,22 +1,22 @@
1
- # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  module Raas
5
+ # Represents the response from the get exchange rates call
4
6
  class ExchangeRateResponseModel < BaseModel
5
- # Disclaimer
7
+ # A disclaimer about the exchange rates returned
6
8
  # @return [String]
7
9
  attr_accessor :disclaimer
8
10
 
9
- # Exchange Rates
11
+ # An array of ExchangeRate objects
10
12
  # @return [List of ExchangeRateModel]
11
13
  attr_accessor :exchange_rates
12
14
 
13
- # A mapping from model property names to API property names
15
+ # A mapping from model property names to API property names.
14
16
  def self.names
15
- if @_hash.nil?
16
- @_hash = {}
17
- @_hash["disclaimer"] = "disclaimer"
18
- @_hash["exchange_rates"] = "exchangeRates"
19
- end
17
+ @_hash = {} if @_hash.nil?
18
+ @_hash['disclaimer'] = 'disclaimer'
19
+ @_hash['exchange_rates'] = 'exchangeRates'
20
20
  @_hash
21
21
  end
22
22
 
@@ -26,20 +26,22 @@ module Raas
26
26
  @exchange_rates = exchange_rates
27
27
  end
28
28
 
29
- # Creates an instance of the object from a hash
29
+ # Creates an instance of the object from a hash.
30
30
  def self.from_hash(hash)
31
31
  return nil unless hash
32
32
 
33
- # Extract variables from the hash
33
+ # Extract variables from the hash.
34
34
  disclaimer = hash['disclaimer']
35
35
  # Parameter is an array, so we need to iterate through it
36
36
  exchange_rates = nil
37
- if hash['exchangeRates'] != nil
38
- exchange_rates = Array.new
39
- hash['exchangeRates'].each{|structure| exchange_rates << (ExchangeRateModel.from_hash(structure) if structure)}
37
+ unless hash['exchangeRates'].nil?
38
+ exchange_rates = []
39
+ hash['exchangeRates'].each do |structure|
40
+ exchange_rates << (ExchangeRateModel.from_hash(structure) if structure)
41
+ end
40
42
  end
41
43
 
42
- # Create object from extracted values
44
+ # Create object from extracted values.
43
45
  ExchangeRateResponseModel.new(disclaimer,
44
46
  exchange_rates)
45
47
  end
@@ -0,0 +1,42 @@
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Raas
5
+ # Represents a full name and an email address
6
+ class FullNameEmailModel < BaseModel
7
+ # The full name
8
+ # @return [String]
9
+ attr_accessor :full_name
10
+
11
+ # The email address
12
+ # @return [String]
13
+ attr_accessor :email_address
14
+
15
+ # A mapping from model property names to API property names.
16
+ def self.names
17
+ @_hash = {} if @_hash.nil?
18
+ @_hash['full_name'] = 'fullName'
19
+ @_hash['email_address'] = 'emailAddress'
20
+ @_hash
21
+ end
22
+
23
+ def initialize(full_name = nil,
24
+ email_address = nil)
25
+ @full_name = full_name
26
+ @email_address = email_address
27
+ end
28
+
29
+ # Creates an instance of the object from a hash.
30
+ def self.from_hash(hash)
31
+ return nil unless hash
32
+
33
+ # Extract variables from the hash.
34
+ full_name = hash['fullName']
35
+ email_address = hash['emailAddress']
36
+
37
+ # Create object from extracted values.
38
+ FullNameEmailModel.new(full_name,
39
+ email_address)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,80 @@
1
+ # This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ require 'date'
5
+ module Raas
6
+ # Represents the response from a get deposit call
7
+ class GetDepositResponseModel < BaseModel
8
+ # The deposit amount
9
+ # @return [Float]
10
+ attr_accessor :amount
11
+
12
+ # The amount charged
13
+ # @return [Float]
14
+ attr_accessor :amount_charged
15
+
16
+ # The date the deposit was made
17
+ # @return [DateTime]
18
+ attr_accessor :created_date
19
+
20
+ # The fee percentage
21
+ # @return [Float]
22
+ attr_accessor :fee_percent
23
+
24
+ # The deposit reference id
25
+ # @return [String]
26
+ attr_accessor :reference_deposit_id
27
+
28
+ # The deposit's status
29
+ # @return [String]
30
+ attr_accessor :status
31
+
32
+ # A mapping from model property names to API property names.
33
+ def self.names
34
+ @_hash = {} if @_hash.nil?
35
+ @_hash['amount'] = 'amount'
36
+ @_hash['amount_charged'] = 'amountCharged'
37
+ @_hash['created_date'] = 'createdDate'
38
+ @_hash['fee_percent'] = 'feePercent'
39
+ @_hash['reference_deposit_id'] = 'referenceDepositID'
40
+ @_hash['status'] = 'status'
41
+ @_hash
42
+ end
43
+
44
+ def initialize(amount = nil,
45
+ amount_charged = nil,
46
+ created_date = nil,
47
+ fee_percent = nil,
48
+ reference_deposit_id = nil,
49
+ status = nil)
50
+ @amount = amount
51
+ @amount_charged = amount_charged
52
+ @created_date = created_date
53
+ @fee_percent = fee_percent
54
+ @reference_deposit_id = reference_deposit_id
55
+ @status = status
56
+ end
57
+
58
+ # Creates an instance of the object from a hash.
59
+ def self.from_hash(hash)
60
+ return nil unless hash
61
+
62
+ # Extract variables from the hash.
63
+ amount = hash['amount']
64
+ amount_charged = hash['amountCharged']
65
+ created_date = APIHelper.rfc3339(hash['createdDate']) if
66
+ hash['createdDate']
67
+ fee_percent = hash['feePercent']
68
+ reference_deposit_id = hash['referenceDepositID']
69
+ status = hash['status']
70
+
71
+ # Create object from extracted values.
72
+ GetDepositResponseModel.new(amount,
73
+ amount_charged,
74
+ created_date,
75
+ fee_percent,
76
+ reference_deposit_id,
77
+ status)
78
+ end
79
+ end
80
+ end