tangocard-raas 1.1.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.
- checksums.yaml +7 -0
- data/LICENSE +175 -0
- data/README.md +542 -0
- data/lib/raas.rb +61 -0
- data/lib/raas/api_helper.rb +181 -0
- data/lib/raas/configuration.rb +72 -0
- data/lib/raas/controllers/accounts_controller.rb +189 -0
- data/lib/raas/controllers/base_controller.rb +68 -0
- data/lib/raas/controllers/catalog_controller.rb +47 -0
- data/lib/raas/controllers/customers_controller.rb +137 -0
- data/lib/raas/controllers/exchange_rates_controller.rb +36 -0
- data/lib/raas/controllers/orders_controller.rb +199 -0
- data/lib/raas/controllers/status_controller.rb +46 -0
- data/lib/raas/exceptions/api_exception.rb +16 -0
- data/lib/raas/exceptions/raas_client_exception.rb +58 -0
- data/lib/raas/exceptions/raas_generic_exception.rb +53 -0
- data/lib/raas/exceptions/raas_server_exception.rb +58 -0
- data/lib/raas/http/auth/basic_auth.rb +17 -0
- data/lib/raas/http/faraday_client.rb +43 -0
- data/lib/raas/http/http_call_back.rb +17 -0
- data/lib/raas/http/http_client.rb +84 -0
- data/lib/raas/http/http_context.rb +15 -0
- data/lib/raas/http/http_method_enum.rb +7 -0
- data/lib/raas/http/http_request.rb +44 -0
- data/lib/raas/http/http_response.rb +19 -0
- data/lib/raas/models/account_model.rb +88 -0
- data/lib/raas/models/account_summary_model.rb +61 -0
- data/lib/raas/models/base_model.rb +32 -0
- data/lib/raas/models/brand_model.rb +129 -0
- data/lib/raas/models/catalog_model.rb +47 -0
- data/lib/raas/models/create_account_request_model.rb +51 -0
- data/lib/raas/models/create_customer_request_model.rb +42 -0
- data/lib/raas/models/create_order_request_model.rb +132 -0
- data/lib/raas/models/currency_breakdown_model.rb +69 -0
- data/lib/raas/models/customer_model.rb +75 -0
- data/lib/raas/models/exchange_rate_model.rb +61 -0
- data/lib/raas/models/exchange_rate_response_model.rb +47 -0
- data/lib/raas/models/get_orders_response_model.rb +47 -0
- data/lib/raas/models/item_model.rb +133 -0
- data/lib/raas/models/name_email_model.rb +51 -0
- data/lib/raas/models/order_model.rb +187 -0
- data/lib/raas/models/page_model.rb +60 -0
- data/lib/raas/models/raas_client_error_model.rb +60 -0
- data/lib/raas/models/raas_server_error_model.rb +42 -0
- data/lib/raas/models/resend_order_response_model.rb +43 -0
- data/lib/raas/models/reward_credential_model.rb +51 -0
- data/lib/raas/models/reward_model.rb +56 -0
- data/lib/raas/models/system_status_response_model.rb +33 -0
- data/lib/raas/raas_client.rb +53 -0
- metadata +175 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class StatusController < BaseController
|
5
|
+
@@instance = StatusController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Retrieve system status
|
12
|
+
# @return SystemStatusResponseModel response from the API call
|
13
|
+
def get_system_status
|
14
|
+
begin
|
15
|
+
@logger.info("get_system_status called.")
|
16
|
+
|
17
|
+
# prepare query url
|
18
|
+
@logger.info("Preparing query URL for get_system_status.")
|
19
|
+
_query_builder = Configuration.get_base_uri()
|
20
|
+
_query_builder << '/pulse'
|
21
|
+
_query_url = APIHelper.clean_url _query_builder
|
22
|
+
|
23
|
+
# prepare headers
|
24
|
+
@logger.info("Preparing headers for get_system_status.")
|
25
|
+
_headers = {
|
26
|
+
'accept' => 'application/json'
|
27
|
+
}
|
28
|
+
|
29
|
+
# prepare and execute HttpRequest
|
30
|
+
@logger.info('Preparing and executing HttpRequest for get_system_status.')
|
31
|
+
_request = @http_client.get _query_url, headers: _headers
|
32
|
+
_context = execute_request(_request, name: 'get_system_status')
|
33
|
+
validate_response(_context)
|
34
|
+
|
35
|
+
# return appropriate response type
|
36
|
+
@logger.info("Returning response for get_system_status.")
|
37
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
38
|
+
return SystemStatusResponseModel.from_hash(decoded)
|
39
|
+
|
40
|
+
rescue Exception => e
|
41
|
+
@logger.error(e)
|
42
|
+
raise e
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class APIException < StandardError
|
5
|
+
attr_reader :context, :response_code
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [String] The reason for raising an exception
|
9
|
+
# @param [HttpContext] The HttpContext of the API call.
|
10
|
+
def initialize(reason, context)
|
11
|
+
super(reason)
|
12
|
+
@context = context
|
13
|
+
@response_code = context.response.status_code
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
module Raas
|
5
|
+
class RaasClientException < APIException
|
6
|
+
# Request timestamp
|
7
|
+
# @return [DateTime]
|
8
|
+
attr_accessor :timestamp
|
9
|
+
|
10
|
+
# Request ID
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :request_id
|
13
|
+
|
14
|
+
# Request Path
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :path
|
17
|
+
|
18
|
+
# HTTP Code
|
19
|
+
# @return [Integer]
|
20
|
+
attr_accessor :http_code
|
21
|
+
|
22
|
+
# HTTP Phrase
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :http_phrase
|
25
|
+
|
26
|
+
# An array of errors
|
27
|
+
# @return [List of RaasClientErrorModel]
|
28
|
+
attr_accessor :errors
|
29
|
+
|
30
|
+
# The constructor.
|
31
|
+
# @param [String] The reason for raising an exception
|
32
|
+
# @param [HttpContext] The HttpContext of the API call.
|
33
|
+
def initialize(reason, context)
|
34
|
+
super(reason, context)
|
35
|
+
begin
|
36
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
37
|
+
unbox(hash)
|
38
|
+
rescue TypeError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Populates this object by extracting properties from a hash.
|
43
|
+
# @param [Hash] The deserialized response sent by the server in the response body.
|
44
|
+
def unbox(hash)
|
45
|
+
@timestamp = DateTime.rfc3339(hash['timestamp']) if hash['timestamp']
|
46
|
+
@request_id = hash['requestId']
|
47
|
+
@path = hash['path']
|
48
|
+
@http_code = hash['httpCode']
|
49
|
+
@http_phrase = hash['httpPhrase']
|
50
|
+
# Parameter is an array, so we need to iterate through it
|
51
|
+
@errors = nil
|
52
|
+
if hash['errors'] != nil
|
53
|
+
@errors = Array.new
|
54
|
+
hash['errors'].each{|structure| @errors << (RaasClientErrorModel.from_hash(structure) if structure)}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
module Raas
|
5
|
+
class RaasGenericException < APIException
|
6
|
+
# Request timestamp
|
7
|
+
# @return [DateTime]
|
8
|
+
attr_accessor :timestamp
|
9
|
+
|
10
|
+
# Request ID
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :request_id
|
13
|
+
|
14
|
+
# Request Path
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :path
|
17
|
+
|
18
|
+
# HTTP Code
|
19
|
+
# @return [Integer]
|
20
|
+
attr_accessor :http_code
|
21
|
+
|
22
|
+
# HTTP Phrase
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :http_phrase
|
25
|
+
|
26
|
+
# Error Message
|
27
|
+
# @return [String]
|
28
|
+
attr_accessor :message
|
29
|
+
|
30
|
+
# The constructor.
|
31
|
+
# @param [String] The reason for raising an exception
|
32
|
+
# @param [HttpContext] The HttpContext of the API call.
|
33
|
+
def initialize(reason, context)
|
34
|
+
super(reason, context)
|
35
|
+
begin
|
36
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
37
|
+
unbox(hash)
|
38
|
+
rescue TypeError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Populates this object by extracting properties from a hash.
|
43
|
+
# @param [Hash] The deserialized response sent by the server in the response body.
|
44
|
+
def unbox(hash)
|
45
|
+
@timestamp = DateTime.rfc3339(hash['timestamp']) if hash['timestamp']
|
46
|
+
@request_id = hash['requestId']
|
47
|
+
@path = hash['path']
|
48
|
+
@http_code = hash['httpCode']
|
49
|
+
@http_phrase = hash['httpPhrase']
|
50
|
+
@message = hash['message']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
module Raas
|
5
|
+
class RaasServerException < APIException
|
6
|
+
# Request timestamp
|
7
|
+
# @return [DateTime]
|
8
|
+
attr_accessor :timestamp
|
9
|
+
|
10
|
+
# Request ID
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :request_id
|
13
|
+
|
14
|
+
# Request Path
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :path
|
17
|
+
|
18
|
+
# HTTP Code
|
19
|
+
# @return [Integer]
|
20
|
+
attr_accessor :http_code
|
21
|
+
|
22
|
+
# HTTP Phrase
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :http_phrase
|
25
|
+
|
26
|
+
# An array of errors
|
27
|
+
# @return [List of RaasServerErrorModel]
|
28
|
+
attr_accessor :errors
|
29
|
+
|
30
|
+
# The constructor.
|
31
|
+
# @param [String] The reason for raising an exception
|
32
|
+
# @param [HttpContext] The HttpContext of the API call.
|
33
|
+
def initialize(reason, context)
|
34
|
+
super(reason, context)
|
35
|
+
begin
|
36
|
+
hash = APIHelper.json_deserialize(@context.response.raw_body)
|
37
|
+
unbox(hash)
|
38
|
+
rescue TypeError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Populates this object by extracting properties from a hash.
|
43
|
+
# @param [Hash] The deserialized response sent by the server in the response body.
|
44
|
+
def unbox(hash)
|
45
|
+
@timestamp = DateTime.rfc3339(hash['timestamp']) if hash['timestamp']
|
46
|
+
@request_id = hash['requestId']
|
47
|
+
@path = hash['path']
|
48
|
+
@http_code = hash['httpCode']
|
49
|
+
@http_phrase = hash['httpPhrase']
|
50
|
+
# Parameter is an array, so we need to iterate through it
|
51
|
+
@errors = nil
|
52
|
+
if hash['errors'] != nil
|
53
|
+
@errors = Array.new
|
54
|
+
hash['errors'].each{|structure| @errors << (RaasServerErrorModel.from_hash(structure) if structure)}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
|
5
|
+
module Raas
|
6
|
+
class BasicAuth
|
7
|
+
# Add basic authentication to the request.
|
8
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will be added.
|
9
|
+
def self.apply(http_request)
|
10
|
+
username = Configuration.platform_name
|
11
|
+
password = Configuration.platform_key
|
12
|
+
value = Base64.strict_encode64("#{username}:#{password}")
|
13
|
+
header_value = "Basic #{value}"
|
14
|
+
http_request.headers["Authorization"] = header_value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
require 'faraday/http_cache'
|
3
|
+
|
4
|
+
module Raas
|
5
|
+
class FaradayClient < HttpClient
|
6
|
+
# The constructor.
|
7
|
+
def initialize(timeout: nil, cache: false, max_retries: nil, retry_interval: nil)
|
8
|
+
@connection = Faraday.new do |faraday|
|
9
|
+
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
10
|
+
faraday.request :multipart
|
11
|
+
faraday.request :url_encoded
|
12
|
+
faraday.ssl[:ca_file] = Certifi.where
|
13
|
+
faraday.adapter Faraday.default_adapter
|
14
|
+
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
15
|
+
faraday.options[:open_timeout] = timeout if timeout
|
16
|
+
faraday.request :retry, max: max_retries, interval: retry_interval if (max_retries && retry_interval)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Method overridden from HttpClient.
|
21
|
+
def execute_as_string(http_request)
|
22
|
+
response = @connection.send(http_request.http_method.downcase, http_request.query_url) do |request|
|
23
|
+
request.headers = http_request.headers
|
24
|
+
request.body = http_request.parameters
|
25
|
+
end
|
26
|
+
return convert_response(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Method overridden from HttpClient.
|
30
|
+
def execute_as_binary(http_request)
|
31
|
+
response = @connection.send(http_request.http_method.downcase, http_request.query_url) do |request|
|
32
|
+
request.headers = http_request.headers
|
33
|
+
request.body = http_request.parameters
|
34
|
+
end
|
35
|
+
return convert_response(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Method overridden from HttpClient.
|
39
|
+
def convert_response(response)
|
40
|
+
HttpResponse.new(response.status, response.headers, response.body)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class HttpCallBack
|
5
|
+
# A controller will call this method before making an HTTP Request.
|
6
|
+
# @param [HttpRequest] The HttpRequest object which the HttpClient will execute.
|
7
|
+
def on_before_request(http_request)
|
8
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
9
|
+
end
|
10
|
+
|
11
|
+
# A controller will call this method after making an HTTP Request.
|
12
|
+
# @param [HttpContext] The HttpContext of the API call.
|
13
|
+
def on_after_response(http_context)
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class HttpClient
|
5
|
+
# Execute an HttpRequest when the response is expected to be a string.
|
6
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
7
|
+
def execute_as_string(http_request)
|
8
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Execute an HttpRequest when the response is expected to be binary.
|
12
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
13
|
+
def execute_as_binary(http_request)
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
15
|
+
end
|
16
|
+
|
17
|
+
# Converts the HTTP Response from the client to an HttpResponse object.
|
18
|
+
# @param [Dynamic] The response object received from the client.
|
19
|
+
def convert_response(response)
|
20
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a GET HttpRequest object.
|
24
|
+
# @param [String] The URL to send the request to.
|
25
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
26
|
+
def get(query_url,
|
27
|
+
headers: {})
|
28
|
+
return HttpRequest.new(HttpMethodEnum::GET,
|
29
|
+
query_url,
|
30
|
+
headers: headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get a POST HttpRequest object.
|
34
|
+
# @param [String] The URL to send the request to.
|
35
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
36
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
37
|
+
def post(query_url,
|
38
|
+
headers: {},
|
39
|
+
parameters: {})
|
40
|
+
return HttpRequest.new(HttpMethodEnum::POST,
|
41
|
+
query_url,
|
42
|
+
headers: headers,
|
43
|
+
parameters: parameters)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get a PUT HttpRequest object.
|
47
|
+
# @param [String] The URL to send the request to.
|
48
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
49
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
50
|
+
def put(query_url,
|
51
|
+
headers: {},
|
52
|
+
parameters: {})
|
53
|
+
return HttpRequest.new(HttpMethodEnum::PUT,
|
54
|
+
query_url,
|
55
|
+
headers: headers,
|
56
|
+
parameters: parameters)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get a PATCH HttpRequest object.
|
60
|
+
# @param [String] The URL to send the request to.
|
61
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
62
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
63
|
+
def patch(query_url,
|
64
|
+
headers: {},
|
65
|
+
parameters: {})
|
66
|
+
return HttpRequest.new(HttpMethodEnum::PATCH,
|
67
|
+
query_url,
|
68
|
+
headers: headers,
|
69
|
+
parameters: parameters)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get a DELETE HttpRequest object.
|
73
|
+
# @param [String] The URL to send the request to.
|
74
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
75
|
+
def delete(query_url,
|
76
|
+
headers: {},
|
77
|
+
parameters: {})
|
78
|
+
return HttpRequest.new(HttpMethodEnum::DELETE,
|
79
|
+
query_url,
|
80
|
+
headers: headers,
|
81
|
+
parameters: parameters)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class HttpContext
|
5
|
+
attr_accessor :request, :response
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [HttpRequest] An HttpRequest object representing the HTTP request.
|
9
|
+
# @param [HttpResponse] An HttpResponse object representing the HTTP response.
|
10
|
+
def initialize(request, response)
|
11
|
+
@request = request
|
12
|
+
@response = response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# This file was automatically generated for Tango Card, Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Raas
|
4
|
+
class HttpRequest
|
5
|
+
attr_accessor :http_method, :query_url, :headers, :parameters, :username, :password
|
6
|
+
|
7
|
+
# The constructor.
|
8
|
+
# @param [HttpMethodEnum] The HTTP method.
|
9
|
+
# @param [String] The URL to send the request to.
|
10
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
11
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
12
|
+
def initialize(http_method,
|
13
|
+
query_url,
|
14
|
+
headers: {},
|
15
|
+
parameters: {})
|
16
|
+
@http_method = http_method
|
17
|
+
@query_url = query_url
|
18
|
+
@headers = headers
|
19
|
+
@parameters = parameters
|
20
|
+
end
|
21
|
+
|
22
|
+
# Add a header to the HttpRequest.
|
23
|
+
# @param [String] The name of the header.
|
24
|
+
# @param [String] The value of the header.
|
25
|
+
def add_header(name, value)
|
26
|
+
@headers[name] = value
|
27
|
+
end
|
28
|
+
|
29
|
+
# Add a parameter to the HttpRequest.
|
30
|
+
# @param [String] The name of the parameter.
|
31
|
+
# @param [String] The value of the parameter.
|
32
|
+
def add_parameter(name, value)
|
33
|
+
@parameters[name] = value
|
34
|
+
end
|
35
|
+
|
36
|
+
# Add a query parameter to the HttpRequest.
|
37
|
+
# @param [String] The name of the query parameter.
|
38
|
+
# @param [String] The value of the query parameter.
|
39
|
+
def add_query_parameter(name, value)
|
40
|
+
@query_url = APIHelper.append_url_with_query_parameters(@query_url, name => value)
|
41
|
+
@query_url = APIHelper.clean_url(@query_url)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|