feratel-check-api-client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +159 -0
- data/Rakefile +10 -0
- data/docs/AgeGroup.md +22 -0
- data/docs/AgeGroupTranslation.md +20 -0
- data/docs/CheckPoint.md +38 -0
- data/docs/CheckPointGroup.md +20 -0
- data/docs/CheckPointItem.md +26 -0
- data/docs/CheckResourcesApi.md +545 -0
- data/docs/CheckResult.md +26 -0
- data/docs/CheckState.md +20 -0
- data/docs/CheckStateEnum.md +15 -0
- data/docs/CheckStateTranslation.md +20 -0
- data/docs/CheckpointError.md +22 -0
- data/docs/Customer.md +24 -0
- data/docs/History.md +18 -0
- data/docs/HistoryItem.md +24 -0
- data/docs/HistoryItemState.md +26 -0
- data/docs/Identification.md +36 -0
- data/docs/IdentificationStatus.md +15 -0
- data/docs/IdentificationType.md +26 -0
- data/docs/IdentificationUsage.md +26 -0
- data/docs/IdentificationUsageType.md +15 -0
- data/docs/Identifier.md +20 -0
- data/docs/IdentifierType.md +15 -0
- data/docs/ServiceProvider.md +24 -0
- data/docs/ServiceType.md +28 -0
- data/docs/ServiceTypeAssignment.md +22 -0
- data/docs/ServiceTypeTranslation.md +20 -0
- data/docs/ServiceUsage.md +36 -0
- data/docs/ServiceUsageType.md +15 -0
- data/docs/SystemResourcesApi.md +147 -0
- data/docs/TransactError.md +22 -0
- data/docs/TransactResult.md +34 -0
- data/docs/TransactState.md +20 -0
- data/docs/TransactStateEnum.md +15 -0
- data/docs/TransactStateTranslation.md +20 -0
- data/docs/ValidTransactionInfo.md +20 -0
- data/docs/Week.md +30 -0
- data/feratel-check-api-client.gemspec +39 -0
- data/git_push.sh +57 -0
- data/lib/feratel-check-api-client/api/check_resources_api.rb +586 -0
- data/lib/feratel-check-api-client/api/system_resources_api.rb +148 -0
- data/lib/feratel-check-api-client/api_client.rb +394 -0
- data/lib/feratel-check-api-client/api_error.rb +58 -0
- data/lib/feratel-check-api-client/configuration.rb +308 -0
- data/lib/feratel-check-api-client/models/age_group.rb +255 -0
- data/lib/feratel-check-api-client/models/age_group_translation.rb +223 -0
- data/lib/feratel-check-api-client/models/check_point.rb +327 -0
- data/lib/feratel-check-api-client/models/check_point_group.rb +244 -0
- data/lib/feratel-check-api-client/models/check_point_item.rb +271 -0
- data/lib/feratel-check-api-client/models/check_result.rb +250 -0
- data/lib/feratel-check-api-client/models/check_state.rb +247 -0
- data/lib/feratel-check-api-client/models/check_state_enum.rb +82 -0
- data/lib/feratel-check-api-client/models/check_state_translation.rb +223 -0
- data/lib/feratel-check-api-client/models/checkpoint_error.rb +256 -0
- data/lib/feratel-check-api-client/models/customer.rb +262 -0
- data/lib/feratel-check-api-client/models/history.rb +216 -0
- data/lib/feratel-check-api-client/models/history_item.rb +262 -0
- data/lib/feratel-check-api-client/models/history_item_state.rb +250 -0
- data/lib/feratel-check-api-client/models/identification.rb +338 -0
- data/lib/feratel-check-api-client/models/identification_status.rb +43 -0
- data/lib/feratel-check-api-client/models/identification_type.rb +271 -0
- data/lib/feratel-check-api-client/models/identification_usage.rb +314 -0
- data/lib/feratel-check-api-client/models/identification_usage_type.rb +42 -0
- data/lib/feratel-check-api-client/models/identifier.rb +245 -0
- data/lib/feratel-check-api-client/models/identifier_type.rb +44 -0
- data/lib/feratel-check-api-client/models/service_provider.rb +262 -0
- data/lib/feratel-check-api-client/models/service_type.rb +282 -0
- data/lib/feratel-check-api-client/models/service_type_assignment.rb +253 -0
- data/lib/feratel-check-api-client/models/service_type_translation.rb +223 -0
- data/lib/feratel-check-api-client/models/service_usage.rb +380 -0
- data/lib/feratel-check-api-client/models/service_usage_type.rb +50 -0
- data/lib/feratel-check-api-client/models/transact_error.rb +256 -0
- data/lib/feratel-check-api-client/models/transact_result.rb +349 -0
- data/lib/feratel-check-api-client/models/transact_state.rb +247 -0
- data/lib/feratel-check-api-client/models/transact_state_enum.rb +54 -0
- data/lib/feratel-check-api-client/models/transact_state_translation.rb +223 -0
- data/lib/feratel-check-api-client/models/valid_transaction_info.rb +223 -0
- data/lib/feratel-check-api-client/models/week.rb +268 -0
- data/lib/feratel-check-api-client/version.rb +15 -0
- data/lib/feratel-check-api-client.rb +75 -0
- data/spec/api/check_resources_api_spec.rb +137 -0
- data/spec/api/system_resources_api_spec.rb +59 -0
- data/spec/models/age_group_spec.rb +48 -0
- data/spec/models/age_group_translation_spec.rb +42 -0
- data/spec/models/check_point_group_spec.rb +42 -0
- data/spec/models/check_point_item_spec.rb +60 -0
- data/spec/models/check_point_spec.rb +96 -0
- data/spec/models/check_result_spec.rb +60 -0
- data/spec/models/check_state_enum_spec.rb +30 -0
- data/spec/models/check_state_spec.rb +42 -0
- data/spec/models/check_state_translation_spec.rb +42 -0
- data/spec/models/checkpoint_error_spec.rb +48 -0
- data/spec/models/customer_spec.rb +54 -0
- data/spec/models/history_item_spec.rb +54 -0
- data/spec/models/history_item_state_spec.rb +60 -0
- data/spec/models/history_spec.rb +36 -0
- data/spec/models/identification_spec.rb +90 -0
- data/spec/models/identification_status_spec.rb +30 -0
- data/spec/models/identification_type_spec.rb +60 -0
- data/spec/models/identification_usage_spec.rb +60 -0
- data/spec/models/identification_usage_type_spec.rb +30 -0
- data/spec/models/identifier_spec.rb +42 -0
- data/spec/models/identifier_type_spec.rb +30 -0
- data/spec/models/service_provider_spec.rb +54 -0
- data/spec/models/service_type_assignment_spec.rb +48 -0
- data/spec/models/service_type_spec.rb +66 -0
- data/spec/models/service_type_translation_spec.rb +42 -0
- data/spec/models/service_usage_spec.rb +90 -0
- data/spec/models/service_usage_type_spec.rb +30 -0
- data/spec/models/transact_error_spec.rb +48 -0
- data/spec/models/transact_result_spec.rb +84 -0
- data/spec/models/transact_state_enum_spec.rb +30 -0
- data/spec/models/transact_state_spec.rb +42 -0
- data/spec/models/transact_state_translation_spec.rb +42 -0
- data/spec/models/valid_transaction_info_spec.rb +42 -0
- data/spec/models/week_spec.rb +72 -0
- data/spec/spec_helper.rb +111 -0
- metadata +255 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
=begin
|
2
|
+
#CheckAPI Standard
|
3
|
+
|
4
|
+
#This documentation describes your available CheckAPI REST services: Get your checkpoints and their details, check the permission of a customer's ID, take a look at your checkpoint's history - everything a checkpoint needs can be found here in one place. Please look at the descriptions in each service below. <div id=\"authorize-information-wrap\"><h1>Authorize</h1><p>You can use this automated authentication to try out your activated methods - just click „Authorize“, enter CardAPI credentials and have a try! You received the CardAPI username and password via e-mail – credentials are different from your developer-portal credentials. Authentication is based on OAUTH2 (implicit grant flow) and needs to be implemented and called prior to using any API method. <b>CLIENT_ID</b><br>The client ID is pre-filled automatically according to the chosen application. You can find your available client IDs in the \"Applications\" - Area. <b>GRANT_TYPE</b><br>With grant_type=password you get an access-token and a refresh-token for your request. The received access token can be used for 10 minutes, there are two ways to renew it. Either you can send the same request again or you can use the grant_type=refresh_token. The refresh token needs to be used every 30 minutes and can provide new access tokens for 10 hours without using your credentials.</p></div>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.17.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module FeratelCheckApiClient
|
16
|
+
class SystemResourcesApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# provides all errors related to the CheckAPI
|
23
|
+
# Get all possible checkErrors.(checkstate,valid or not and all translations).
|
24
|
+
# @param tenant_id [String]
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @return [Array<CheckpointError>]
|
27
|
+
def v1_tenant_id_secure_system_checkpoint_errors_get(tenant_id, opts = {})
|
28
|
+
data, _status_code, _headers = v1_tenant_id_secure_system_checkpoint_errors_get_with_http_info(tenant_id, opts)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
# provides all errors related to the CheckAPI
|
33
|
+
# Get all possible checkErrors.(checkstate,valid or not and all translations).
|
34
|
+
# @param tenant_id [String]
|
35
|
+
# @param [Hash] opts the optional parameters
|
36
|
+
# @return [Array<(Array<CheckpointError>, Integer, Hash)>] Array<CheckpointError> data, response status code and response headers
|
37
|
+
def v1_tenant_id_secure_system_checkpoint_errors_get_with_http_info(tenant_id, opts = {})
|
38
|
+
if @api_client.config.debugging
|
39
|
+
@api_client.config.logger.debug 'Calling API: SystemResourcesApi.v1_tenant_id_secure_system_checkpoint_errors_get ...'
|
40
|
+
end
|
41
|
+
# verify the required parameter 'tenant_id' is set
|
42
|
+
if @api_client.config.client_side_validation && tenant_id.nil?
|
43
|
+
fail ArgumentError, "Missing the required parameter 'tenant_id' when calling SystemResourcesApi.v1_tenant_id_secure_system_checkpoint_errors_get"
|
44
|
+
end
|
45
|
+
# resource path
|
46
|
+
local_var_path = '/v1/{tenantId}/secure/system/checkpointErrors'.sub('{' + 'tenantId' + '}', CGI.escape(tenant_id.to_s))
|
47
|
+
|
48
|
+
# query parameters
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
|
51
|
+
# header parameters
|
52
|
+
header_params = opts[:header_params] || {}
|
53
|
+
# HTTP header 'Accept' (if needed)
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
55
|
+
|
56
|
+
# form parameters
|
57
|
+
form_params = opts[:form_params] || {}
|
58
|
+
|
59
|
+
# http body (model)
|
60
|
+
post_body = opts[:debug_body]
|
61
|
+
|
62
|
+
# return_type
|
63
|
+
return_type = opts[:debug_return_type] || 'Array<CheckpointError>'
|
64
|
+
|
65
|
+
# auth_names
|
66
|
+
auth_names = opts[:debug_auth_names] || ['oauth']
|
67
|
+
|
68
|
+
new_options = opts.merge(
|
69
|
+
:operation => :"SystemResourcesApi.v1_tenant_id_secure_system_checkpoint_errors_get",
|
70
|
+
:header_params => header_params,
|
71
|
+
:query_params => query_params,
|
72
|
+
:form_params => form_params,
|
73
|
+
:body => post_body,
|
74
|
+
:auth_names => auth_names,
|
75
|
+
:return_type => return_type
|
76
|
+
)
|
77
|
+
|
78
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
79
|
+
if @api_client.config.debugging
|
80
|
+
@api_client.config.logger.debug "API called: SystemResourcesApi#v1_tenant_id_secure_system_checkpoint_errors_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
81
|
+
end
|
82
|
+
return data, status_code, headers
|
83
|
+
end
|
84
|
+
|
85
|
+
# provides all transactErrors related to the CheckAPI
|
86
|
+
# Get all possible transactErrors.(transactState,translations and valid).
|
87
|
+
# @param tenant_id [String]
|
88
|
+
# @param [Hash] opts the optional parameters
|
89
|
+
# @return [Array<TransactError>]
|
90
|
+
def v1_tenant_id_secure_system_transact_errors_get(tenant_id, opts = {})
|
91
|
+
data, _status_code, _headers = v1_tenant_id_secure_system_transact_errors_get_with_http_info(tenant_id, opts)
|
92
|
+
data
|
93
|
+
end
|
94
|
+
|
95
|
+
# provides all transactErrors related to the CheckAPI
|
96
|
+
# Get all possible transactErrors.(transactState,translations and valid).
|
97
|
+
# @param tenant_id [String]
|
98
|
+
# @param [Hash] opts the optional parameters
|
99
|
+
# @return [Array<(Array<TransactError>, Integer, Hash)>] Array<TransactError> data, response status code and response headers
|
100
|
+
def v1_tenant_id_secure_system_transact_errors_get_with_http_info(tenant_id, opts = {})
|
101
|
+
if @api_client.config.debugging
|
102
|
+
@api_client.config.logger.debug 'Calling API: SystemResourcesApi.v1_tenant_id_secure_system_transact_errors_get ...'
|
103
|
+
end
|
104
|
+
# verify the required parameter 'tenant_id' is set
|
105
|
+
if @api_client.config.client_side_validation && tenant_id.nil?
|
106
|
+
fail ArgumentError, "Missing the required parameter 'tenant_id' when calling SystemResourcesApi.v1_tenant_id_secure_system_transact_errors_get"
|
107
|
+
end
|
108
|
+
# resource path
|
109
|
+
local_var_path = '/v1/{tenantId}/secure/system/transactErrors'.sub('{' + 'tenantId' + '}', CGI.escape(tenant_id.to_s))
|
110
|
+
|
111
|
+
# query parameters
|
112
|
+
query_params = opts[:query_params] || {}
|
113
|
+
|
114
|
+
# header parameters
|
115
|
+
header_params = opts[:header_params] || {}
|
116
|
+
# HTTP header 'Accept' (if needed)
|
117
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
118
|
+
|
119
|
+
# form parameters
|
120
|
+
form_params = opts[:form_params] || {}
|
121
|
+
|
122
|
+
# http body (model)
|
123
|
+
post_body = opts[:debug_body]
|
124
|
+
|
125
|
+
# return_type
|
126
|
+
return_type = opts[:debug_return_type] || 'Array<TransactError>'
|
127
|
+
|
128
|
+
# auth_names
|
129
|
+
auth_names = opts[:debug_auth_names] || ['oauth']
|
130
|
+
|
131
|
+
new_options = opts.merge(
|
132
|
+
:operation => :"SystemResourcesApi.v1_tenant_id_secure_system_transact_errors_get",
|
133
|
+
:header_params => header_params,
|
134
|
+
:query_params => query_params,
|
135
|
+
:form_params => form_params,
|
136
|
+
:body => post_body,
|
137
|
+
:auth_names => auth_names,
|
138
|
+
:return_type => return_type
|
139
|
+
)
|
140
|
+
|
141
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
142
|
+
if @api_client.config.debugging
|
143
|
+
@api_client.config.logger.debug "API called: SystemResourcesApi#v1_tenant_id_secure_system_transact_errors_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
144
|
+
end
|
145
|
+
return data, status_code, headers
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,394 @@
|
|
1
|
+
=begin
|
2
|
+
#CheckAPI Standard
|
3
|
+
|
4
|
+
#This documentation describes your available CheckAPI REST services: Get your checkpoints and their details, check the permission of a customer's ID, take a look at your checkpoint's history - everything a checkpoint needs can be found here in one place. Please look at the descriptions in each service below. <div id=\"authorize-information-wrap\"><h1>Authorize</h1><p>You can use this automated authentication to try out your activated methods - just click „Authorize“, enter CardAPI credentials and have a try! You received the CardAPI username and password via e-mail – credentials are different from your developer-portal credentials. Authentication is based on OAUTH2 (implicit grant flow) and needs to be implemented and called prior to using any API method. <b>CLIENT_ID</b><br>The client ID is pre-filled automatically according to the chosen application. You can find your available client IDs in the \"Applications\" - Area. <b>GRANT_TYPE</b><br>With grant_type=password you get an access-token and a refresh-token for your request. The received access token can be used for 10 minutes, there are two ways to renew it. Either you can send the same request again or you can use the grant_type=refresh_token. The refresh token needs to be used every 30 minutes and can provide new access tokens for 10 hours without using your credentials.</p></div>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.17.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'json'
|
15
|
+
require 'logger'
|
16
|
+
require 'tempfile'
|
17
|
+
require 'time'
|
18
|
+
require 'typhoeus'
|
19
|
+
|
20
|
+
|
21
|
+
module FeratelCheckApiClient
|
22
|
+
class ApiClient
|
23
|
+
# The Configuration object holding settings to be used in the API client.
|
24
|
+
attr_accessor :config
|
25
|
+
|
26
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
27
|
+
#
|
28
|
+
# @return [Hash]
|
29
|
+
attr_accessor :default_headers
|
30
|
+
|
31
|
+
# Initializes the ApiClient
|
32
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
33
|
+
def initialize(config = Configuration.default)
|
34
|
+
@config = config
|
35
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
36
|
+
@default_headers = {
|
37
|
+
'Content-Type' => 'application/json',
|
38
|
+
'User-Agent' => @user_agent
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.default
|
43
|
+
@@default ||= ApiClient.new
|
44
|
+
end
|
45
|
+
|
46
|
+
# Call an API with given options.
|
47
|
+
#
|
48
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
49
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
50
|
+
def call_api(http_method, path, opts = {})
|
51
|
+
request = build_request(http_method, path, opts)
|
52
|
+
tempfile = download_file(request) if opts[:return_type] == 'File'
|
53
|
+
response = request.run
|
54
|
+
|
55
|
+
if @config.debugging
|
56
|
+
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
unless response.success?
|
60
|
+
if response.timed_out?
|
61
|
+
fail ApiError.new('Connection timed out')
|
62
|
+
elsif response.code == 0
|
63
|
+
# Errors from libcurl will be made visible here
|
64
|
+
fail ApiError.new(:code => 0,
|
65
|
+
:message => response.return_message)
|
66
|
+
else
|
67
|
+
fail ApiError.new(:code => response.code,
|
68
|
+
:response_headers => response.headers,
|
69
|
+
:response_body => response.body),
|
70
|
+
response.status_message
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if opts[:return_type] == 'File'
|
75
|
+
data = tempfile
|
76
|
+
elsif opts[:return_type]
|
77
|
+
data = deserialize(response, opts[:return_type])
|
78
|
+
else
|
79
|
+
data = nil
|
80
|
+
end
|
81
|
+
return data, response.code, response.headers
|
82
|
+
end
|
83
|
+
|
84
|
+
# Builds the HTTP request
|
85
|
+
#
|
86
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
87
|
+
# @param [String] path URL path (e.g. /account/new)
|
88
|
+
# @option opts [Hash] :header_params Header parameters
|
89
|
+
# @option opts [Hash] :query_params Query parameters
|
90
|
+
# @option opts [Hash] :form_params Query parameters
|
91
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
92
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
93
|
+
def build_request(http_method, path, opts = {})
|
94
|
+
url = build_request_url(path, opts)
|
95
|
+
http_method = http_method.to_sym.downcase
|
96
|
+
|
97
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
98
|
+
query_params = opts[:query_params] || {}
|
99
|
+
form_params = opts[:form_params] || {}
|
100
|
+
follow_location = opts[:follow_location] || true
|
101
|
+
|
102
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
103
|
+
|
104
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
105
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
106
|
+
|
107
|
+
req_opts = {
|
108
|
+
:method => http_method,
|
109
|
+
:headers => header_params,
|
110
|
+
:params => query_params,
|
111
|
+
:params_encoding => @config.params_encoding,
|
112
|
+
:timeout => @config.timeout,
|
113
|
+
:ssl_verifypeer => @config.verify_ssl,
|
114
|
+
:ssl_verifyhost => _verify_ssl_host,
|
115
|
+
:sslcert => @config.cert_file,
|
116
|
+
:sslkey => @config.key_file,
|
117
|
+
:verbose => @config.debugging,
|
118
|
+
:followlocation => follow_location
|
119
|
+
}
|
120
|
+
|
121
|
+
# set custom cert, if provided
|
122
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
123
|
+
|
124
|
+
if [:post, :patch, :put, :delete].include?(http_method)
|
125
|
+
req_body = build_request_body(header_params, form_params, opts[:body])
|
126
|
+
req_opts.update :body => req_body
|
127
|
+
if @config.debugging
|
128
|
+
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
Typhoeus::Request.new(url, req_opts)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Builds the HTTP request body
|
136
|
+
#
|
137
|
+
# @param [Hash] header_params Header parameters
|
138
|
+
# @param [Hash] form_params Query parameters
|
139
|
+
# @param [Object] body HTTP body (JSON/XML)
|
140
|
+
# @return [String] HTTP body data in the form of string
|
141
|
+
def build_request_body(header_params, form_params, body)
|
142
|
+
# http form
|
143
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
144
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
145
|
+
data = {}
|
146
|
+
form_params.each do |key, value|
|
147
|
+
case value
|
148
|
+
when ::File, ::Array, nil
|
149
|
+
# let typhoeus handle File, Array and nil parameters
|
150
|
+
data[key] = value
|
151
|
+
else
|
152
|
+
data[key] = value.to_s
|
153
|
+
end
|
154
|
+
end
|
155
|
+
elsif body
|
156
|
+
data = body.is_a?(String) ? body : body.to_json
|
157
|
+
else
|
158
|
+
data = nil
|
159
|
+
end
|
160
|
+
data
|
161
|
+
end
|
162
|
+
|
163
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
164
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
165
|
+
# The response body is written to the file in chunks in order to handle files which
|
166
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
167
|
+
# process can use.
|
168
|
+
#
|
169
|
+
# @see Configuration#temp_folder_path
|
170
|
+
#
|
171
|
+
# @return [Tempfile] the tempfile generated
|
172
|
+
def download_file(request)
|
173
|
+
tempfile = nil
|
174
|
+
encoding = nil
|
175
|
+
request.on_headers do |response|
|
176
|
+
content_disposition = response.headers['Content-Disposition']
|
177
|
+
if content_disposition && content_disposition =~ /filename=/i
|
178
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
179
|
+
prefix = sanitize_filename(filename)
|
180
|
+
else
|
181
|
+
prefix = 'download-'
|
182
|
+
end
|
183
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
184
|
+
encoding = response.body.encoding
|
185
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
186
|
+
end
|
187
|
+
request.on_body do |chunk|
|
188
|
+
chunk.force_encoding(encoding)
|
189
|
+
tempfile.write(chunk)
|
190
|
+
end
|
191
|
+
# run the request to ensure the tempfile is created successfully before returning it
|
192
|
+
request.run
|
193
|
+
if tempfile
|
194
|
+
tempfile.close
|
195
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
196
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
197
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
198
|
+
"explicitly with `tempfile.delete`"
|
199
|
+
else
|
200
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
201
|
+
end
|
202
|
+
|
203
|
+
tempfile
|
204
|
+
end
|
205
|
+
|
206
|
+
# Check if the given MIME is a JSON MIME.
|
207
|
+
# JSON MIME examples:
|
208
|
+
# application/json
|
209
|
+
# application/json; charset=UTF8
|
210
|
+
# APPLICATION/JSON
|
211
|
+
# */*
|
212
|
+
# @param [String] mime MIME
|
213
|
+
# @return [Boolean] True if the MIME is application/json
|
214
|
+
def json_mime?(mime)
|
215
|
+
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
|
216
|
+
end
|
217
|
+
|
218
|
+
# Deserialize the response to the given return type.
|
219
|
+
#
|
220
|
+
# @param [Response] response HTTP response
|
221
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
222
|
+
def deserialize(response, return_type)
|
223
|
+
body = response.body
|
224
|
+
return nil if body.nil? || body.empty?
|
225
|
+
|
226
|
+
# return response body directly for String return type
|
227
|
+
return body.to_s if return_type == 'String'
|
228
|
+
|
229
|
+
# ensuring a default content type
|
230
|
+
content_type = response.headers['Content-Type'] || 'application/json'
|
231
|
+
|
232
|
+
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
233
|
+
|
234
|
+
begin
|
235
|
+
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
236
|
+
rescue JSON::ParserError => e
|
237
|
+
if %w(String Date Time).include?(return_type)
|
238
|
+
data = body
|
239
|
+
else
|
240
|
+
raise e
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
convert_to_type data, return_type
|
245
|
+
end
|
246
|
+
|
247
|
+
# Convert data to the given return type.
|
248
|
+
# @param [Object] data Data to be converted
|
249
|
+
# @param [String] return_type Return type
|
250
|
+
# @return [Mixed] Data in a particular type
|
251
|
+
def convert_to_type(data, return_type)
|
252
|
+
return nil if data.nil?
|
253
|
+
case return_type
|
254
|
+
when 'String'
|
255
|
+
data.to_s
|
256
|
+
when 'Integer'
|
257
|
+
data.to_i
|
258
|
+
when 'Float'
|
259
|
+
data.to_f
|
260
|
+
when 'Boolean'
|
261
|
+
data == true
|
262
|
+
when 'Time'
|
263
|
+
# parse date time (expecting ISO 8601 format)
|
264
|
+
Time.parse data
|
265
|
+
when 'Date'
|
266
|
+
# parse date time (expecting ISO 8601 format)
|
267
|
+
Date.parse data
|
268
|
+
when 'Object'
|
269
|
+
# generic object (usually a Hash), return directly
|
270
|
+
data
|
271
|
+
when /\AArray<(.+)>\z/
|
272
|
+
# e.g. Array<Pet>
|
273
|
+
sub_type = $1
|
274
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
275
|
+
when /\AHash\<String, (.+)\>\z/
|
276
|
+
# e.g. Hash<String, Integer>
|
277
|
+
sub_type = $1
|
278
|
+
{}.tap do |hash|
|
279
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
280
|
+
end
|
281
|
+
else
|
282
|
+
# models (e.g. Pet) or oneOf
|
283
|
+
klass = FeratelCheckApiClient.const_get(return_type)
|
284
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
# Sanitize filename by removing path.
|
289
|
+
# e.g. ../../sun.gif becomes sun.gif
|
290
|
+
#
|
291
|
+
# @param [String] filename the filename to be sanitized
|
292
|
+
# @return [String] the sanitized filename
|
293
|
+
def sanitize_filename(filename)
|
294
|
+
filename.split(/[\/\\]/).last
|
295
|
+
end
|
296
|
+
|
297
|
+
def build_request_url(path, opts = {})
|
298
|
+
# Add leading and trailing slashes to path
|
299
|
+
path = "/#{path}".gsub(/\/+/, '/')
|
300
|
+
@config.base_url(opts[:operation]) + path
|
301
|
+
end
|
302
|
+
|
303
|
+
# Update header and query params based on authentication settings.
|
304
|
+
#
|
305
|
+
# @param [Hash] header_params Header parameters
|
306
|
+
# @param [Hash] query_params Query parameters
|
307
|
+
# @param [String] auth_names Authentication scheme name
|
308
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
309
|
+
Array(auth_names).each do |auth_name|
|
310
|
+
auth_setting = @config.auth_settings[auth_name]
|
311
|
+
next unless auth_setting
|
312
|
+
case auth_setting[:in]
|
313
|
+
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
314
|
+
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
315
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
# Sets user agent in HTTP header
|
321
|
+
#
|
322
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
323
|
+
def user_agent=(user_agent)
|
324
|
+
@user_agent = user_agent
|
325
|
+
@default_headers['User-Agent'] = @user_agent
|
326
|
+
end
|
327
|
+
|
328
|
+
# Return Accept header based on an array of accepts provided.
|
329
|
+
# @param [Array] accepts array for Accept
|
330
|
+
# @return [String] the Accept header (e.g. application/json)
|
331
|
+
def select_header_accept(accepts)
|
332
|
+
return nil if accepts.nil? || accepts.empty?
|
333
|
+
# use JSON when present, otherwise use all of the provided
|
334
|
+
json_accept = accepts.find { |s| json_mime?(s) }
|
335
|
+
json_accept || accepts.join(',')
|
336
|
+
end
|
337
|
+
|
338
|
+
# Return Content-Type header based on an array of content types provided.
|
339
|
+
# @param [Array] content_types array for Content-Type
|
340
|
+
# @return [String] the Content-Type header (e.g. application/json)
|
341
|
+
def select_header_content_type(content_types)
|
342
|
+
# return nil by default
|
343
|
+
return if content_types.nil? || content_types.empty?
|
344
|
+
# use JSON when present, otherwise use the first one
|
345
|
+
json_content_type = content_types.find { |s| json_mime?(s) }
|
346
|
+
json_content_type || content_types.first
|
347
|
+
end
|
348
|
+
|
349
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
350
|
+
# @param [Object] model object to be converted into JSON string
|
351
|
+
# @return [String] JSON string representation of the object
|
352
|
+
def object_to_http_body(model)
|
353
|
+
return model if model.nil? || model.is_a?(String)
|
354
|
+
local_body = nil
|
355
|
+
if model.is_a?(Array)
|
356
|
+
local_body = model.map { |m| object_to_hash(m) }
|
357
|
+
else
|
358
|
+
local_body = object_to_hash(model)
|
359
|
+
end
|
360
|
+
local_body.to_json
|
361
|
+
end
|
362
|
+
|
363
|
+
# Convert object(non-array) to hash.
|
364
|
+
# @param [Object] obj object to be converted into JSON string
|
365
|
+
# @return [String] JSON string representation of the object
|
366
|
+
def object_to_hash(obj)
|
367
|
+
if obj.respond_to?(:to_hash)
|
368
|
+
obj.to_hash
|
369
|
+
else
|
370
|
+
obj
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
# Build parameter value according to the given collection format.
|
375
|
+
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
376
|
+
def build_collection_param(param, collection_format)
|
377
|
+
case collection_format
|
378
|
+
when :csv
|
379
|
+
param.join(',')
|
380
|
+
when :ssv
|
381
|
+
param.join(' ')
|
382
|
+
when :tsv
|
383
|
+
param.join("\t")
|
384
|
+
when :pipes
|
385
|
+
param.join('|')
|
386
|
+
when :multi
|
387
|
+
# return the array directly as typhoeus will handle it as expected
|
388
|
+
param
|
389
|
+
else
|
390
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
=begin
|
2
|
+
#CheckAPI Standard
|
3
|
+
|
4
|
+
#This documentation describes your available CheckAPI REST services: Get your checkpoints and their details, check the permission of a customer's ID, take a look at your checkpoint's history - everything a checkpoint needs can be found here in one place. Please look at the descriptions in each service below. <div id=\"authorize-information-wrap\"><h1>Authorize</h1><p>You can use this automated authentication to try out your activated methods - just click „Authorize“, enter CardAPI credentials and have a try! You received the CardAPI username and password via e-mail – credentials are different from your developer-portal credentials. Authentication is based on OAUTH2 (implicit grant flow) and needs to be implemented and called prior to using any API method. <b>CLIENT_ID</b><br>The client ID is pre-filled automatically according to the chosen application. You can find your available client IDs in the \"Applications\" - Area. <b>GRANT_TYPE</b><br>With grant_type=password you get an access-token and a refresh-token for your request. The received access token can be used for 10 minutes, there are two ways to renew it. Either you can send the same request again or you can use the grant_type=refresh_token. The refresh token needs to be used every 30 minutes and can provide new access tokens for 10 hours without using your credentials.</p></div>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.17.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.8.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module FeratelCheckApiClient
|
14
|
+
class ApiError < StandardError
|
15
|
+
attr_reader :code, :response_headers, :response_body
|
16
|
+
|
17
|
+
# Usage examples:
|
18
|
+
# ApiError.new
|
19
|
+
# ApiError.new("message")
|
20
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
22
|
+
def initialize(arg = nil)
|
23
|
+
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
30
|
+
arg.each do |k, v|
|
31
|
+
instance_variable_set "@#{k}", v
|
32
|
+
end
|
33
|
+
else
|
34
|
+
super arg
|
35
|
+
@message = arg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Override to_s to display a friendly error message
|
40
|
+
def to_s
|
41
|
+
message
|
42
|
+
end
|
43
|
+
|
44
|
+
def message
|
45
|
+
if @message.nil?
|
46
|
+
msg = "Error message: the server returns an error"
|
47
|
+
else
|
48
|
+
msg = @message
|
49
|
+
end
|
50
|
+
|
51
|
+
msg += "\nHTTP status code: #{code}" if code
|
52
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
53
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
54
|
+
|
55
|
+
msg
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|