colorado-booth-sdk 1.0.0

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 (39) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +202 -0
  4. data/bin/console +15 -0
  5. data/lib/multi_auth_sample/api_helper.rb +10 -0
  6. data/lib/multi_auth_sample/client.rb +118 -0
  7. data/lib/multi_auth_sample/configuration.rb +262 -0
  8. data/lib/multi_auth_sample/controllers/authentication_controller.rb +149 -0
  9. data/lib/multi_auth_sample/controllers/base_controller.rb +60 -0
  10. data/lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb +188 -0
  11. data/lib/multi_auth_sample/exceptions/api_exception.rb +21 -0
  12. data/lib/multi_auth_sample/exceptions/o_auth_provider_exception.rb +64 -0
  13. data/lib/multi_auth_sample/http/auth/api_header.rb +59 -0
  14. data/lib/multi_auth_sample/http/auth/api_key.rb +59 -0
  15. data/lib/multi_auth_sample/http/auth/basic_auth.rb +62 -0
  16. data/lib/multi_auth_sample/http/auth/custom_auth.rb +40 -0
  17. data/lib/multi_auth_sample/http/auth/o_auth_acg.rb +163 -0
  18. data/lib/multi_auth_sample/http/auth/o_auth_bearer_token.rb +53 -0
  19. data/lib/multi_auth_sample/http/auth/o_auth_ccg.rb +148 -0
  20. data/lib/multi_auth_sample/http/auth/o_auth_ropcg.rb +139 -0
  21. data/lib/multi_auth_sample/http/http_call_back.rb +10 -0
  22. data/lib/multi_auth_sample/http/http_method_enum.rb +10 -0
  23. data/lib/multi_auth_sample/http/http_request.rb +10 -0
  24. data/lib/multi_auth_sample/http/http_response.rb +10 -0
  25. data/lib/multi_auth_sample/http/proxy_settings.rb +22 -0
  26. data/lib/multi_auth_sample/models/base_model.rb +122 -0
  27. data/lib/multi_auth_sample/models/o_auth_provider_error_enum.rb +62 -0
  28. data/lib/multi_auth_sample/models/o_auth_scope_o_auth_acg_enum.rb +26 -0
  29. data/lib/multi_auth_sample/models/o_auth_token.rb +106 -0
  30. data/lib/multi_auth_sample/models/service_status.rb +140 -0
  31. data/lib/multi_auth_sample/models/suite_code_enum.rb +50 -0
  32. data/lib/multi_auth_sample/models/user.rb +111 -0
  33. data/lib/multi_auth_sample/utilities/date_time_helper.rb +11 -0
  34. data/lib/multi_auth_sample/utilities/file_wrapper.rb +28 -0
  35. data/lib/multi_auth_sample.rb +55 -0
  36. data/test/controllers/controller_test_base.rb +60 -0
  37. data/test/controllers/test_authentication_controller.rb +110 -0
  38. data/test/http_response_catcher.rb +19 -0
  39. metadata +150 -0
