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.
- checksums.yaml +4 -4
- data/LICENSE +28 -175
- data/README.md +38 -525
- data/lib/raas.rb +32 -19
- data/lib/raas/api_helper.rb +146 -54
- data/lib/raas/configuration.rb +22 -30
- data/lib/raas/controllers/accounts_controller.rb +146 -92
- data/lib/raas/controllers/base_controller.rb +32 -29
- data/lib/raas/controllers/catalog_controller.rb +31 -14
- data/lib/raas/controllers/customers_controller.rb +113 -72
- data/lib/raas/controllers/exchange_rates_controller.rb +40 -12
- data/lib/raas/controllers/fund_controller.rb +345 -0
- data/lib/raas/controllers/orders_controller.rb +166 -105
- data/lib/raas/controllers/status_controller.rb +31 -14
- data/lib/raas/exceptions/api_exception.rb +4 -2
- data/lib/raas/exceptions/raas_client_exception.rb +14 -12
- data/lib/raas/exceptions/raas_generic_exception.rb +9 -9
- data/lib/raas/exceptions/raas_server_exception.rb +14 -12
- data/lib/raas/http/auth/basic_auth.rb +7 -4
- data/lib/raas/http/faraday_client.rb +19 -7
- data/lib/raas/http/http_call_back.rb +11 -6
- data/lib/raas/http/http_client.rb +50 -32
- data/lib/raas/http/http_context.rb +5 -2
- data/lib/raas/http/http_method_enum.rb +6 -2
- data/lib/raas/http/http_request.rb +7 -3
- data/lib/raas/http/http_response.rb +3 -1
- data/lib/raas/models/account_model.rb +32 -23
- data/lib/raas/models/account_summary_model.rb +26 -17
- data/lib/raas/models/base_model.rb +11 -9
- data/lib/raas/models/billing_address_model.rb +105 -0
- data/lib/raas/models/brand_model.rb +39 -35
- data/lib/raas/models/catalog_model.rb +15 -13
- data/lib/raas/models/create_account_request_model.rb +14 -14
- data/lib/raas/models/create_credit_card_request_model.rb +96 -0
- data/lib/raas/models/create_customer_request_model.rb +12 -12
- data/lib/raas/models/create_order_request_model.rb +45 -35
- data/lib/raas/models/credit_card_model.rb +124 -0
- data/lib/raas/models/currency_breakdown_model.rb +18 -18
- data/lib/raas/models/customer_model.rb +24 -22
- data/lib/raas/models/deposit_request_model.rb +60 -0
- data/lib/raas/models/deposit_response_model.rb +80 -0
- data/lib/raas/models/exchange_rate_model.rb +18 -17
- data/lib/raas/models/exchange_rate_response_model.rb +17 -15
- data/lib/raas/models/full_name_email_model.rb +42 -0
- data/lib/raas/models/get_deposit_response_model.rb +80 -0
- data/lib/raas/models/get_orders_response_model.rb +16 -14
- data/lib/raas/models/item_model.rb +36 -34
- data/lib/raas/models/name_email_model.rb +14 -14
- data/lib/raas/models/new_credit_card_model.rb +51 -0
- data/lib/raas/models/order_model.rb +124 -92
- data/lib/raas/models/order_summary_model.rb +155 -0
- data/lib/raas/models/page_model.rb +16 -16
- data/lib/raas/models/raas_client_error_model.rb +16 -16
- data/lib/raas/models/raas_server_error_model.rb +12 -12
- data/lib/raas/models/resend_order_response_model.rb +11 -11
- data/lib/raas/models/reward_credential_model.rb +14 -14
- data/lib/raas/models/reward_model.rb +16 -14
- data/lib/raas/models/system_status_response_model.rb +10 -10
- data/lib/raas/models/unregister_credit_card_request_model.rb +51 -0
- data/lib/raas/models/unregister_credit_card_response_model.rb +53 -0
- data/lib/raas/raas_client.rb +36 -25
- data/test/controllers/controller_test_base.rb +31 -0
- data/test/controllers/test_accounts_controller.rb +79 -0
- data/test/controllers/test_catalog_controller.rb +65 -0
- data/test/controllers/test_customers_controller.rb +61 -0
- data/test/controllers/test_exchange_rates_controller.rb +35 -0
- data/test/controllers/test_fund_controller.rb +108 -0
- data/test/controllers/test_orders_controller.rb +86 -0
- data/test/controllers/test_status_controller.rb +27 -0
- data/test/http_response_catcher.rb +16 -0
- data/test/test_helper.rb +91 -0
- metadata +32 -10
@@ -1,96 +1,70 @@
|
|
1
|
-
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
|
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
|
+
# OrdersController
|
4
6
|
class OrdersController < BaseController
|
5
|
-
|
6
|
-
# Singleton instance of the controller class
|
7
|
-
def self.instance
|
8
|
-
@@instance
|
9
|
-
end
|
7
|
+
@instance = OrdersController.new
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def create_order(body)
|
15
|
-
begin
|
16
|
-
@logger.info("create_order called.")
|
17
|
-
|
18
|
-
# validate required parameters
|
19
|
-
@logger.info("Validating required parameters for create_order.")
|
20
|
-
validate_parameters({
|
21
|
-
'body' => body
|
22
|
-
})
|
23
|
-
|
24
|
-
# prepare query url
|
25
|
-
@logger.info("Preparing query URL for create_order.")
|
26
|
-
_query_builder = Configuration.get_base_uri()
|
27
|
-
_query_builder << '/orders'
|
28
|
-
_query_url = APIHelper.clean_url _query_builder
|
29
|
-
|
30
|
-
# prepare headers
|
31
|
-
@logger.info("Preparing headers for create_order.")
|
32
|
-
_headers = {
|
33
|
-
'accept' => 'application/json',
|
34
|
-
'content-type' => 'application/json; charset=utf-8'
|
35
|
-
}
|
36
|
-
|
37
|
-
# prepare and execute HttpRequest
|
38
|
-
@logger.info('Preparing and executing HttpRequest for create_order.')
|
39
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: body.to_json
|
40
|
-
BasicAuth.apply(_request)
|
41
|
-
_context = execute_request(_request, name: 'create_order')
|
42
|
-
validate_response(_context)
|
43
|
-
|
44
|
-
# return appropriate response type
|
45
|
-
@logger.info("Returning response for create_order.")
|
46
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
47
|
-
return OrderModel.from_hash(decoded)
|
9
|
+
class << self
|
10
|
+
attr_accessor :instance
|
11
|
+
end
|
48
12
|
|
49
|
-
|
50
|
-
|
51
|
-
raise e
|
52
|
-
end
|
13
|
+
def instance
|
14
|
+
self.class.instance
|
53
15
|
end
|
54
16
|
|
55
|
-
#
|
56
|
-
# @param [String] reference_order_id Required parameter: Reference Order
|
17
|
+
# Retrieves a single order
|
18
|
+
# @param [String] reference_order_id Required parameter: Reference Order
|
19
|
+
# ID
|
57
20
|
# @return OrderModel response from the API call
|
58
21
|
def get_order(reference_order_id)
|
59
22
|
begin
|
60
23
|
@logger.info("get_order called.")
|
61
|
-
|
62
|
-
# validate required parameters
|
24
|
+
# Validate required parameters.
|
63
25
|
@logger.info("Validating required parameters for get_order.")
|
64
|
-
validate_parameters(
|
26
|
+
validate_parameters(
|
65
27
|
'reference_order_id' => reference_order_id
|
66
|
-
|
67
|
-
|
68
|
-
# prepare query url
|
28
|
+
)
|
29
|
+
# Prepare query url.
|
69
30
|
@logger.info("Preparing query URL for get_order.")
|
70
|
-
_query_builder = Configuration.get_base_uri
|
31
|
+
_query_builder = Configuration.get_base_uri
|
71
32
|
_query_builder << '/orders/{referenceOrderID}'
|
72
|
-
_query_builder = APIHelper.append_url_with_template_parameters
|
33
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
34
|
+
_query_builder,
|
73
35
|
'referenceOrderID' => reference_order_id
|
74
|
-
|
36
|
+
)
|
75
37
|
_query_url = APIHelper.clean_url _query_builder
|
76
38
|
|
77
|
-
#
|
39
|
+
# Prepare headers.
|
78
40
|
@logger.info("Preparing headers for get_order.")
|
79
41
|
_headers = {
|
80
42
|
'accept' => 'application/json'
|
81
43
|
}
|
82
44
|
|
83
|
-
#
|
45
|
+
# Prepare and execute HttpRequest.
|
84
46
|
@logger.info('Preparing and executing HttpRequest for get_order.')
|
85
|
-
_request = @http_client.get
|
47
|
+
_request = @http_client.get(
|
48
|
+
_query_url,
|
49
|
+
headers: _headers
|
50
|
+
)
|
86
51
|
BasicAuth.apply(_request)
|
87
52
|
_context = execute_request(_request, name: 'get_order')
|
53
|
+
|
54
|
+
# Validate response against endpoint and global error codes.
|
55
|
+
@logger.info("Validating response for get_order.")
|
56
|
+
unless _context.response.status_code.between?(200, 208)
|
57
|
+
raise RaasGenericException.new(
|
58
|
+
'API Error',
|
59
|
+
_context
|
60
|
+
)
|
61
|
+
end
|
88
62
|
validate_response(_context)
|
89
63
|
|
90
|
-
#
|
64
|
+
# Return appropriate response type.
|
91
65
|
@logger.info("Returning response for get_order.")
|
92
66
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
93
|
-
|
67
|
+
OrderModel.from_hash(decoded)
|
94
68
|
|
95
69
|
rescue Exception => e
|
96
70
|
@logger.error(e)
|
@@ -98,45 +72,57 @@ module Raas
|
|
98
72
|
end
|
99
73
|
end
|
100
74
|
|
101
|
-
#
|
102
|
-
# @param [String] reference_order_id Required parameter:
|
75
|
+
# Resends an order
|
76
|
+
# @param [String] reference_order_id Required parameter: The order's
|
77
|
+
# reference order id
|
103
78
|
# @return ResendOrderResponseModel response from the API call
|
104
79
|
def create_resend_order(reference_order_id)
|
105
80
|
begin
|
106
81
|
@logger.info("create_resend_order called.")
|
107
|
-
|
108
|
-
# validate required parameters
|
82
|
+
# Validate required parameters.
|
109
83
|
@logger.info("Validating required parameters for create_resend_order.")
|
110
|
-
validate_parameters(
|
84
|
+
validate_parameters(
|
111
85
|
'reference_order_id' => reference_order_id
|
112
|
-
|
113
|
-
|
114
|
-
# prepare query url
|
86
|
+
)
|
87
|
+
# Prepare query url.
|
115
88
|
@logger.info("Preparing query URL for create_resend_order.")
|
116
|
-
_query_builder = Configuration.get_base_uri
|
89
|
+
_query_builder = Configuration.get_base_uri
|
117
90
|
_query_builder << '/orders/{referenceOrderID}/resends'
|
118
|
-
_query_builder = APIHelper.append_url_with_template_parameters
|
91
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
92
|
+
_query_builder,
|
119
93
|
'referenceOrderID' => reference_order_id
|
120
|
-
|
94
|
+
)
|
121
95
|
_query_url = APIHelper.clean_url _query_builder
|
122
96
|
|
123
|
-
#
|
97
|
+
# Prepare headers.
|
124
98
|
@logger.info("Preparing headers for create_resend_order.")
|
125
99
|
_headers = {
|
126
100
|
'accept' => 'application/json'
|
127
101
|
}
|
128
102
|
|
129
|
-
#
|
103
|
+
# Prepare and execute HttpRequest.
|
130
104
|
@logger.info('Preparing and executing HttpRequest for create_resend_order.')
|
131
|
-
_request = @http_client.post
|
105
|
+
_request = @http_client.post(
|
106
|
+
_query_url,
|
107
|
+
headers: _headers
|
108
|
+
)
|
132
109
|
BasicAuth.apply(_request)
|
133
110
|
_context = execute_request(_request, name: 'create_resend_order')
|
111
|
+
|
112
|
+
# Validate response against endpoint and global error codes.
|
113
|
+
@logger.info("Validating response for create_resend_order.")
|
114
|
+
unless _context.response.status_code.between?(200, 208)
|
115
|
+
raise RaasGenericException.new(
|
116
|
+
'API Error',
|
117
|
+
_context
|
118
|
+
)
|
119
|
+
end
|
134
120
|
validate_response(_context)
|
135
121
|
|
136
|
-
#
|
122
|
+
# Return appropriate response type.
|
137
123
|
@logger.info("Returning response for create_resend_order.")
|
138
124
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
139
|
-
|
125
|
+
ResendOrderResponseModel.from_hash(decoded)
|
140
126
|
|
141
127
|
rescue Exception => e
|
142
128
|
@logger.error(e)
|
@@ -144,51 +130,126 @@ module Raas
|
|
144
130
|
end
|
145
131
|
end
|
146
132
|
|
147
|
-
#
|
148
|
-
# @param [String] account_identifier Optional parameter:
|
149
|
-
#
|
150
|
-
# @param [String]
|
151
|
-
#
|
152
|
-
# @param [
|
153
|
-
#
|
154
|
-
# @param [
|
133
|
+
# Retrieves a list of orders under a platform
|
134
|
+
# @param [String] account_identifier Optional parameter: Account
|
135
|
+
# identifier
|
136
|
+
# @param [String] customer_identifier Optional parameter: Customer
|
137
|
+
# identifier
|
138
|
+
# @param [String] external_ref_id Optional parameter: External reference
|
139
|
+
# id
|
140
|
+
# @param [DateTime] start_date Optional parameter: The start date
|
141
|
+
# @param [DateTime] end_date Optional parameter: The end date
|
142
|
+
# @param [Integer] elements_per_block Optional parameter: The number of
|
143
|
+
# elements per page
|
144
|
+
# @param [Integer] page Optional parameter: The page number to return
|
155
145
|
# @return GetOrdersResponseModel response from the API call
|
156
|
-
def get_orders(options =
|
146
|
+
def get_orders(options = {})
|
157
147
|
begin
|
158
148
|
@logger.info("get_orders called.")
|
159
|
-
|
160
|
-
# prepare query url
|
149
|
+
# Prepare query url.
|
161
150
|
@logger.info("Preparing query URL for get_orders.")
|
162
|
-
_query_builder = Configuration.get_base_uri
|
151
|
+
_query_builder = Configuration.get_base_uri
|
163
152
|
_query_builder << '/orders'
|
164
|
-
_query_builder = APIHelper.append_url_with_query_parameters
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
153
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
154
|
+
_query_builder,
|
155
|
+
{
|
156
|
+
'accountIdentifier' => options['account_identifier'],
|
157
|
+
'customerIdentifier' => options['customer_identifier'],
|
158
|
+
'externalRefID' => options['external_ref_id'],
|
159
|
+
'startDate' => options['start_date'],
|
160
|
+
'endDate' => options['end_date'],
|
161
|
+
'elementsPerBlock' => options['elements_per_block'],
|
162
|
+
'page' => options['page']
|
163
|
+
},
|
164
|
+
array_serialization: Configuration.array_serialization
|
165
|
+
)
|
173
166
|
_query_url = APIHelper.clean_url _query_builder
|
174
167
|
|
175
|
-
#
|
168
|
+
# Prepare headers.
|
176
169
|
@logger.info("Preparing headers for get_orders.")
|
177
170
|
_headers = {
|
178
171
|
'accept' => 'application/json'
|
179
172
|
}
|
180
173
|
|
181
|
-
#
|
174
|
+
# Prepare and execute HttpRequest.
|
182
175
|
@logger.info('Preparing and executing HttpRequest for get_orders.')
|
183
|
-
_request = @http_client.get
|
176
|
+
_request = @http_client.get(
|
177
|
+
_query_url,
|
178
|
+
headers: _headers
|
179
|
+
)
|
184
180
|
BasicAuth.apply(_request)
|
185
181
|
_context = execute_request(_request, name: 'get_orders')
|
182
|
+
|
183
|
+
# Validate response against endpoint and global error codes.
|
184
|
+
@logger.info("Validating response for get_orders.")
|
185
|
+
unless _context.response.status_code.between?(200, 208)
|
186
|
+
raise RaasGenericException.new(
|
187
|
+
'API Error',
|
188
|
+
_context
|
189
|
+
)
|
190
|
+
end
|
186
191
|
validate_response(_context)
|
187
192
|
|
188
|
-
#
|
193
|
+
# Return appropriate response type.
|
189
194
|
@logger.info("Returning response for get_orders.")
|
190
195
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
191
|
-
|
196
|
+
GetOrdersResponseModel.from_hash(decoded)
|
197
|
+
|
198
|
+
rescue Exception => e
|
199
|
+
@logger.error(e)
|
200
|
+
raise e
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Places an order
|
205
|
+
# @param [CreateOrderRequestModel] body Required parameter: A
|
206
|
+
# CreateOrderRequest object
|
207
|
+
# @return OrderModel response from the API call
|
208
|
+
def create_order(body)
|
209
|
+
begin
|
210
|
+
@logger.info("create_order called.")
|
211
|
+
# Validate required parameters.
|
212
|
+
@logger.info("Validating required parameters for create_order.")
|
213
|
+
validate_parameters(
|
214
|
+
'body' => body
|
215
|
+
)
|
216
|
+
# Prepare query url.
|
217
|
+
@logger.info("Preparing query URL for create_order.")
|
218
|
+
_query_builder = Configuration.get_base_uri
|
219
|
+
_query_builder << '/orders'
|
220
|
+
_query_url = APIHelper.clean_url _query_builder
|
221
|
+
|
222
|
+
# Prepare headers.
|
223
|
+
@logger.info("Preparing headers for create_order.")
|
224
|
+
_headers = {
|
225
|
+
'accept' => 'application/json',
|
226
|
+
'content-type' => 'application/json; charset=utf-8'
|
227
|
+
}
|
228
|
+
|
229
|
+
# Prepare and execute HttpRequest.
|
230
|
+
@logger.info('Preparing and executing HttpRequest for create_order.')
|
231
|
+
_request = @http_client.post(
|
232
|
+
_query_url,
|
233
|
+
headers: _headers,
|
234
|
+
parameters: body.to_json
|
235
|
+
)
|
236
|
+
BasicAuth.apply(_request)
|
237
|
+
_context = execute_request(_request, name: 'create_order')
|
238
|
+
|
239
|
+
# Validate response against endpoint and global error codes.
|
240
|
+
@logger.info("Validating response for create_order.")
|
241
|
+
unless _context.response.status_code.between?(200, 208)
|
242
|
+
raise RaasGenericException.new(
|
243
|
+
'API Error',
|
244
|
+
_context
|
245
|
+
)
|
246
|
+
end
|
247
|
+
validate_response(_context)
|
248
|
+
|
249
|
+
# Return appropriate response type.
|
250
|
+
@logger.info("Returning response for create_order.")
|
251
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
252
|
+
OrderModel.from_hash(decoded)
|
192
253
|
|
193
254
|
rescue Exception => e
|
194
255
|
@logger.error(e)
|
@@ -1,41 +1,58 @@
|
|
1
|
-
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
|
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
|
+
# StatusController
|
4
6
|
class StatusController < BaseController
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
@instance = StatusController.new
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :instance
|
11
|
+
end
|
12
|
+
|
13
|
+
def instance
|
14
|
+
self.class.instance
|
9
15
|
end
|
10
16
|
|
11
|
-
#
|
17
|
+
# Retrieves system status
|
12
18
|
# @return SystemStatusResponseModel response from the API call
|
13
19
|
def get_system_status
|
14
20
|
begin
|
15
21
|
@logger.info("get_system_status called.")
|
16
|
-
|
17
|
-
# prepare query url
|
22
|
+
# Prepare query url.
|
18
23
|
@logger.info("Preparing query URL for get_system_status.")
|
19
|
-
_query_builder = Configuration.get_base_uri
|
24
|
+
_query_builder = Configuration.get_base_uri
|
20
25
|
_query_builder << '/pulse'
|
21
26
|
_query_url = APIHelper.clean_url _query_builder
|
22
27
|
|
23
|
-
#
|
28
|
+
# Prepare headers.
|
24
29
|
@logger.info("Preparing headers for get_system_status.")
|
25
30
|
_headers = {
|
26
31
|
'accept' => 'application/json'
|
27
32
|
}
|
28
33
|
|
29
|
-
#
|
34
|
+
# Prepare and execute HttpRequest.
|
30
35
|
@logger.info('Preparing and executing HttpRequest for get_system_status.')
|
31
|
-
_request = @http_client.get
|
36
|
+
_request = @http_client.get(
|
37
|
+
_query_url,
|
38
|
+
headers: _headers
|
39
|
+
)
|
32
40
|
_context = execute_request(_request, name: 'get_system_status')
|
41
|
+
|
42
|
+
# Validate response against endpoint and global error codes.
|
43
|
+
@logger.info("Validating response for get_system_status.")
|
44
|
+
unless _context.response.status_code.between?(200, 208)
|
45
|
+
raise RaasGenericException.new(
|
46
|
+
'API Error',
|
47
|
+
_context
|
48
|
+
)
|
49
|
+
end
|
33
50
|
validate_response(_context)
|
34
51
|
|
35
|
-
#
|
52
|
+
# Return appropriate response type.
|
36
53
|
@logger.info("Returning response for get_system_status.")
|
37
54
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
38
|
-
|
55
|
+
SystemStatusResponseModel.from_hash(decoded)
|
39
56
|
|
40
57
|
rescue Exception => e
|
41
58
|
@logger.error(e)
|
@@ -1,11 +1,13 @@
|
|
1
|
-
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
|
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
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
4
6
|
class APIException < StandardError
|
5
7
|
attr_reader :context, :response_code
|
6
8
|
|
7
9
|
# The constructor.
|
8
|
-
# @param [String] The reason for raising an exception
|
10
|
+
# @param [String] The reason for raising an exception.
|
9
11
|
# @param [HttpContext] The HttpContext of the API call.
|
10
12
|
def initialize(reason, context)
|
11
13
|
super(reason)
|
@@ -1,7 +1,9 @@
|
|
1
|
-
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0
|
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
|
+
# RaaS API 4xx Exception
|
5
7
|
class RaasClientException < APIException
|
6
8
|
# Request timestamp
|
7
9
|
# @return [DateTime]
|
@@ -28,30 +30,30 @@ module Raas
|
|
28
30
|
attr_accessor :errors
|
29
31
|
|
30
32
|
# The constructor.
|
31
|
-
# @param [String] The reason for raising an exception
|
33
|
+
# @param [String] The reason for raising an exception.
|
32
34
|
# @param [HttpContext] The HttpContext of the API call.
|
33
35
|
def initialize(reason, context)
|
34
36
|
super(reason, context)
|
35
|
-
|
36
|
-
|
37
|
-
unbox(hash)
|
38
|
-
rescue TypeError
|
39
|
-
end
|
37
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
38
|
+
unbox(hash)
|
40
39
|
end
|
41
40
|
|
42
41
|
# Populates this object by extracting properties from a hash.
|
43
|
-
# @param [Hash] The deserialized response sent by the server in the
|
42
|
+
# @param [Hash] The deserialized response sent by the server in the
|
43
|
+
# response body.
|
44
44
|
def unbox(hash)
|
45
|
-
@timestamp =
|
45
|
+
@timestamp = APIHelper.rfc3339(hash['timestamp']) if hash['timestamp']
|
46
46
|
@request_id = hash['requestId']
|
47
47
|
@path = hash['path']
|
48
48
|
@http_code = hash['httpCode']
|
49
49
|
@http_phrase = hash['httpPhrase']
|
50
50
|
# Parameter is an array, so we need to iterate through it
|
51
51
|
@errors = nil
|
52
|
-
|
53
|
-
@errors =
|
54
|
-
hash['errors'].each
|
52
|
+
unless hash['errors'].nil?
|
53
|
+
@errors = []
|
54
|
+
hash['errors'].each do |structure|
|
55
|
+
@errors << (RaasClientErrorModel.from_hash(structure) if structure)
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|