tangocard-raas 1.1.2 → 2.2.1

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 +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
@@ -0,0 +1,155 @@
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 an Order Summary
7
+ class OrderSummaryModel < BaseModel
8
+ # The reference order id
9
+ # @return [String]
10
+ attr_accessor :reference_order_id
11
+
12
+ # The customer identifier
13
+ # @return [String]
14
+ attr_accessor :customer_identifier
15
+
16
+ # The account identifier
17
+ # @return [String]
18
+ attr_accessor :account_identifier
19
+
20
+ # The account number
21
+ # @return [String]
22
+ attr_accessor :account_number
23
+
24
+ # The order amount information
25
+ # @return [CurrencyBreakdownModel]
26
+ attr_accessor :amount_charged
27
+
28
+ # The margin share information
29
+ # @return [CurrencyBreakdownModel]
30
+ attr_accessor :margin_share
31
+
32
+ # The UTID
33
+ # @return [String]
34
+ attr_accessor :utid
35
+
36
+ # The reward's name
37
+ # @return [String]
38
+ attr_accessor :reward_name
39
+
40
+ # The sender's information
41
+ # @return [NameEmailModel]
42
+ attr_accessor :sender
43
+
44
+ # The recipient's information
45
+ # @return [NameEmailModel]
46
+ attr_accessor :recipient
47
+
48
+ # Indicates if an an email was sent to the recipient
49
+ # @return [Boolean]
50
+ attr_accessor :send_email
51
+
52
+ # The order's status
53
+ # @return [String]
54
+ attr_accessor :status
55
+
56
+ # The date the order was placed
57
+ # @return [DateTime]
58
+ attr_accessor :created_at
59
+
60
+ # The order's email template id
61
+ # @return [String]
62
+ attr_accessor :etid
63
+
64
+ # A mapping from model property names to API property names.
65
+ def self.names
66
+ @_hash = {} if @_hash.nil?
67
+ @_hash['reference_order_id'] = 'referenceOrderID'
68
+ @_hash['customer_identifier'] = 'customerIdentifier'
69
+ @_hash['account_identifier'] = 'accountIdentifier'
70
+ @_hash['account_number'] = 'accountNumber'
71
+ @_hash['amount_charged'] = 'amountCharged'
72
+ @_hash['margin_share'] = 'marginShare'
73
+ @_hash['utid'] = 'utid'
74
+ @_hash['reward_name'] = 'rewardName'
75
+ @_hash['sender'] = 'sender'
76
+ @_hash['recipient'] = 'recipient'
77
+ @_hash['send_email'] = 'sendEmail'
78
+ @_hash['status'] = 'status'
79
+ @_hash['created_at'] = 'createdAt'
80
+ @_hash['etid'] = 'etid'
81
+ @_hash
82
+ end
83
+
84
+ def initialize(reference_order_id = nil,
85
+ customer_identifier = nil,
86
+ account_identifier = nil,
87
+ account_number = nil,
88
+ amount_charged = nil,
89
+ margin_share = nil,
90
+ utid = nil,
91
+ reward_name = nil,
92
+ sender = nil,
93
+ recipient = nil,
94
+ send_email = nil,
95
+ status = nil,
96
+ created_at = nil,
97
+ etid = nil)
98
+ @reference_order_id = reference_order_id
99
+ @customer_identifier = customer_identifier
100
+ @account_identifier = account_identifier
101
+ @account_number = account_number
102
+ @amount_charged = amount_charged
103
+ @margin_share = margin_share
104
+ @utid = utid
105
+ @reward_name = reward_name
106
+ @sender = sender
107
+ @recipient = recipient
108
+ @send_email = send_email
109
+ @status = status
110
+ @created_at = created_at
111
+ @etid = etid
112
+ end
113
+
114
+ # Creates an instance of the object from a hash.
115
+ def self.from_hash(hash)
116
+ return nil unless hash
117
+
118
+ # Extract variables from the hash.
119
+ reference_order_id = hash['referenceOrderID']
120
+ customer_identifier = hash['customerIdentifier']
121
+ account_identifier = hash['accountIdentifier']
122
+ account_number = hash['accountNumber']
123
+ if hash['amountCharged']
124
+ amount_charged = CurrencyBreakdownModel.from_hash(hash['amountCharged'])
125
+ end
126
+ margin_share = CurrencyBreakdownModel.from_hash(hash['marginShare']) if
127
+ hash['marginShare']
128
+ utid = hash['utid']
129
+ reward_name = hash['rewardName']
130
+ sender = NameEmailModel.from_hash(hash['sender']) if hash['sender']
131
+ recipient = NameEmailModel.from_hash(hash['recipient']) if
132
+ hash['recipient']
133
+ send_email = hash['sendEmail']
134
+ status = hash['status']
135
+ created_at = APIHelper.rfc3339(hash['createdAt']) if hash['createdAt']
136
+ etid = hash['etid']
137
+
138
+ # Create object from extracted values.
139
+ OrderSummaryModel.new(reference_order_id,
140
+ customer_identifier,
141
+ account_identifier,
142
+ account_number,
143
+ amount_charged,
144
+ margin_share,
145
+ utid,
146
+ reward_name,
147
+ sender,
148
+ recipient,
149
+ send_email,
150
+ status,
151
+ created_at,
152
+ etid)
153
+ end
154
+ end
155
+ end
@@ -1,32 +1,32 @@
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 pagination information returned in a paginated API call
4
6
  class PageModel < BaseModel