@@ -0,0 +1,149 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # AuthenticationController
8
+ class AuthenticationController < BaseController
9
+ # TODO: type endpoint description here
10
+ # @return [String] Response from the API call.
11
+ def custom_authentication
12
+ @api_call
13
+ .request(new_request_builder(HttpMethodEnum::GET,
14
+ '/auth/customAuthentication',
15
+ Server::DEFAULT)
16
+ .auth(Single.new('CustomAuth')))
17
+ .response(new_response_handler
18
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
19
+ .deserialize_into(proc do |response| response&.to_s end)
20
+ .is_primitive_response(true))
21
+ .execute
22
+ end
23
+
24
+ # TODO: type endpoint description here
25
+ # @return [String] Response from the API call.
26
+ def o_auth_bearer_token
27
+ @api_call
28
+ .request(new_request_builder(HttpMethodEnum::GET,
29
+ '/auth/oauth2',
30
+ Server::DEFAULT)
31
+ .auth(Single.new('OAuthBearerToken')))
32
+ .response(new_response_handler
33
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
34
+ .deserialize_into(proc do |response| response&.to_s end)
35
+ .is_primitive_response(true))
36
+ .execute
37
+ end
38
+
39
+ # TODO: type endpoint description here
40
+ # @return [ServiceStatus] Response from the API call.
41
+ def o_auth_client_credentials_grant
42
+ @api_call
43
+ .request(new_request_builder(HttpMethodEnum::GET,
44
+ '/oauth2/non-auth-server/status',
45
+ Server::DEFAULT)
46
+ .header_param(new_parameter('application/json', key: 'accept'))
47
+ .auth(Single.new('OAuthCCG')))
48
+ .response(new_response_handler
49
+ .deserializer(APIHelper.method(:custom_type_deserializer))
50
+ .deserialize_into(ServiceStatus.method(:from_hash)))
51
+ .execute
52
+ end
53
+
54
+ # TODO: type endpoint description here
55
+ # @return [User] Response from the API call.
56
+ def o_auth_authorization_grant
57
+ @api_call
58
+ .request(new_request_builder(HttpMethodEnum::GET,
59
+ '/oauth2/non-auth-server/user',
60
+ Server::DEFAULT)
61
+ .header_param(new_parameter('application/json', key: 'accept'))
62
+ .auth(And.new('OAuthACG', 'OAuthROPCG')))
63
+ .response(new_response_handler
64
+ .deserializer(APIHelper.method(:custom_type_deserializer))
65
+ .deserialize_into(User.method(:from_hash)))
66
+ .execute
67
+ end
68
+
69
+ # TODO: type endpoint description here
70
+ # @return [String] Response from the API call.
71
+ def custom_query_or_header_authentication
72
+ @api_call
73
+ .request(new_request_builder(HttpMethodEnum::GET,
74
+ '/auth/customQueryOrHeaderParam',
75
+ Server::DEFAULT)
76
+ .auth(Or.new('apiKey', 'apiHeader')))
77
+ .response(new_response_handler
78
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
79
+ .deserialize_into(proc do |response| response&.to_s end)
80
+ .is_primitive_response(true))
81
+ .execute
82
+ end
83
+
84
+ # TODO: type endpoint description here
85
+ # @return [String] Response from the API call.
86
+ def basic_auth_and_api_header_auth
87
+ @api_call
88
+ .request(new_request_builder(HttpMethodEnum::GET,
89
+ '/auth/basicAndApiKeyAndApiHeader',
90
+ Server::DEFAULT)
91
+ .auth(And.new('basicAuth', 'apiKey', 'apiHeader')))
92
+ .response(new_response_handler
93
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
94
+ .deserialize_into(proc do |response| response&.to_s end)
95
+ .is_primitive_response(true))
96
+ .execute
97
+ end
98
+
99
+ # This endpoint tests or combinations of OAuth types
100
+ # @return [String] Response from the API call.
101
+ def o_auth_grant_types_or_combinations
102
+ @api_call
103
+ .request(new_request_builder(HttpMethodEnum::GET,
104
+ '/oauth2/oauthOrCombination',
105
+ Server::DEFAULT)
106
+ .auth(Or.new('OAuthCCG', 'OAuthBearerToken')))
107
+ .response(new_response_handler
108
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
109
+ .deserialize_into(proc do |response| response&.to_s end)
110
+ .is_primitive_response(true))
111
+ .execute
112
+ end
113
+
114
+ # This endpoint uses globally applied auth which is a hypothetical scneraio
115
+ # but covers the worst case.
116
+ # @return [String] Response from the API call.
117
+ def multiple_auth_combination
118
+ @api_call
119
+ .request(new_request_builder(HttpMethodEnum::GET,
120
+ '/auth/multipleAuthCombination',
121
+ Server::DEFAULT)
122
+ .auth(Or.new('CustomAuth', 'OAuthBearerToken', And.new('basicAuth', 'apiKey', 'apiHeader'))))
123
+ .response(new_response_handler
124
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
125
+ .deserialize_into(proc do |response| response&.to_s end)
126
+ .is_primitive_response(true))
127
+ .execute
128
+ end
129
+
130
+ # This endpoint does not use auth.
131
+ # @return [String] Response from the API call.
132
+ def no_auth
133
+ warn 'Endpoint no_auth in AuthenticationController is deprecated since v'\
134
+ 'ersion 0.0.1-alpha. You should not use this method as it requir'\
135
+ 'es no auth and can bring security issues to the server and api cal'\
136
+ 'l itself!!'
137
+ @api_call
138
+ .request(new_request_builder(HttpMethodEnum::GET,
139
+ '/auth/noAuth',
140
+ Server::DEFAULT)
141
+ .query_param(new_parameter(true, key: 'array')))
142
+ .response(new_response_handler
143
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
144
+ .deserialize_into(proc do |response| response&.to_s end)
145
+ .is_primitive_response(true))
146
+ .execute
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,60 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # BaseController.
8
+ class BaseController
9
+ include CoreLibrary
10
+ attr_accessor :config, :http_call_back
11
+
12
+ def self.user_agent
13
+ 'APIMATIC 3.0'
14
+ end
15
+
16
+
17
+ GLOBAL_ERRORS = {
18
+ 'default' => ErrorCase.new
19
+ .error_message('HTTP response not OK.')
20
+ .exception_type(APIException)
21
+ }.freeze
22
+
23
+ # Initialization constructor.
24
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
25
+ def initialize(global_configuration)
26
+ @global_configuration = global_configuration
27
+ @config = @global_configuration.client_configuration
28
+ @http_call_back = @config.http_callback
29
+ @api_call = ApiCall.new(@global_configuration)
30
+ end
31
+
32
+ # Creates a new instance of the request builder.
33
+ # @param [String] http_method The HTTP method to use in the request.
34
+ # @param [String] path The endpoint path to use in the request.
35
+ # @param [String] server The server to extract the base uri for the request.
36
+ # @return [RequestBuilder] The instance of RequestBuilder.
37
+ def new_request_builder(http_method, path, server)
38
+ RequestBuilder.new
39
+ .http_method(http_method)
40
+ .path(path)
41
+ .server(server)
42
+ end
43
+
44
+ # Creates a new instance of the response handler.
45
+ # @return [ResponseHandler] The instance of ResponseHandler.
46
+ def new_response_handler
47
+ ResponseHandler.new
48
+ end
49
+
50
+ # Creates a new instance of the parameter.
51
+ # @param [String|optional] key The key of the parameter.
52
+ # @param [Object] value The value of the parameter.
53
+ # @return [Parameter] The instance of Parameter.
54
+ def new_parameter(value, key: nil)
55
+ Parameter.new
56
+ .key(key)
57
+ .value(value)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,188 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # OAuthAuthorizationController
8
+ class OAuthAuthorizationController < BaseController
9
+ # Create a new OAuth 2 token.
10
+ # @param [String] authorization Required parameter: Authorization header in
11
+ # Basic auth format
12
+ # @param [String] scope Optional parameter: Requested scopes as a
13
+ # space-delimited list.
14
+ # @param [Hash] _field_parameters Additional optional form parameters are
15
+ # supported by this endpoint.
16
+ # @return [OAuthToken] Response from the API call.
17
+ def request_token_o_auth_ccg(authorization,
18
+ scope: nil,
19
+ _field_parameters: nil)
20
+ @api_call
21
+ .request(new_request_builder(HttpMethodEnum::POST,
22
+ '/request_token',
23
+ Server::AUTH)
24
+ .form_param(new_parameter('client_credentials', key: 'grant_type'))
25
+ .header_param(new_parameter(authorization, key: 'Authorization'))
26
+ .form_param(new_parameter(scope, key: 'scope'))
27
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
28
+ .header_param(new_parameter('application/json', key: 'accept'))
29
+ .additional_form_params(_field_parameters))
30
+ .response(new_response_handler
31
+ .deserializer(APIHelper.method(:custom_type_deserializer))
32
+ .deserialize_into(OAuthToken.method(:from_hash))
33
+ .local_error('400',
34
+ 'OAuth 2 provider returned an error.',
35
+ OAuthProviderException)
36
+ .local_error('401',
37
+ 'OAuth 2 provider says client authentication failed.',
38
+ OAuthProviderException))
39
+ .execute
40
+ end
41
+
42
+ # Create a new OAuth 2 token.
43
+ # @param [String] authorization Required parameter: Authorization header in
44
+ # Basic auth format
45
+ # @param [String] code Required parameter: Authorization Code
46
+ # @param [String] redirect_uri Required parameter: Redirect Uri
47
+ # @param [Hash] _field_parameters Additional optional form parameters are
48
+ # supported by this endpoint.
49
+ # @return [OAuthToken] Response from the API call.
50
+ def request_token_o_auth_acg(authorization,
51
+ code,
52
+ redirect_uri,
53
+ _field_parameters: nil)
54
+ @api_call
55
+ .request(new_request_builder(HttpMethodEnum::POST,
56
+ '/oauth2/non-auth-server/token',
57
+ Server::DEFAULT)
58
+ .form_param(new_parameter('authorization_code', key: 'grant_type'))
59
+ .header_param(new_parameter(authorization, key: 'Authorization'))
60
+ .form_param(new_parameter(code, key: 'code'))
61
+ .form_param(new_parameter(redirect_uri, key: 'redirect_uri'))
62
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
63
+ .header_param(new_parameter('application/json', key: 'accept'))
64
+ .additional_form_params(_field_parameters))
65
+ .response(new_response_handler
66
+ .deserializer(APIHelper.method(:custom_type_deserializer))
67
+ .deserialize_into(OAuthToken.method(:from_hash))
68
+ .local_error('400',
69
+ 'OAuth 2 provider returned an error.',
70
+ OAuthProviderException)
71
+ .local_error('401',
72
+ 'OAuth 2 provider says client authentication failed.',
73
+ OAuthProviderException))
74
+ .execute
75
+ end
76
+
77
+ # Obtain a new access token using a refresh token
78
+ # @param [String] authorization Required parameter: Authorization header in
79
+ # Basic auth format
80
+ # @param [String] refresh_token Required parameter: Refresh token
81
+ # @param [String] scope Optional parameter: Requested scopes as a
82
+ # space-delimited list.
83
+ # @param [Hash] _field_parameters Additional optional form parameters are
84
+ # supported by this endpoint.
85
+ # @return [OAuthToken] Response from the API call.
86
+ def refresh_token_o_auth_acg(authorization,
87
+ refresh_token,
88
+ scope: nil,
89
+ _field_parameters: nil)
90
+ @api_call
91
+ .request(new_request_builder(HttpMethodEnum::POST,
92
+ '/oauth2/non-auth-server/token',
93
+ Server::DEFAULT)
94
+ .form_param(new_parameter('refresh_token', key: 'grant_type'))
95
+ .header_param(new_parameter(authorization, key: 'Authorization'))
96
+ .form_param(new_parameter(refresh_token, key: 'refresh_token'))
97
+ .form_param(new_parameter(scope, key: 'scope'))
98
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
99
+ .header_param(new_parameter('application/json', key: 'accept'))
100
+ .additional_form_params(_field_parameters))
101
+ .response(new_response_handler
102
+ .deserializer(APIHelper.method(:custom_type_deserializer))
103
+ .deserialize_into(OAuthToken.method(:from_hash))
104
+ .local_error('400',
105
+ 'OAuth 2 provider returned an error.',
106
+ OAuthProviderException)
107
+ .local_error('401',
108
+ 'OAuth 2 provider says client authentication failed.',
109
+ OAuthProviderException))
110
+ .execute
111
+ end
112
+
113
+ # Create a new OAuth 2 token.
114
+ # @param [String] authorization Required parameter: Authorization header in
115
+ # Basic auth format
116
+ # @param [String] username Required parameter: Resource owner username
117
+ # @param [String] password Required parameter: Resource owner password
118
+ # @param [String] scope Optional parameter: Requested scopes as a
119
+ # space-delimited list.
120
+ # @param [Hash] _field_parameters Additional optional form parameters are
121
+ # supported by this endpoint.
122
+ # @return [OAuthToken] Response from the API call.
123
+ def request_token_o_auth_ropcg(authorization,
124
+ username,
125
+ password,
126
+ scope: nil,
127
+ _field_parameters: nil)
128
+ @api_call
129
+ .request(new_request_builder(HttpMethodEnum::POST,
130
+ '/oauth2/non-auth-server/token',
131
+ Server::DEFAULT)
132
+ .form_param(new_parameter('password', key: 'grant_type'))
133
+ .header_param(new_parameter(authorization, key: 'Authorization'))
134
+ .form_param(new_parameter(username, key: 'username'))
135
+ .form_param(new_parameter(password, key: 'password'))
136
+ .form_param(new_parameter(scope, key: 'scope'))
137
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
138
+ .header_param(new_parameter('application/json', key: 'accept'))
139
+ .additional_form_params(_field_parameters))
140
+ .response(new_response_handler
141
+ .deserializer(APIHelper.method(:custom_type_deserializer))
142
+ .deserialize_into(OAuthToken.method(:from_hash))
143
+ .local_error('400',
144
+ 'OAuth 2 provider returned an error.',
145
+ OAuthProviderException)
146
+ .local_error('401',
147
+ 'OAuth 2 provider says client authentication failed.',
148
+ OAuthProviderException))
149
+ .execute
150
+ end
151
+
152
+ # Obtain a new access token using a refresh token
153
+ # @param [String] authorization Required parameter: Authorization header in
154
+ # Basic auth format
155
+ # @param [String] refresh_token Required parameter: Refresh token
156
+ # @param [String] scope Optional parameter: Requested scopes as a
157
+ # space-delimited list.
158
+ # @param [Hash] _field_parameters Additional optional form parameters are
159
+ # supported by this endpoint.
160
+ # @return [OAuthToken] Response from the API call.
161
+ def refresh_token_o_auth_ropcg(authorization,
162
+ refresh_token,
163
+ scope: nil,
164
+ _field_parameters: nil)
165
+ @api_call
166
+ .request(new_request_builder(HttpMethodEnum::POST,
167
+ '/oauth2/non-auth-server/token',
168
+ Server::DEFAULT)
169
+ .form_param(new_parameter('refresh_token', key: 'grant_type'))
170
+ .header_param(new_parameter(authorization, key: 'Authorization'))
171
+ .form_param(new_parameter(refresh_token, key: 'refresh_token'))
172
+ .form_param(new_parameter(scope, key: 'scope'))
173
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
174
+ .header_param(new_parameter('application/json', key: 'accept'))
175
+ .additional_form_params(_field_parameters))
176
+ .response(new_response_handler
177
+ .deserializer(APIHelper.method(:custom_type_deserializer))
178
+ .deserialize_into(OAuthToken.method(:from_hash))
179
+ .local_error('400',
180
+ 'OAuth 2 provider returned an error.',
181
+ OAuthProviderException)
182
+ .local_error('401',
183
+ 'OAuth 2 provider says client authentication failed.',
184
+ OAuthProviderException))
185
+ .execute
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,21 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # Class for exceptions when there is a network error, status code error, etc.
8
+ class APIException < CoreLibrary::ApiException
9
+ # Provides a human-readable string representation of the object.
10
+ def to_s
11
+ class_name = self.class.name.split('::').last
12
+ "<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
13
+ end
14
+
15
+ # Provides a debugging-friendly string with detailed object information.
16
+ def inspect
17
+ class_name = self.class.name.split('::').last
18
+ "<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,64 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # OAuth 2 Authorization endpoint exception.
8
+ class OAuthProviderException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Gets or sets error code.
13
+ # @return [OAuthProviderErrorEnum]
14
+ attr_accessor :error
15
+
16
+ # Gets or sets human-readable text providing additional information on
17
+ # error.
18
+ # Used to assist the client developer in understanding the error that
19
+ # occurred.
20
+ # @return [String]
21
+ attr_accessor :error_description
22
+
23
+ # Gets or sets a URI identifying a human-readable web page with information
24
+ # about the error, used to provide the client developer with additional
25
+ # information about the error.
26
+ # @return [String]
27
+ attr_accessor :error_uri
28
+
29
+ # The constructor.
30
+ # @param [String] reason The reason for raising an exception.
31
+ # @param [HttpResponse] response The HttpReponse of the API call.
32
+ def initialize(reason, response)
33
+ super(reason, response)
34
+ hash = APIHelper.json_deserialize(@response.raw_body)
35
+ unbox(hash)
36
+ end
37
+
38
+ # Populates this object by extracting properties from a hash.
39
+ # @param [Hash] hash The deserialized response sent by the server in the
40
+ # response body.
41
+ def unbox(hash)
42
+ return nil unless hash
43
+
44
+ @error = hash.key?('error') ? hash['error'] : nil
45
+ @error_description =
46
+ hash.key?('error_description') ? hash['error_description'] : SKIP
47
+ @error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP
48
+ end
49
+
50
+ # Provides a human-readable string representation of the object.
51
+ def to_s
52
+ class_name = self.class.name.split('::').last
53
+ "<#{class_name} error: #{@error}, error_description: #{@error_description}, error_uri:"\
54
+ " #{@error_uri}>"
55
+ end
56
+
57
+ # Provides a debugging-friendly string with detailed object information.
58
+ def inspect
59
+ class_name = self.class.name.split('::').last
60
+ "<#{class_name} error: #{@error.inspect}, error_description: #{@error_description.inspect},"\
61
+ " error_uri: #{@error_uri.inspect}>"
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,59 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # Utility class for custom header authorization.
8
+ class ApiHeader < CoreLibrary::HeaderAuth
9
+ # Display error message on occurrence of authentication failure.
10
+ # @returns [String] The oAuth error message.
11
+ def error_message
12
+ 'ApiHeader: token or api_key is undefined.'
13
+ end
14
+
15
+ # Initialization constructor.
16
+ def initialize(api_header_credentials)
17
+ auth_params = {}
18
+ auth_params['token'] = api_header_credentials.token unless
19
+ api_header_credentials.nil? || api_header_credentials.token.nil?
20
+ auth_params['api-key'] = api_header_credentials.api_key unless
21
+ api_header_credentials.nil? || api_header_credentials.api_key.nil?
22
+
23
+ super auth_params
24
+ end
25
+ end
26
+
27
+ # Data class for ApiHeaderCredentials.
28
+ # Data class for ApiHeaderCredentials.
29
+ class ApiHeaderCredentials
30
+ attr_reader :token, :api_key
31
+
32
+ def initialize(token:, api_key:)
33
+ raise ArgumentError, 'token cannot be nil' if token.nil?
34
+ raise ArgumentError, 'api_key cannot be nil' if api_key.nil?
35
+
36
+ @token = token
37
+ @api_key = api_key
38
+ end
39
+
40
+ def self.from_env
41
+ token = ENV['API_HEADER_TOKEN']
42
+ api_key = ENV['API_HEADER_API_KEY']
43
+ all_nil = [
44
+ token,
45
+ api_key
46
+ ].all?(&:nil?)
47
+ return nil if all_nil
48
+
49
+ new(token: token, api_key: api_key)
50
+ end
51
+
52
+ def clone_with(token: nil, api_key: nil)
53
+ token ||= self.token
54
+ api_key ||= self.api_key
55
+
56
+ ApiHeaderCredentials.new(token: token, api_key: api_key)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # Utility class for custom query_parameter authorization.
8
+ class ApiKey < CoreLibrary::QueryAuth
9
+ # Display error message on occurrence of authentication failure.
10
+ # @returns [String] The oAuth error message.
11
+ def error_message
12
+ 'ApiKey: token or api_key is undefined.'
13
+ end
14
+
15
+ # Initialization constructor.
16
+ def initialize(api_key_credentials)
17
+ auth_params = {}
18
+ auth_params['token'] = api_key_credentials.token unless
19
+ api_key_credentials.nil? || api_key_credentials.token.nil?
20
+ auth_params['api-key'] = api_key_credentials.api_key unless
21
+ api_key_credentials.nil? || api_key_credentials.api_key.nil?
22
+
23
+ super auth_params
24
+ end
25
+ end
26
+
27
+ # Data class for ApiKeyCredentials.
28
+ # Data class for ApiKeyCredentials.
29
+ class ApiKeyCredentials
30
+ attr_reader :token, :api_key
31
+
32
+ def initialize(token:, api_key:)
33
+ raise ArgumentError, 'token cannot be nil' if token.nil?
34
+ raise ArgumentError, 'api_key cannot be nil' if api_key.nil?
35
+
36
+ @token = token
37
+ @api_key = api_key
38
+ end
39
+
40
+ def self.from_env
41
+ token = ENV['API_KEY_TOKEN']
42
+ api_key = ENV['API_KEY_API_KEY']
43
+ all_nil = [
44
+ token,
45
+ api_key
46
+ ].all?(&:nil?)
47
+ return nil if all_nil
48
+
49
+ new(token: token, api_key: api_key)
50
+ end
51
+
52
+ def clone_with(token: nil, api_key: nil)
53
+ token ||= self.token
54
+ api_key ||= self.api_key
55
+
56
+ ApiKeyCredentials.new(token: token, api_key: api_key)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,62 @@
1
+ # multi_auth_sample
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ module MultiAuthSample
7
+ # Utility class for basic authorization.
8
+ class BasicAuth < CoreLibrary::HeaderAuth
9
+ include CoreLibrary
10
+ # Display error message on occurrence of authentication failure.
11
+ # @returns [String] The oAuth error message.
12
+ def error_message
13
+ 'BasicAuth: username or password is undefined.'
14
+ end
15
+
16
+ # Initialization constructor.
17
+ def initialize(basic_auth_credentials)
18
+ auth_params = {}
19
+ unless basic_auth_credentials.nil? ||
20
+ basic_auth_credentials.username.nil? ||
21
+ basic_auth_credentials.password.nil?
22
+ auth_params['Authorization'] =
23
+ "Basic #{AuthHelper.get_base64_encoded_value(basic_auth_credentials.username,
24
+ basic_auth_credentials.password)}"
25
+ end
26
+
27
+ super auth_params
28
+ end
29
+ end
30
+
31
+ # Data class for BasicAuthCredentials.
32
+ class BasicAuthCredentials
33
+ attr_reader :username, :password
34
+
35
+ def initialize(username:, password:)
36
+ raise ArgumentError, 'username cannot be nil' if username.nil?
37
+ raise ArgumentError, 'password cannot be nil' if password.nil?
38
+
39
+ @username = username
40
+ @password = password
41
+ end
42
+
43
+ def self.from_env
44
+ username = ENV['BASIC_AUTH_USERNAME']
45
+ password = ENV['BASIC_AUTH_PASSWORD']
46
+ all_nil = [
47
+ username,
48
+ password
49
+ ].all?(&:nil?)
50
+ return nil if all_nil
51
+
52
+ new(username: username, password: password)
53
+ end
54
+
55
+ def clone_with(username: nil, password: nil)
56
+ username ||= self.username
57
+ password ||= self.password
58
+
59
+ BasicAuthCredentials.new(username: username, password: password)
60
+ end
61
+ end
62
+ end