mannual-calculator 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +105 -0
- data/lib/manualpractice_sample_api/api_helper.rb +10 -0
- data/lib/manualpractice_sample_api/apis/addnumbermath_api.rb +32 -0
- data/lib/manualpractice_sample_api/apis/api.rb +25 -0
- data/lib/manualpractice_sample_api/apis/base_api.rb +67 -0
- data/lib/manualpractice_sample_api/apis/createsquarerootmath_api.rb +28 -0
- data/lib/manualpractice_sample_api/apis/multipliednumbermath_api.rb +32 -0
- data/lib/manualpractice_sample_api/apis/oauth_authorization_api.rb +87 -0
- data/lib/manualpractice_sample_api/apis/subtractnumbermath_api.rb +34 -0
- data/lib/manualpractice_sample_api/apis/updatenumbermath_api.rb +31 -0
- data/lib/manualpractice_sample_api/client.rb +104 -0
- data/lib/manualpractice_sample_api/configuration.rb +104 -0
- data/lib/manualpractice_sample_api/exceptions/api_exception.rb +21 -0
- data/lib/manualpractice_sample_api/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/manualpractice_sample_api/http/api_response.rb +19 -0
- data/lib/manualpractice_sample_api/http/auth/oauth_2.rb +145 -0
- data/lib/manualpractice_sample_api/http/http_call_back.rb +10 -0
- data/lib/manualpractice_sample_api/http/http_method_enum.rb +10 -0
- data/lib/manualpractice_sample_api/http/http_request.rb +10 -0
- data/lib/manualpractice_sample_api/http/http_response.rb +10 -0
- data/lib/manualpractice_sample_api/logging/configuration/api_logging_configuration.rb +114 -0
- data/lib/manualpractice_sample_api/logging/sdk_logger.rb +17 -0
- data/lib/manualpractice_sample_api/models/addnumbers_response.rb +75 -0
- data/lib/manualpractice_sample_api/models/base_model.rb +110 -0
- data/lib/manualpractice_sample_api/models/complexvalueset.rb +23 -0
- data/lib/manualpractice_sample_api/models/createsquareroot_response.rb +75 -0
- data/lib/manualpractice_sample_api/models/getcode_response.rb +75 -0
- data/lib/manualpractice_sample_api/models/multiplnumbers_response.rb +75 -0
- data/lib/manualpractice_sample_api/models/oauth_provider_error.rb +45 -0
- data/lib/manualpractice_sample_api/models/oauth_scope.rb +23 -0
- data/lib/manualpractice_sample_api/models/oauth_token.rb +96 -0
- data/lib/manualpractice_sample_api/models/subtractnumbers_response.rb +75 -0
- data/lib/manualpractice_sample_api/models/updatenumber_response.rb +75 -0
- data/lib/manualpractice_sample_api/utilities/date_time_helper.rb +11 -0
- data/lib/manualpractice_sample_api/utilities/file_wrapper.rb +28 -0
- data/lib/manualpractice_sample_api.rb +61 -0
- metadata +121 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# An enum for SDK environments.
|
8
|
+
class Environment
|
9
|
+
ENVIRONMENT = [
|
10
|
+
PRODUCTION = 'production'.freeze
|
11
|
+
].freeze
|
12
|
+
end
|
13
|
+
|
14
|
+
# An enum for API servers.
|
15
|
+
class Server
|
16
|
+
SERVER = [
|
17
|
+
DEFAULT = 'default'.freeze,
|
18
|
+
AUTH = 'auth'.freeze
|
19
|
+
].freeze
|
20
|
+
end
|
21
|
+
|
22
|
+
# All configuration including auth info and base URI for the API access
|
23
|
+
# are configured in this class.
|
24
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
25
|
+
# The attribute readers for properties.
|
26
|
+
attr_reader :environment, :authorization_code_auth_credentials
|
27
|
+
|
28
|
+
class << self
|
29
|
+
attr_reader :environments
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(
|
33
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
34
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
35
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
36
|
+
retry_methods: %i[get put], http_callback: nil,
|
37
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
38
|
+
authorization_code_auth_credentials: nil
|
39
|
+
)
|
40
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
41
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
42
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
43
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
44
|
+
logging_configuration: logging_configuration
|
45
|
+
|
46
|
+
# Current API environment
|
47
|
+
@environment = String(environment)
|
48
|
+
|
49
|
+
# The object holding OAuth 2 Authorization Code Grant credentials
|
50
|
+
@authorization_code_auth_credentials = authorization_code_auth_credentials
|
51
|
+
|
52
|
+
# Initializing OAuth 2 Authorization Code Grant credentials with the provided auth parameters
|
53
|
+
@authorization_code_auth_credentials = authorization_code_auth_credentials
|
54
|
+
|
55
|
+
# The Http Client to use for making requests.
|
56
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
60
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
61
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
62
|
+
logging_configuration: nil, environment: nil,
|
63
|
+
authorization_code_auth_credentials: nil)
|
64
|
+
connection ||= self.connection
|
65
|
+
adapter ||= self.adapter
|
66
|
+
timeout ||= self.timeout
|
67
|
+
max_retries ||= self.max_retries
|
68
|
+
retry_interval ||= self.retry_interval
|
69
|
+
backoff_factor ||= self.backoff_factor
|
70
|
+
retry_statuses ||= self.retry_statuses
|
71
|
+
retry_methods ||= self.retry_methods
|
72
|
+
http_callback ||= self.http_callback
|
73
|
+
logging_configuration ||= self.logging_configuration
|
74
|
+
environment ||= self.environment
|
75
|
+
authorization_code_auth_credentials ||= self.authorization_code_auth_credentials
|
76
|
+
|
77
|
+
Configuration.new(
|
78
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
79
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
80
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
81
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
82
|
+
logging_configuration: logging_configuration, environment: environment,
|
83
|
+
authorization_code_auth_credentials: authorization_code_auth_credentials
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# All the environments the SDK can run in.
|
89
|
+
ENVIRONMENTS = {
|
90
|
+
Environment::PRODUCTION => {
|
91
|
+
Server::DEFAULT => 'https://pratcicetask.free.beeceptor.com',
|
92
|
+
Server::AUTH => 'http://localhost:3000/oauth2/auth-server'
|
93
|
+
}
|
94
|
+
}.freeze
|
95
|
+
|
96
|
+
# Generates the appropriate base URI for the environment and the server.
|
97
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
98
|
+
# required.
|
99
|
+
# @return [String] The base URI.
|
100
|
+
def get_base_uri(server = Server::DEFAULT)
|
101
|
+
ENVIRONMENTS[environment][server].clone
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
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
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
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 [OauthProviderError]
|
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,19 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# Http response received.
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
9
|
+
# The constructor
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
11
|
+
# @param [Object] data The data field specified for the response.
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
13
|
+
def initialize(http_response,
|
14
|
+
data: nil,
|
15
|
+
errors: nil)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
8
|
+
class Oauth2 < 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
|
+
'AuthorizationCodeAuth: OAuthToken is undefined or expired.'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Initialization constructor.
|
17
|
+
def initialize(authorization_code_auth_credentials, config)
|
18
|
+
auth_params = {}
|
19
|
+
@_oauth_client_id = authorization_code_auth_credentials.oauth_client_id unless
|
20
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.oauth_client_id.nil?
|
21
|
+
@_oauth_client_secret = authorization_code_auth_credentials.oauth_client_secret unless
|
22
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.oauth_client_secret.nil?
|
23
|
+
@_oauth_redirect_uri = authorization_code_auth_credentials.oauth_redirect_uri unless
|
24
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.oauth_redirect_uri.nil?
|
25
|
+
@_oauth_token = authorization_code_auth_credentials.oauth_token unless
|
26
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.oauth_token.nil?
|
27
|
+
@_oauth_scopes = authorization_code_auth_credentials.oauth_scopes unless
|
28
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.oauth_scopes.nil?
|
29
|
+
@_config = config
|
30
|
+
@_o_auth_api = OauthAuthorizationApi.new(config)
|
31
|
+
auth_params[:Authorization] = "Bearer #{@_oauth_token.access_token}" unless @_oauth_token.nil?
|
32
|
+
|
33
|
+
super auth_params
|
34
|
+
end
|
35
|
+
|
36
|
+
# Validates the oAuth token.
|
37
|
+
# @return [Boolean] true if the token is present and not expired.
|
38
|
+
def valid
|
39
|
+
!@_oauth_token.nil? && !token_expired?(@_oauth_token)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Builds and returns an authorization URL.
|
43
|
+
# The user is expected to obtain an authorization code from this URL and then call the
|
44
|
+
# fetch token function with that authorization code.
|
45
|
+
# @param [String] state An opaque state string.
|
46
|
+
# @param [Hash] additional_params Any additional query parameters to be added to the URL.
|
47
|
+
# @return [String] The authorization URL.
|
48
|
+
def get_authorization_url(state: nil, additional_params: nil)
|
49
|
+
auth_url = @_config.get_base_uri_executor.call(Server::AUTH)
|
50
|
+
auth_url += '/oauth/authorize'
|
51
|
+
query_params = {
|
52
|
+
'response_type' => 'code',
|
53
|
+
'client_id' => @_oauth_client_id,
|
54
|
+
'redirect_uri' => @_oauth_redirect_uri
|
55
|
+
}
|
56
|
+
query_params['scope'] = Array(@_o_auth_scopes).compact.join(' ') if @_o_auth_scopes
|
57
|
+
query_params['state'] = state if state
|
58
|
+
query_params.merge!(additional_params) if additional_params
|
59
|
+
auth_url = APIHelper.append_url_with_query_parameters(auth_url,
|
60
|
+
query_params)
|
61
|
+
APIHelper.clean_url(auth_url)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
65
|
+
# @return [String] The value of the Authentication header.
|
66
|
+
def build_basic_auth_header
|
67
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_oauth_client_id, @_oauth_client_secret)}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Fetches the token.
|
71
|
+
# @param [String] auth_code The authentication code.
|
72
|
+
# @param [Hash] additional_params Any additional form parameters.
|
73
|
+
# @return [OAuthToken] The oAuth token instance.
|
74
|
+
def fetch_token(auth_code, additional_params: nil)
|
75
|
+
token = @_o_auth_api.request_token(
|
76
|
+
build_basic_auth_header,
|
77
|
+
auth_code,
|
78
|
+
@_oauth_redirect_uri,
|
79
|
+
_field_parameters: additional_params
|
80
|
+
).data
|
81
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
82
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
83
|
+
end
|
84
|
+
token
|
85
|
+
end
|
86
|
+
|
87
|
+
# Checks if OAuth token has expired.
|
88
|
+
# @param [OAuthToken] token The oAuth token instance.
|
89
|
+
# @return [Boolean] true if the token is present and not expired.
|
90
|
+
def token_expired?(token)
|
91
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Refreshes OAuth token.
|
95
|
+
# @param [Hash] additional_params Any additional form parameters.
|
96
|
+
# @return [OAuthToken] The oAuth token instance.
|
97
|
+
def refresh_token(additional_params: nil)
|
98
|
+
token = @_o_auth_api.refresh_token(
|
99
|
+
build_basic_auth_header,
|
100
|
+
@_oauth_token.refresh_token,
|
101
|
+
scope: !@_oauth_scopes.nil? ? Array(@_oauth_scopes).compact.join(' ') : nil,
|
102
|
+
_field_parameters: additional_params
|
103
|
+
).data
|
104
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
105
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
106
|
+
end
|
107
|
+
token
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Data class for AuthorizationCodeAuthCredentials.
|
112
|
+
class AuthorizationCodeAuthCredentials
|
113
|
+
attr_reader :oauth_client_id, :oauth_client_secret, :oauth_redirect_uri,
|
114
|
+
:oauth_token, :oauth_scopes
|
115
|
+
|
116
|
+
def initialize(oauth_client_id:, oauth_client_secret:, oauth_redirect_uri:,
|
117
|
+
oauth_token: nil, oauth_scopes: nil)
|
118
|
+
raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
|
119
|
+
raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil?
|
120
|
+
raise ArgumentError, 'oauth_redirect_uri cannot be nil' if oauth_redirect_uri.nil?
|
121
|
+
|
122
|
+
@oauth_client_id = oauth_client_id
|
123
|
+
@oauth_client_secret = oauth_client_secret
|
124
|
+
@oauth_redirect_uri = oauth_redirect_uri
|
125
|
+
@oauth_token = oauth_token
|
126
|
+
@oauth_scopes = oauth_scopes
|
127
|
+
end
|
128
|
+
|
129
|
+
def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
|
130
|
+
oauth_redirect_uri: nil, oauth_token: nil, oauth_scopes: nil)
|
131
|
+
oauth_client_id ||= self.oauth_client_id
|
132
|
+
oauth_client_secret ||= self.oauth_client_secret
|
133
|
+
oauth_redirect_uri ||= self.oauth_redirect_uri
|
134
|
+
oauth_token ||= self.oauth_token
|
135
|
+
oauth_scopes ||= self.oauth_scopes
|
136
|
+
|
137
|
+
AuthorizationCodeAuthCredentials.new(
|
138
|
+
oauth_client_id: oauth_client_id,
|
139
|
+
oauth_client_secret: oauth_client_secret,
|
140
|
+
oauth_redirect_uri: oauth_redirect_uri, oauth_token: oauth_token,
|
141
|
+
oauth_scopes: oauth_scopes
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# Initializes a new instance of RequestLoggingConfiguration.
|
8
|
+
class RequestLoggingConfiguration < CoreLibrary::ApiRequestLoggingConfiguration
|
9
|
+
# @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
|
10
|
+
# @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
|
11
|
+
# @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
|
12
|
+
# @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
|
13
|
+
# @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
|
14
|
+
# Default is an empty array.
|
15
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
16
|
+
headers_to_exclude: nil, headers_to_unmask: nil,
|
17
|
+
include_query_in_path: false)
|
18
|
+
super(
|
19
|
+
log_body,
|
20
|
+
log_headers,
|
21
|
+
headers_to_exclude,
|
22
|
+
headers_to_include,
|
23
|
+
headers_to_unmask,
|
24
|
+
include_query_in_path
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
29
|
+
headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
|
30
|
+
log_body ||= self.log_body
|
31
|
+
log_headers ||= self.log_headers
|
32
|
+
headers_to_include ||= self.headers_to_include
|
33
|
+
headers_to_exclude ||= self.headers_to_exclude
|
34
|
+
headers_to_unmask ||= self.headers_to_unmask
|
35
|
+
include_query_in_path ||= self.include_query_in_path
|
36
|
+
|
37
|
+
RequestLoggingConfiguration.class.new(log_body: log_body, log_headers: log_headers,
|
38
|
+
headers_to_include: headers_to_include,
|
39
|
+
headers_to_exclude: headers_to_exclude,
|
40
|
+
headers_to_unmask: headers_to_unmask,
|
41
|
+
include_query_in_path: include_query_in_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes a new instance of ResponseLoggingConfiguration.
|
46
|
+
class ResponseLoggingConfiguration < CoreLibrary::ApiResponseLoggingConfiguration
|
47
|
+
# @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
|
48
|
+
# @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
|
49
|
+
# @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
|
50
|
+
# @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
|
51
|
+
# @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
|
52
|
+
# Default is an empty array.
|
53
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
54
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
55
|
+
super(
|
56
|
+
log_body,
|
57
|
+
log_headers,
|
58
|
+
headers_to_exclude,
|
59
|
+
headers_to_include,
|
60
|
+
headers_to_unmask
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
65
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
66
|
+
log_body ||= self.log_body
|
67
|
+
log_headers ||= self.log_headers
|
68
|
+
headers_to_include ||= self.headers_to_include
|
69
|
+
headers_to_exclude ||= self.headers_to_exclude
|
70
|
+
headers_to_unmask ||= self.headers_to_unmask
|
71
|
+
|
72
|
+
ResponseLoggingConfiguration.new(log_body: log_body, log_headers: log_headers,
|
73
|
+
headers_to_include: headers_to_include,
|
74
|
+
headers_to_exclude: headers_to_exclude,
|
75
|
+
headers_to_unmask: headers_to_unmask)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Initializes a new instance of LoggingConfiguration.
|
80
|
+
class LoggingConfiguration < CoreLibrary::ApiLoggingConfiguration
|
81
|
+
# @param logger [LoggerInterface] The logger to use for logging messages.
|
82
|
+
# @param log_level [LogLevel] The log level to determine which messages should be logged.
|
83
|
+
# @param request_logging_config [RequestLoggingConfiguration] Options for logging HTTP requests.
|
84
|
+
# @param response_logging_config [ResponseLoggingConfiguration] Options for logging HTTP responses.
|
85
|
+
# @param mask_sensitive_headers [Boolean] Indicates whether sensitive headers should be masked in logged messages.
|
86
|
+
def initialize(logger: nil, log_level: nil, mask_sensitive_headers: true,
|
87
|
+
request_logging_config: nil,
|
88
|
+
response_logging_config: nil)
|
89
|
+
request_logging_config ||= RequestLoggingConfiguration.new
|
90
|
+
response_logging_config ||= ResponseLoggingConfiguration.new
|
91
|
+
super(
|
92
|
+
logger,
|
93
|
+
log_level,
|
94
|
+
request_logging_config,
|
95
|
+
response_logging_config,
|
96
|
+
mask_sensitive_headers
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def clone_with(logger: nil, log_level: nil, mask_sensitive_headers: nil,
|
101
|
+
request_logging_config: nil, response_logging_config: nil)
|
102
|
+
logger ||= self.logger
|
103
|
+
log_level ||= self.log_level
|
104
|
+
mask_sensitive_headers = self.mask_sensitive_headers ||= mask_sensitive_headers
|
105
|
+
request_logging_config ||= self.request_logging_config.clone
|
106
|
+
response_logging_config ||= self.response_logging_config.clone
|
107
|
+
|
108
|
+
LoggingConfiguration.new(logger: logger, log_level: log_level,
|
109
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
110
|
+
request_logging_config: request_logging_config,
|
111
|
+
response_logging_config: response_logging_config)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# Represents the generic logger facade
|
8
|
+
class AbstractLogger < Logger
|
9
|
+
# Logs a message with a specified log level and additional parameters.
|
10
|
+
# @param level [Symbol] The log level of the message.
|
11
|
+
# @param message [String] The message to log.
|
12
|
+
# @param params [Hash] Additional parameters to include in the log message.
|
13
|
+
def log(level, message, params)
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# manualpractice_sample_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ManualpracticeSampleApi
|
7
|
+
# AddnumbersResponse Model.
|
8
|
+
class AddnumbersResponse < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The sum of the two numbers
|
13
|
+
# @return [Float]
|
14
|
+
attr_accessor :result
|
15
|
+
|
16
|
+
# A mapping from model property names to API property names.
|
17
|
+
def self.names
|
18
|
+
@_hash = {} if @_hash.nil?
|
19
|
+
@_hash['result'] = 'result'
|
20
|
+
@_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# An array for optional fields
|
24
|
+
def self.optionals
|
25
|
+
%w[
|
26
|
+
result
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
# An array for nullable fields
|
31
|
+
def self.nullables
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(result: SKIP, additional_properties: nil)
|
36
|
+
# Add additional model properties to the instance
|
37
|
+
additional_properties = {} if additional_properties.nil?
|
38
|
+
|
39
|
+
@result = result unless result == SKIP
|
40
|
+
@additional_properties = additional_properties
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates an instance of the object from a hash.
|
44
|
+
def self.from_hash(hash)
|
45
|
+
return nil unless hash
|
46
|
+
|
47
|
+
# Extract variables from the hash.
|
48
|
+
result = hash.key?('result') ? hash['result'] : SKIP
|
49
|
+
|
50
|
+
# Create a new hash for additional properties, removing known properties.
|
51
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
52
|
+
|
53
|
+
additional_properties = APIHelper.get_additional_properties(
|
54
|
+
new_hash, proc { |value| value }
|
55
|
+
)
|
56
|
+
|
57
|
+
# Create object from extracted values.
|
58
|
+
AddnumbersResponse.new(result: result,
|
59
|
+
additional_properties: additional_properties)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Provides a human-readable string representation of the object.
|
63
|
+
def to_s
|
64
|
+
class_name = self.class.name.split('::').last
|
65
|
+
"<#{class_name} result: #{@result}, additional_properties: #{@additional_properties}>"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Provides a debugging-friendly string with detailed object information.
|
69
|
+
def inspect
|
70
|
+
class_name = self.class.name.split('::').last
|
71
|
+
"<#{class_name} result: #{@result.inspect}, additional_properties:"\
|
72
|
+
" #{@additional_properties}>"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|