5
- # Page Number
7
+ # The page number
6
8
  # @return [Integer]
7
9
  attr_accessor :number
8
10
 
9
- # Elements per page
11
+ # The number of elements per page
10
12
  # @return [Integer]
11
13
  attr_accessor :elements_per_block
12
14
 
13
- # Result Count
15
+ # The number of results returned
14
16
  # @return [Integer]
15
17
  attr_accessor :result_count
16
18
 
17
- # Total Count
19
+ # The total number of results
18
20
  # @return [Integer]
19
21
  attr_accessor :total_count
20
22
 
21
- # A mapping from model property names to API property names
23
+ # A mapping from model property names to API property names.
22
24
  def self.names
23
- if @_hash.nil?
24
- @_hash = {}
25
- @_hash["number"] = "number"
26
- @_hash["elements_per_block"] = "elementsPerBlock"
27
- @_hash["result_count"] = "resultCount"
28
- @_hash["total_count"] = "totalCount"
29
- end
25
+ @_hash = {} if @_hash.nil?
26
+ @_hash['number'] = 'number'
27
+ @_hash['elements_per_block'] = 'elementsPerBlock'
28
+ @_hash['result_count'] = 'resultCount'
29
+ @_hash['total_count'] = 'totalCount'
30
30
  @_hash
31
31
  end
32
32
 
@@ -40,17 +40,17 @@ module Raas
40
40
  @total_count = total_count
41
41
  end
42
42
 
43
- # Creates an instance of the object from a hash
43
+ # Creates an instance of the object from a hash.
44
44
  def self.from_hash(hash)
45
45
  return nil unless hash
46
46
 
47
- # Extract variables from the hash
47
+ # Extract variables from the hash.
48
48
  number = hash['number']
49
49
  elements_per_block = hash['elementsPerBlock']
50
50
  result_count = hash['resultCount']
51
51
  total_count = hash['totalCount']
52
52
 
