multi-auth-project-sdk 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/LICENSE +28 -0
- data/README.md +139 -0
- data/lib/multi_auth_sample/api_helper.rb +10 -0
- data/lib/multi_auth_sample/client.rb +105 -0
- data/lib/multi_auth_sample/configuration.rb +170 -0
- data/lib/multi_auth_sample/controllers/authentication_controller.rb +151 -0
- data/lib/multi_auth_sample/controllers/base_controller.rb +65 -0
- data/lib/multi_auth_sample/controllers/o_auth_authorization_controller.rb +188 -0
- data/lib/multi_auth_sample/exceptions/api_exception.rb +10 -0
- data/lib/multi_auth_sample/exceptions/o_auth_provider_exception.rb +48 -0
- data/lib/multi_auth_sample/http/auth/api_header.rb +47 -0
- data/lib/multi_auth_sample/http/auth/api_key.rb +47 -0
- data/lib/multi_auth_sample/http/auth/basic_auth.rb +49 -0
- data/lib/multi_auth_sample/http/auth/custom_auth.rb +40 -0
- data/lib/multi_auth_sample/http/auth/o_auth_acg.rb +144 -0
- data/lib/multi_auth_sample/http/auth/o_auth_bearer_token.rb +42 -0
- data/lib/multi_auth_sample/http/auth/o_auth_ccg.rb +88 -0
- data/lib/multi_auth_sample/http/auth/o_auth_ropcg.rb +120 -0
- data/lib/multi_auth_sample/http/http_call_back.rb +10 -0
- data/lib/multi_auth_sample/http/http_method_enum.rb +10 -0
- data/lib/multi_auth_sample/http/http_request.rb +10 -0
- data/lib/multi_auth_sample/http/http_response.rb +10 -0
- data/lib/multi_auth_sample/models/base_model.rb +62 -0
- data/lib/multi_auth_sample/models/o_auth_provider_error_enum.rb +45 -0
- data/lib/multi_auth_sample/models/o_auth_scope_o_auth_acg_enum.rb +20 -0
- data/lib/multi_auth_sample/models/o_auth_token.rb +110 -0
- data/lib/multi_auth_sample/models/service_status.rb +129 -0
- data/lib/multi_auth_sample/models/suite_code_enum.rb +29 -0
- data/lib/multi_auth_sample/models/user.rb +100 -0
- data/lib/multi_auth_sample/utilities/date_time_helper.rb +11 -0
- data/lib/multi_auth_sample/utilities/file_wrapper.rb +16 -0
- data/lib/multi_auth_sample.rb +54 -0
- data/test/controllers/controller_test_base.rb +47 -0
- data/test/controllers/test_authentication_controller.rb +110 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +154 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
8
|
+
class OAuthBearerToken < CoreLibrary::HeaderAuth
|
9
|
+
# Display error message on occurrence of authentication failure.
|
10
|
+
# @returns [String] The oAuth error message.
|
11
|
+
def error_message
|
12
|
+
'OAuthBearerToken: access_token is undefined.'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initialization constructor.
|
16
|
+
def initialize(o_auth_bearer_token_credentials)
|
17
|
+
auth_params = {}
|
18
|
+
@_access_token = o_auth_bearer_token_credentials.access_token unless
|
19
|
+
o_auth_bearer_token_credentials.nil? || o_auth_bearer_token_credentials.access_token.nil?
|
20
|
+
auth_params['Authorization'] = "Bearer #{@_access_token}" unless @_access_token.nil?
|
21
|
+
|
22
|
+
super auth_params
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Data class for OAuthBearerTokenCredentials.
|
27
|
+
class OAuthBearerTokenCredentials
|
28
|
+
attr_reader :access_token
|
29
|
+
|
30
|
+
def initialize(access_token:)
|
31
|
+
raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
|
32
|
+
|
33
|
+
@access_token = access_token
|
34
|
+
end
|
35
|
+
|
36
|
+
def clone_with(access_token: nil)
|
37
|
+
access_token ||= self.access_token
|
38
|
+
|
39
|
+
OAuthBearerTokenCredentials.new(access_token: access_token)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
8
|
+
class OAuthCCG < CoreLibrary::HeaderAuth
|
9
|
+
# Display error message on occurrence of authentication failure.
|
10
|
+
# @returns [String] The oAuth error message.
|
11
|
+
def error_message
|
12
|
+
'OAuthCCG: OAuthToken is undefined or expired.'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initialization constructor.
|
16
|
+
def initialize(o_auth_ccg_credentials, config)
|
17
|
+
auth_params = {}
|
18
|
+
@_o_auth_client_id = o_auth_ccg_credentials.o_auth_client_id unless
|
19
|
+
o_auth_ccg_credentials.nil? || o_auth_ccg_credentials.o_auth_client_id.nil?
|
20
|
+
@_o_auth_client_secret = o_auth_ccg_credentials.o_auth_client_secret unless
|
21
|
+
o_auth_ccg_credentials.nil? || o_auth_ccg_credentials.o_auth_client_secret.nil?
|
22
|
+
@_o_auth_token = o_auth_ccg_credentials.o_auth_token unless
|
23
|
+
o_auth_ccg_credentials.nil? || o_auth_ccg_credentials.o_auth_token.nil?
|
24
|
+
@_o_auth_api = OAuthAuthorizationController.new(config)
|
25
|
+
auth_params['Authorization'] = "Bearer #{@_o_auth_token.access_token}" unless @_o_auth_token.nil?
|
26
|
+
|
27
|
+
super auth_params
|
28
|
+
end
|
29
|
+
|
30
|
+
# Validates the oAuth token.
|
31
|
+
# @return [Boolean] true if the token is present and not expired.
|
32
|
+
def valid
|
33
|
+
!@_o_auth_token.nil? && !token_expired?(@_o_auth_token)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
37
|
+
# @return [String] The value of the Authentication header.
|
38
|
+
def build_basic_auth_header
|
39
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_o_auth_client_id, @_o_auth_client_secret)}"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Fetches the token.
|
43
|
+
# @param [Hash] additional_params Any additional form parameters.
|
44
|
+
# @return [OAuthToken] The oAuth token instance.
|
45
|
+
def fetch_token(additional_params: nil)
|
46
|
+
token = @_o_auth_api.request_token_o_auth_ccg(
|
47
|
+
build_basic_auth_header,
|
48
|
+
_field_parameters: additional_params
|
49
|
+
)
|
50
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
51
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
52
|
+
end
|
53
|
+
token
|
54
|
+
end
|
55
|
+
|
56
|
+
# Checks if OAuth token has expired.
|
57
|
+
# @param [OAuthToken] token The oAuth token instance.
|
58
|
+
# @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
|
59
|
+
def token_expired?(token)
|
60
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Data class for OAuthCCGCredentials.
|
65
|
+
class OAuthCCGCredentials
|
66
|
+
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_token
|
67
|
+
|
68
|
+
def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_token: nil)
|
69
|
+
raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
|
70
|
+
raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
|
71
|
+
|
72
|
+
@o_auth_client_id = o_auth_client_id
|
73
|
+
@o_auth_client_secret = o_auth_client_secret
|
74
|
+
@o_auth_token = o_auth_token
|
75
|
+
end
|
76
|
+
|
77
|
+
def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
|
78
|
+
o_auth_token: nil)
|
79
|
+
o_auth_client_id ||= self.o_auth_client_id
|
80
|
+
o_auth_client_secret ||= self.o_auth_client_secret
|
81
|
+
o_auth_token ||= self.o_auth_token
|
82
|
+
|
83
|
+
OAuthCCGCredentials.new(o_auth_client_id: o_auth_client_id,
|
84
|
+
o_auth_client_secret: o_auth_client_secret,
|
85
|
+
o_auth_token: o_auth_token)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
8
|
+
class OAuthROPCG < CoreLibrary::HeaderAuth
|
9
|
+
# Display error message on occurrence of authentication failure.
|
10
|
+
# @returns [String] The oAuth error message.
|
11
|
+
def error_message
|
12
|
+
'OAuthROPCG: OAuthToken is undefined or expired.'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initialization constructor.
|
16
|
+
def initialize(o_auth_ropcg_credentials, config)
|
17
|
+
auth_params = {}
|
18
|
+
@_o_auth_client_id = o_auth_ropcg_credentials.o_auth_client_id unless
|
19
|
+
o_auth_ropcg_credentials.nil? || o_auth_ropcg_credentials.o_auth_client_id.nil?
|
20
|
+
@_o_auth_client_secret = o_auth_ropcg_credentials.o_auth_client_secret unless
|
21
|
+
o_auth_ropcg_credentials.nil? || o_auth_ropcg_credentials.o_auth_client_secret.nil?
|
22
|
+
@_o_auth_username = o_auth_ropcg_credentials.o_auth_username unless
|
23
|
+
o_auth_ropcg_credentials.nil? || o_auth_ropcg_credentials.o_auth_username.nil?
|
24
|
+
@_o_auth_password = o_auth_ropcg_credentials.o_auth_password unless
|
25
|
+
o_auth_ropcg_credentials.nil? || o_auth_ropcg_credentials.o_auth_password.nil?
|
26
|
+
@_o_auth_token = o_auth_ropcg_credentials.o_auth_token unless
|
27
|
+
o_auth_ropcg_credentials.nil? || o_auth_ropcg_credentials.o_auth_token.nil?
|
28
|
+
@_o_auth_api = OAuthAuthorizationController.new(config)
|
29
|
+
auth_params['Authorization'] = "Bearer #{@_o_auth_token.access_token}" unless @_o_auth_token.nil?
|
30
|
+
|
31
|
+
super auth_params
|
32
|
+
end
|
33
|
+
|
34
|
+
# Validates the oAuth token.
|
35
|
+
# @return [Boolean] true if the token is present and not expired.
|
36
|
+
def valid
|
37
|
+
!@_o_auth_token.nil? && !token_expired?(@_o_auth_token)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
41
|
+
# @return [String] The value of the Authentication header.
|
42
|
+
def build_basic_auth_header
|
43
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_o_auth_client_id, @_o_auth_client_secret)}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Fetches the token.
|
47
|
+
# @param [Hash] additional_params Any additional form parameters.
|
48
|
+
# @return [OAuthToken] The oAuth token instance.
|
49
|
+
def fetch_token(additional_params: nil)
|
50
|
+
token = @_o_auth_api.request_token_o_auth_ropcg(
|
51
|
+
build_basic_auth_header,
|
52
|
+
@_o_auth_username,
|
53
|
+
@_o_auth_password,
|
54
|
+
_field_parameters: additional_params
|
55
|
+
)
|
56
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
57
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
58
|
+
end
|
59
|
+
token
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks if OAuth token has expired.
|
63
|
+
# @param [OAuthToken] token The oAuth token instance.
|
64
|
+
# @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
|
65
|
+
def token_expired?(token)
|
66
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Refreshes OAuth token.
|
70
|
+
# @param [Hash] additional_params Any additional form parameters.
|
71
|
+
# @return [OAuthToken] The oAuth token instance.
|
72
|
+
def refresh_token(additional_params: nil)
|
73
|
+
token = @_o_auth_api.refresh_token_o_auth_ropcg(
|
74
|
+
OAuthROPCG.build_basic_auth_header,
|
75
|
+
@_o_auth_token.refresh_token,
|
76
|
+
_field_parameters: additional_params
|
77
|
+
)
|
78
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
79
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
80
|
+
end
|
81
|
+
token
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Data class for OAuthROPCGCredentials.
|
86
|
+
class OAuthROPCGCredentials
|
87
|
+
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_username,
|
88
|
+
:o_auth_password, :o_auth_token
|
89
|
+
|
90
|
+
def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_username:,
|
91
|
+
o_auth_password:, o_auth_token: nil)
|
92
|
+
raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
|
93
|
+
raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
|
94
|
+
raise ArgumentError, 'o_auth_username cannot be nil' if o_auth_username.nil?
|
95
|
+
raise ArgumentError, 'o_auth_password cannot be nil' if o_auth_password.nil?
|
96
|
+
|
97
|
+
@o_auth_client_id = o_auth_client_id
|
98
|
+
@o_auth_client_secret = o_auth_client_secret
|
99
|
+
@o_auth_username = o_auth_username
|
100
|
+
@o_auth_password = o_auth_password
|
101
|
+
@o_auth_token = o_auth_token
|
102
|
+
end
|
103
|
+
|
104
|
+
def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
|
105
|
+
o_auth_username: nil, o_auth_password: nil,
|
106
|
+
o_auth_token: nil)
|
107
|
+
o_auth_client_id ||= self.o_auth_client_id
|
108
|
+
o_auth_client_secret ||= self.o_auth_client_secret
|
109
|
+
o_auth_username ||= self.o_auth_username
|
110
|
+
o_auth_password ||= self.o_auth_password
|
111
|
+
o_auth_token ||= self.o_auth_token
|
112
|
+
|
113
|
+
OAuthROPCGCredentials.new(o_auth_client_id: o_auth_client_id,
|
114
|
+
o_auth_client_secret: o_auth_client_secret,
|
115
|
+
o_auth_username: o_auth_username,
|
116
|
+
o_auth_password: o_auth_password,
|
117
|
+
o_auth_token: o_auth_token)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# Base model.
|
8
|
+
class BaseModel < CoreLibrary::BaseModel
|
9
|
+
# Returns a Hash representation of the current object.
|
10
|
+
def to_hash
|
11
|
+
# validating the model being serialized
|
12
|
+
self.class.validate(self) if self.class.respond_to?(:validate)
|
13
|
+
|
14
|
+
hash = {}
|
15
|
+
instance_variables.each do |name|
|
16
|
+
value = instance_variable_get(name)
|
17
|
+
name = name[1..]
|
18
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
19
|
+
optional_fields = self.class.optionals
|
20
|
+
nullable_fields = self.class.nullables
|
21
|
+
if value.nil?
|
22
|
+
next unless nullable_fields.include?(name)
|
23
|
+
|
24
|
+
if !optional_fields.include?(name) && !nullable_fields.include?(name)
|
25
|
+
raise ArgumentError,
|
26
|
+
"`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
hash[key] = nil
|
31
|
+
unless value.nil?
|
32
|
+
if respond_to?("to_custom_#{name}")
|
33
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
34
|
+
params = [hash, key]
|
35
|
+
hash[key] = send("to_custom_#{name}", *params)
|
36
|
+
else
|
37
|
+
hash[key] = send("to_custom_#{name}")
|
38
|
+
end
|
39
|
+
elsif respond_to?("to_union_type_#{name}")
|
40
|
+
hash[key] = send("to_union_type_#{name}")
|
41
|
+
elsif value.instance_of? Array
|
42
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
43
|
+
elsif value.instance_of? Hash
|
44
|
+
hash[key] = {}
|
45
|
+
value.each do |k, v|
|
46
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
47
|
+
end
|
48
|
+
else
|
49
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
hash
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns a JSON representation of the curent object.
|
57
|
+
def to_json(options = {})
|
58
|
+
hash = to_hash
|
59
|
+
hash.to_json(options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# OAuth 2 Authorization error codes
|
8
|
+
class OAuthProviderErrorEnum
|
9
|
+
O_AUTH_PROVIDER_ERROR_ENUM = [
|
10
|
+
# The request is missing a required parameter, includes an unsupported
|
11
|
+
# parameter value (other than grant type), repeats a parameter, includes
|
12
|
+
# multiple credentials, utilizes more than one mechanism for
|
13
|
+
# authenticating the client, or is otherwise malformed.
|
14
|
+
INVALID_REQUEST = 'invalid_request'.freeze,
|
15
|
+
|
16
|
+
# Client authentication failed (e.g., unknown client, no client
|
17
|
+
# authentication included, or unsupported authentication method).
|
18
|
+
INVALID_CLIENT = 'invalid_client'.freeze,
|
19
|
+
|
20
|
+
# The provided authorization grant (e.g., authorization code, resource
|
21
|
+
# owner credentials) or refresh token is invalid, expired, revoked, does
|
22
|
+
# not match the redirection URI used in the authorization request, or was
|
23
|
+
# issued to another client.
|
24
|
+
INVALID_GRANT = 'invalid_grant'.freeze,
|
25
|
+
|
26
|
+
# The authenticated client is not authorized to use this authorization
|
27
|
+
# grant type.
|
28
|
+
UNAUTHORIZED_CLIENT = 'unauthorized_client'.freeze,
|
29
|
+
|
30
|
+
# The authorization grant type is not supported by the authorization
|
31
|
+
# server.
|
32
|
+
UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'.freeze,
|
33
|
+
|
34
|
+
# The requested scope is invalid, unknown, malformed, or exceeds the scope
|
35
|
+
# granted by the resource owner.
|
36
|
+
INVALID_SCOPE = 'invalid_scope'.freeze
|
37
|
+
].freeze
|
38
|
+
|
39
|
+
def self.validate(value)
|
40
|
+
return false if value.nil?
|
41
|
+
|
42
|
+
O_AUTH_PROVIDER_ERROR_ENUM.include?(value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# OAuth 2 scopes supported by the API
|
8
|
+
class OAuthScopeOAuthACGEnum
|
9
|
+
O_AUTH_SCOPE_O_AUTH_ACG_ENUM = [
|
10
|
+
# Read request for files
|
11
|
+
READ_SCOPE = 'file_requests.read'.freeze
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
def self.validate(value)
|
15
|
+
return false if value.nil?
|
16
|
+
|
17
|
+
O_AUTH_SCOPE_O_AUTH_ACG_ENUM.include?(value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# OAuth 2 Authorization endpoint response
|
8
|
+
class OAuthToken < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Access token
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :access_token
|
15
|
+
|
16
|
+
# Type of access token
|
17
|
+
# @return [String]
|
18
|
+
attr_accessor :token_type
|
19
|
+
|
20
|
+
# Time in seconds before the access token expires
|
21
|
+
# @return [Integer]
|
22
|
+
attr_accessor :expires_in
|
23
|
+
|
24
|
+
# List of scopes granted
|
25
|
+
# This is a space-delimited list of strings.
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :scope
|
28
|
+
|
29
|
+
# Time of token expiry as unix timestamp (UTC)
|
30
|
+
# @return [Integer]
|
31
|
+
attr_accessor :expiry
|
32
|
+
|
33
|
+
# Refresh token
|
34
|
+
# Used to get a new access token when it expires.
|
35
|
+
# @return [String]
|
36
|
+
attr_accessor :refresh_token
|
37
|
+
|
38
|
+
# A mapping from model property names to API property names.
|
39
|
+
def self.names
|
40
|
+
@_hash = {} if @_hash.nil?
|
41
|
+
@_hash['access_token'] = 'access_token'
|
42
|
+
@_hash['token_type'] = 'token_type'
|
43
|
+
@_hash['expires_in'] = 'expires_in'
|
44
|
+
@_hash['scope'] = 'scope'
|
45
|
+
@_hash['expiry'] = 'expiry'
|
46
|
+
@_hash['refresh_token'] = 'refresh_token'
|
47
|
+
@_hash
|
48
|
+
end
|
49
|
+
|
50
|
+
# An array for optional fields
|
51
|
+
def self.optionals
|
52
|
+
%w[
|
53
|
+
expires_in
|
54
|
+
scope
|
55
|
+
expiry
|
56
|
+
refresh_token
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
# An array for nullable fields
|
61
|
+
def self.nullables
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize(access_token = nil,
|
66
|
+
token_type = nil,
|
67
|
+
expires_in = SKIP,
|
68
|
+
scope = SKIP,
|
69
|
+
expiry = SKIP,
|
70
|
+
refresh_token = SKIP,
|
71
|
+
additional_properties = {})
|
72
|
+
@access_token = access_token
|
73
|
+
@token_type = token_type
|
74
|
+
@expires_in = expires_in unless expires_in == SKIP
|
75
|
+
@scope = scope unless scope == SKIP
|
76
|
+
@expiry = expiry unless expiry == SKIP
|
77
|
+
@refresh_token = refresh_token unless refresh_token == SKIP
|
78
|
+
|
79
|
+
# Add additional model properties to the instance.
|
80
|
+
additional_properties.each do |_name, _value|
|
81
|
+
instance_variable_set("@#{_name}", _value)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Creates an instance of the object from a hash.
|
86
|
+
def self.from_hash(hash)
|
87
|
+
return nil unless hash
|
88
|
+
|
89
|
+
# Extract variables from the hash.
|
90
|
+
access_token = hash.key?('access_token') ? hash['access_token'] : nil
|
91
|
+
token_type = hash.key?('token_type') ? hash['token_type'] : nil
|
92
|
+
expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP
|
93
|
+
scope = hash.key?('scope') ? hash['scope'] : SKIP
|
94
|
+
expiry = hash.key?('expiry') ? hash['expiry'] : SKIP
|
95
|
+
refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP
|
96
|
+
|
97
|
+
# Clean out expected properties from Hash.
|
98
|
+
names.each_value { |k| hash.delete(k) }
|
99
|
+
|
100
|
+
# Create object from extracted values.
|
101
|
+
OAuthToken.new(access_token,
|
102
|
+
token_type,
|
103
|
+
expires_in,
|
104
|
+
scope,
|
105
|
+
expiry,
|
106
|
+
refresh_token,
|
107
|
+
hash)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# multi_auth_sample
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MultiAuthSample
|
7
|
+
# ServiceStatus Model.
|
8
|
+
class ServiceStatus < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# TODO: Write general description for this method
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :app
|
15
|
+
|
16
|
+
# TODO: Write general description for this method
|
17
|
+
# @return [String]
|
18
|
+
attr_accessor :moto
|
19
|
+
|
20
|
+
# TODO: Write general description for this method
|
21
|
+
# @return [Integer]
|
22
|
+
attr_accessor :notes
|
23
|
+
|
24
|
+
# TODO: Write general description for this method
|
25
|
+
# @return [Integer]
|
26
|
+
attr_accessor :users
|
27
|
+
|
28
|
+
# TODO: Write general description for this method
|
29
|
+
# @return [String]
|
30
|
+
attr_accessor :time
|
31
|
+
|
32
|
+
# TODO: Write general description for this method
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :os
|
35
|
+
|
36
|
+
# TODO: Write general description for this method
|
37
|
+
# @return [String]
|
38
|
+
attr_accessor :php_version
|
39
|
+
|
40
|
+
# TODO: Write general description for this method
|
41
|
+
# @return [String]
|
42
|
+
attr_accessor :status
|
43
|
+
|
44
|
+
# A mapping from model property names to API property names.
|
45
|
+
def self.names
|
46
|
+
@_hash = {} if @_hash.nil?
|
47
|
+
@_hash['app'] = 'app'
|
48
|
+
@_hash['moto'] = 'moto'
|
49
|
+
@_hash['notes'] = 'notes'
|
50
|
+
@_hash['users'] = 'users'
|
51
|
+
@_hash['time'] = 'time'
|
52
|
+
@_hash['os'] = 'os'
|
53
|
+
@_hash['php_version'] = 'php_version'
|
54
|
+
@_hash['status'] = 'status'
|
55
|
+
@_hash
|
56
|
+
end
|
57
|
+
|
58
|
+
# An array for optional fields
|
59
|
+
def self.optionals
|
60
|
+
%w[
|
61
|
+
app
|
62
|
+
moto
|
63
|
+
notes
|
64
|
+
users
|
65
|
+
time
|
66
|
+
os
|
67
|
+
php_version
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
# An array for nullable fields
|
72
|
+
def self.nullables
|
73
|
+
[]
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(status = nil,
|
77
|
+
app = SKIP,
|
78
|
+
moto = SKIP,
|
79
|
+
notes = SKIP,
|
80
|
+
users = SKIP,
|
81
|
+
time = SKIP,
|
82
|
+
os = SKIP,
|
83
|
+
php_version = SKIP,
|
84
|
+
additional_properties = {})
|
85
|
+
@app = app unless app == SKIP
|
86
|
+
@moto = moto unless moto == SKIP
|
87
|
+
@notes = notes unless notes == SKIP
|
88
|
+
@users = users unless users == SKIP
|
89
|
+
@time = time unless time == SKIP
|
90
|
+
@os = os unless os == SKIP
|
91
|
+
@php_version = php_version unless php_version == SKIP
|
92
|
+
@status = status
|
93
|
+
|
94
|
+
# Add additional model properties to the instance.
|
95
|
+
additional_properties.each do |_name, _value|
|
96
|
+
instance_variable_set("@#{_name}", _value)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Creates an instance of the object from a hash.
|
101
|
+
def self.from_hash(hash)
|
102
|
+
return nil unless hash
|
103
|
+
|
104
|
+
# Extract variables from the hash.
|
105
|
+
status = hash.key?('status') ? hash['status'] : nil
|
106
|
+
app = hash.key?('app') ? hash['app'] : SKIP
|
107
|
+
moto = hash.key?('moto') ? hash['moto'] : SKIP
|
108
|
+
notes = hash.key?('notes') ? hash['notes'] : SKIP
|
109
|
+
users = hash.key?('users') ? hash['users'] : SKIP
|
110
|
+
time = hash.key?('time') ? hash['time'] : SKIP
|
111
|
+
os = hash.key?('os') ? hash['os'] : SKIP
|
112
|
+
php_version = hash.key?('php_version') ? hash['php_version'] : SKIP
|
113
|
+
|
114
|
+
# Clean out expected properties from Hash.
|
115
|
+
names.each_value { |k| hash.delete(k) }
|
116
|
+
|
117
|
+
# Create object from extracted values.
|
118
|
+
ServiceStatus.new(status,
|
119
|
+
app,
|
120
|
+
moto,
|
121
|
+
notes,
|
122
|
+
users,
|
123
|
+
time,
|
124
|
+
os,
|
125
|
+
php_version,
|
126
|
+
hash)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|