53
- # Create object from extracted values
53
+ # Create object from extracted values.
54
54
  PageModel.new(number,
55
55
  elements_per_block,
56
56
  result_count,
@@ -1,32 +1,32 @@
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 a RaaS 4xx Error
4
6
  class RaasClientErrorModel < BaseModel
5
- # Error Path
7
+ # The path to the invalid value
6
8
  # @return [String]
7
9
  attr_accessor :path
8
10
 
9
- # Error Message
11
+ # The error message
10
12
  # @return [String]
11
13
  attr_accessor :message
12
14
 
13
- # Constraint
15
+ # The constraint validated
14
16
  # @return [String]
15
17
  attr_accessor :constraint
16
18
 
17
- # Invalid Value
19
+ # The value that was invalid
18
20
  # @return [String]
19
21
  attr_accessor :invalid_value
20
22
 
21
- # A mapping from model property names to API property names
23
+ # A mapping from model property names to API property names.
22
24
  def self.names
23
- if @_hash.nil?
24
- @_hash = {}
25
- @_hash["path"] = "path"
26
- @_hash["message"] = "message"
27
- @_hash["constraint"] = "constraint"
28
- @_hash["invalid_value"] = "invalidValue"
29
- end
25
+ @_hash = {} if @_hash.nil?
26
+ @_hash['path'] = 'path'
27
+ @_hash['message'] = 'message'
28
+ @_hash['constraint'] = 'constraint'
29
+ @_hash['invalid_value'] = 'invalidValue'
30
30
  @_hash
31
31
  end
32
32
 
@@ -40,17 +40,17 @@ module Raas
40
40
  @invalid_value = invalid_value
41
41
  end
42
42
 
43
- # Creates an instance of the object from a hash
43
+ # Creates an instance of the object from a hash.
44
44
  def self.from_hash(hash)
45
45
  return nil unless hash
46
46
 
47
- # Extract variables from the hash
47
+ # Extract variables from the hash.
48
48
  path = hash['path']
49
49
  message = hash['message']
50
50
  constraint = hash['constraint']
51
51
  invalid_value = hash['invalidValue']
52
52
 
53
- # Create object from extracted values
53
+ # Create object from extracted values.
54
54
  RaasClientErrorModel.new(path,
55
55
  message,
56
56
  constraint,
@@ -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 a RaaS 5xx Error
4
6
  class RaasServerErrorModel < BaseModel
5
- # Error Message
7
+ # The error message
6
8
  # @return [String]
7
9
  attr_accessor :message
8
10
 
9
- # Error Code
11
+ # The RaaS error code
10
12
  # @return [Integer]
11
13
  attr_accessor :code
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["message"] = "message"
18
- @_hash["code"] = "code"
19
- end
17
+ @_hash = {} if @_hash.nil?
18
+ @_hash['message'] = 'message'
19
+ @_hash['code'] = 'code'
20
20
  @_hash
21
21
  end
22
22
 
@@ -26,15 +26,15 @@ module Raas
26
26
  @code = code
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
  message = hash['message']
35
35
  code = hash['code']
36
36
 
37
- # Create object from extracted values
37
+ # Create object from extracted values.
38
38
  RaasServerErrorModel.new(message,
39
39
  code)
40
40
  end
@@ -1,7 +1,9 @@
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 the response returned from a resend order request
5
7
  class ResendOrderResponseModel < BaseModel
6
8
  # When the resend request was created
7
9
  # @return [DateTime]
@@ -11,13 +13,11 @@ module Raas
11
13
  # @return [Integer]
12
14
  attr_accessor :id
13
15
 
14
- # A mapping from model property names to API property names
16
+ # A mapping from model property names to API property names.
15
17
  def self.names
16
- if @_hash.nil?
17
- @_hash = {}
18
- @_hash["created_at"] = "createdAt"
19
- @_hash["id"] = "id"
20
- end
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['created_at'] = 'createdAt'
20
+ @_hash['id'] = 'id'
21
21
  @_hash
22
22
  end
23
23
 
@@ -27,15 +27,15 @@ module Raas
27
27
  @id = id
28
28
  end
29
29
 
30
- # Creates an instance of the object from a hash
30
+ # Creates an instance of the object from a hash.
31
31
  def self.from_hash(hash)
32
32
  return nil unless hash
33
33
 
34
- # Extract variables from the hash
35
- created_at = DateTime.rfc3339(hash['createdAt']) if hash['createdAt']
34
+ # Extract variables from the hash.
35
+ created_at = APIHelper.rfc3339(hash['createdAt']) if hash['createdAt']
36
36
  id = hash['id']
37
37
 
38
- # Create object from extracted values
38
+ # Create object from extracted values.
39
39
  ResendOrderResponseModel.new(created_at,
40
40
  id)
41
41
  end
@@ -1,27 +1,27 @@
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 a Reward Credential
4
6
  class RewardCredentialModel < BaseModel
5
- # Credential Label
7
+ # The label of the credential
6
8
  # @return [String]
7
9
  attr_accessor :label
8
10
 
9
- # Credential Value
11
+ # The actual credential
10
12
  # @return [String]
11
13
  attr_accessor :value
12
14
 
13
- # Credential Type
15
+ # The type of the credential
14
16
  # @return [String]
15
17
  attr_accessor :type
16
18
 
17
- # A mapping from model property names to API property names
19
+ # A mapping from model property names to API property names.
18
20
  def self.names
19
- if @_hash.nil?
20
- @_hash = {}
21
- @_hash["label"] = "label"
22
- @_hash["value"] = "value"
23
- @_hash["type"] = "type"
24
- end
21
+ @_hash = {} if @_hash.nil?
22
+ @_hash['label'] = 'label'
23
+ @_hash['value'] = 'value'
24
+ @_hash['type'] = 'type'
25
25
  @_hash
26
26
  end
27
27
 
@@ -33,16 +33,16 @@ module Raas
33
33
  @type = type
34
34
  end
35
35
 
36
- # Creates an instance of the object from a hash
36
+ # Creates an instance of the object from a hash.
37
37
  def self.from_hash(hash)
38
38
  return nil unless hash
39
39
 
40
- # Extract variables from the hash
40
+ # Extract variables from the hash.
41
41
  label = hash['label']
42
42
  value = hash['value']
43
43
  type = hash['type']
44
44
 
45
- # Create object from extracted values
45
+ # Create object from extracted values.
46
46
  RewardCredentialModel.new(label,
47
47
  value,
48
48
  type)
@@ -1,6 +1,8 @@
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 a Reward
4
6
  class RewardModel < BaseModel
5
7
  # A map of reward credentials
6
8
  # @return [Array<String, String>]
@@ -14,14 +16,12 @@ module Raas
14
16
  # @return [String]
15
17
  attr_accessor :redemption_instructions
16
18
 
17
- # A mapping from model property names to API property names
19
+ # A mapping from model property names to API property names.
18
20
  def self.names
19
- if @_hash.nil?
20
- @_hash = {}
21
- @_hash["credentials"] = "credentials"
22
- @_hash["credential_list"] = "credentialList"
23
- @_hash["redemption_instructions"] = "redemptionInstructions"
24
- end
21
+ @_hash = {} if @_hash.nil?
22
+ @_hash['credentials'] = 'credentials'
23
+ @_hash['credential_list'] = 'credentialList'
24
+ @_hash['redemption_instructions'] = 'redemptionInstructions'
25
25
  @_hash
26
26
  end
27
27
 
@@ -33,21 +33,23 @@ module Raas
33
33
  @redemption_instructions = redemption_instructions
34
34
  end
35
35
 
36
- # Creates an instance of the object from a hash
36
+ # Creates an instance of the object from a hash.
37
37
  def self.from_hash(hash)
38
38
  return nil unless hash
39
39
 
40
- # Extract variables from the hash
40
+ # Extract variables from the hash.
41
41
  credentials = hash['credentials']
42
42
  # Parameter is an array, so we need to iterate through it
43
43
  credential_list = nil
44
- if hash['credentialList'] != nil
45
- credential_list = Array.new
46
- hash['credentialList'].each{|structure| credential_list << (RewardCredentialModel.from_hash(structure) if structure)}
44
+ unless hash['credentialList'].nil?
45
+ credential_list = []
46
+ hash['credentialList'].each do |structure|
47
+ credential_list << (RewardCredentialModel.from_hash(structure) if structure)
48
+ end
47
49
  end
48
50
  redemption_instructions = hash['redemptionInstructions']
49
51
 
50
- # Create object from extracted values
52
+ # Create object from extracted values.
51
53
  RewardModel.new(credentials,
52
54
  credential_list,
53
55
  redemption_instructions)