apimatic-tql-sdk 0.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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +210 -0
  4. data/bin/console +15 -0
  5. data/lib/tql_otr_factoring_data_exchange/api_helper.rb +10 -0
  6. data/lib/tql_otr_factoring_data_exchange/apis/assignments_api.rb +45 -0
  7. data/lib/tql_otr_factoring_data_exchange/apis/base_api.rb +67 -0
  8. data/lib/tql_otr_factoring_data_exchange/apis/documents_api.rb +82 -0
  9. data/lib/tql_otr_factoring_data_exchange/apis/invoices_api.rb +114 -0
  10. data/lib/tql_otr_factoring_data_exchange/apis/loads_api.rb +68 -0
  11. data/lib/tql_otr_factoring_data_exchange/apis/oauth_authorization_api.rb +44 -0
  12. data/lib/tql_otr_factoring_data_exchange/client.rb +104 -0
  13. data/lib/tql_otr_factoring_data_exchange/configuration.rb +164 -0
  14. data/lib/tql_otr_factoring_data_exchange/exceptions/api_exception.rb +21 -0
  15. data/lib/tql_otr_factoring_data_exchange/exceptions/oauth_provider_exception.rb +64 -0
  16. data/lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb +58 -0
  17. data/lib/tql_otr_factoring_data_exchange/http/api_response.rb +19 -0
  18. data/lib/tql_otr_factoring_data_exchange/http/auth/oauth_2.rb +156 -0
  19. data/lib/tql_otr_factoring_data_exchange/http/http_call_back.rb +10 -0
  20. data/lib/tql_otr_factoring_data_exchange/http/http_method_enum.rb +10 -0
  21. data/lib/tql_otr_factoring_data_exchange/http/http_request.rb +10 -0
  22. data/lib/tql_otr_factoring_data_exchange/http/http_response.rb +10 -0
  23. data/lib/tql_otr_factoring_data_exchange/http/proxy_settings.rb +22 -0
  24. data/lib/tql_otr_factoring_data_exchange/logging/configuration/api_logging_configuration.rb +186 -0
  25. data/lib/tql_otr_factoring_data_exchange/logging/sdk_logger.rb +17 -0
  26. data/lib/tql_otr_factoring_data_exchange/models/assignment_request.rb +140 -0
  27. data/lib/tql_otr_factoring_data_exchange/models/assignment_response.rb +126 -0
  28. data/lib/tql_otr_factoring_data_exchange/models/assignment_status.rb +36 -0
  29. data/lib/tql_otr_factoring_data_exchange/models/base64_document.rb +118 -0
  30. data/lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb +107 -0
  31. data/lib/tql_otr_factoring_data_exchange/models/base_model.rb +110 -0
  32. data/lib/tql_otr_factoring_data_exchange/models/carrier.rb +98 -0
  33. data/lib/tql_otr_factoring_data_exchange/models/carrier1.rb +98 -0
  34. data/lib/tql_otr_factoring_data_exchange/models/carrier2.rb +98 -0
  35. data/lib/tql_otr_factoring_data_exchange/models/carrier_input.rb +123 -0
  36. data/lib/tql_otr_factoring_data_exchange/models/carrier_input1.rb +123 -0
  37. data/lib/tql_otr_factoring_data_exchange/models/charge_code.rb +126 -0
  38. data/lib/tql_otr_factoring_data_exchange/models/charge_code_origin.rb +49 -0
  39. data/lib/tql_otr_factoring_data_exchange/models/charge_input.rb +146 -0
  40. data/lib/tql_otr_factoring_data_exchange/models/document.rb +86 -0
  41. data/lib/tql_otr_factoring_data_exchange/models/document_type.rb +288 -0
  42. data/lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb +111 -0
  43. data/lib/tql_otr_factoring_data_exchange/models/document_upload_response.rb +137 -0
  44. data/lib/tql_otr_factoring_data_exchange/models/exception_severity.rb +40 -0
  45. data/lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb +117 -0
  46. data/lib/tql_otr_factoring_data_exchange/models/invoice.rb +223 -0
  47. data/lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb +136 -0
  48. data/lib/tql_otr_factoring_data_exchange/models/invoice_item_input.rb +165 -0
  49. data/lib/tql_otr_factoring_data_exchange/models/invoice_search_request.rb +242 -0
  50. data/lib/tql_otr_factoring_data_exchange/models/invoice_search_response.rb +124 -0
  51. data/lib/tql_otr_factoring_data_exchange/models/invoice_status.rb +74 -0
  52. data/lib/tql_otr_factoring_data_exchange/models/invoice_status_response.rb +193 -0
  53. data/lib/tql_otr_factoring_data_exchange/models/invoice_type.rb +50 -0
  54. data/lib/tql_otr_factoring_data_exchange/models/load.rb +110 -0
  55. data/lib/tql_otr_factoring_data_exchange/models/load_detail.rb +140 -0
  56. data/lib/tql_otr_factoring_data_exchange/models/load_search_request.rb +205 -0
  57. data/lib/tql_otr_factoring_data_exchange/models/load_search_response.rb +124 -0
  58. data/lib/tql_otr_factoring_data_exchange/models/load_status.rb +56 -0
  59. data/lib/tql_otr_factoring_data_exchange/models/location.rb +149 -0
  60. data/lib/tql_otr_factoring_data_exchange/models/oauth_provider_error.rb +62 -0
  61. data/lib/tql_otr_factoring_data_exchange/models/oauth_scope.rb +36 -0
  62. data/lib/tql_otr_factoring_data_exchange/models/oauth_token.rb +96 -0
  63. data/lib/tql_otr_factoring_data_exchange/models/payment.rb +108 -0
  64. data/lib/tql_otr_factoring_data_exchange/models/problem_details.rb +96 -0
  65. data/lib/tql_otr_factoring_data_exchange/models/reference_number_input.rb +109 -0
  66. data/lib/tql_otr_factoring_data_exchange/models/reference_type.rb +90 -0
  67. data/lib/tql_otr_factoring_data_exchange/models/status.rb +44 -0
  68. data/lib/tql_otr_factoring_data_exchange/models/stop_input.rb +121 -0
  69. data/lib/tql_otr_factoring_data_exchange/models/stop_type.rb +62 -0
  70. data/lib/tql_otr_factoring_data_exchange/models/submit_invoice_request.rb +326 -0
  71. data/lib/tql_otr_factoring_data_exchange/models/submit_invoice_response.rb +107 -0
  72. data/lib/tql_otr_factoring_data_exchange/models/weight_unit.rb +36 -0
  73. data/lib/tql_otr_factoring_data_exchange/utilities/date_time_helper.rb +11 -0
  74. data/lib/tql_otr_factoring_data_exchange/utilities/file_wrapper.rb +28 -0
  75. data/lib/tql_otr_factoring_data_exchange/utilities/union_type_lookup.rb +29 -0
  76. data/lib/tql_otr_factoring_data_exchange.rb +107 -0
  77. metadata +160 -0
@@ -0,0 +1,44 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # OauthAuthorizationApi
8
+ class OauthAuthorizationApi < BaseApi
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 [ApiResponse] Complete http response with raw body and status code.
17
+ def request_token(authorization,
18
+ scope: nil,
19
+ _field_parameters: nil)
20
+ @api_call
21
+ .request(new_request_builder(HttpMethodEnum::POST,
22
+ '/oauth2/token',
23
+ Server::DEFAULT)
24
+ .form_param(new_parameter('client_credentials', key: 'grant_type'))
25
+ .header_param(new_parameter(authorization, key: 'Authorization')
26
+ .is_required(true))
27
+ .form_param(new_parameter(scope, key: 'scope'))
28
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
29
+ .header_param(new_parameter('application/json', key: 'accept'))
30
+ .additional_form_params(_field_parameters))
31
+ .response(new_response_handler
32
+ .deserializer(APIHelper.method(:custom_type_deserializer))
33
+ .deserialize_into(OauthToken.method(:from_hash))
34
+ .is_api_response(true)
35
+ .local_error('400',
36
+ 'OAuth 2 provider returned an error.',
37
+ OauthProviderException)
38
+ .local_error('401',
39
+ 'OAuth 2 provider says client authentication failed.',
40
+ OauthProviderException))
41
+ .execute
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,104 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # tql_otr_factoring_data_exchange client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config, :auth_managers
11
+
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
16
+ # Returns the configured authentication bearerAuth instance.
17
+ def bearer_auth
18
+ @auth_managers['bearerAuth']
19
+ end
20
+
21
+ # Access to invoices controller.
22
+ # @return [InvoicesApi] Returns the controller instance.
23
+ def invoices
24
+ @invoices ||= InvoicesApi.new @global_configuration
25
+ end
26
+
27
+ # Access to documents controller.
28
+ # @return [DocumentsApi] Returns the controller instance.
29
+ def documents
30
+ @documents ||= DocumentsApi.new @global_configuration
31
+ end
32
+
33
+ # Access to assignments controller.
34
+ # @return [AssignmentsApi] Returns the controller instance.
35
+ def assignments
36
+ @assignments ||= AssignmentsApi.new @global_configuration
37
+ end
38
+
39
+ # Access to loads controller.
40
+ # @return [LoadsApi] Returns the controller instance.
41
+ def loads
42
+ @loads ||= LoadsApi.new @global_configuration
43
+ end
44
+
45
+ # Access to oauth_authorization controller.
46
+ # @return [OauthAuthorizationApi] Returns the controller instance.
47
+ def oauth_authorization
48
+ @oauth_authorization ||= OauthAuthorizationApi.new @global_configuration
49
+ end
50
+
51
+ def initialize(
52
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
53
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
54
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
55
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
56
+ logging_configuration: nil, environment: Environment::PRODUCTION,
57
+ client_credentials_auth_credentials: nil, config: nil
58
+ )
59
+ @config = if config.nil?
60
+ Configuration.new(
61
+ connection: connection, adapter: adapter, timeout: timeout,
62
+ max_retries: max_retries, retry_interval: retry_interval,
63
+ backoff_factor: backoff_factor,
64
+ retry_statuses: retry_statuses,
65
+ retry_methods: retry_methods, http_callback: http_callback,
66
+ proxy_settings: proxy_settings,
67
+ logging_configuration: logging_configuration,
68
+ environment: environment,
69
+ client_credentials_auth_credentials: client_credentials_auth_credentials
70
+ )
71
+ else
72
+ config
73
+ end
74
+ user_agent_params = BaseApi.user_agent_parameters
75
+
76
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
77
+ .base_uri_executor(@config.method(:get_base_uri))
78
+ .global_errors(BaseApi::GLOBAL_ERRORS)
79
+ .user_agent(BaseApi.user_agent,
80
+ agent_parameters: user_agent_params)
81
+
82
+ initialize_auth_managers(@global_configuration)
83
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
84
+ end
85
+
86
+ # Initializes the auth managers hash used for authenticating API calls.
87
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
88
+ def initialize_auth_managers(global_config)
89
+ @auth_managers = {}
90
+ http_client_config = global_config.client_configuration
91
+ %w[bearerAuth].each { |auth| @auth_managers[auth] = nil }
92
+ @auth_managers['bearerAuth'] = Oauth2.new(
93
+ http_client_config.client_credentials_auth_credentials, global_config
94
+ )
95
+ end
96
+
97
+ # Creates a client directly from environment variables.
98
+ def self.from_env(**overrides)
99
+ default_config = Configuration.build_default_config_from_env
100
+ new_config = default_config.clone_with(**overrides)
101
+ new(config: new_config)
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,164 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # PRODUCTION: Production
10
+ ENVIRONMENT = [
11
+ PRODUCTION = 'production'.freeze
12
+ ].freeze
13
+
14
+ # Converts a string or symbol into a valid Environment constant.
15
+ def self.from_value(value, default_value = PRODUCTION)
16
+ return default_value if value.nil?
17
+
18
+ default_value
19
+ end
20
+ end
21
+
22
+ # An enum for API servers.
23
+ class Server
24
+ SERVER = [
25
+ DEFAULT = 'default'.freeze
26
+ ].freeze
27
+
28
+ # Converts a string or symbol into a valid Server constant.
29
+ def self.from_value(value, default_value = DEFAULT)
30
+ return default_value if value.nil?
31
+
32
+ default_value
33
+ end
34
+ end
35
+
36
+ # All configuration including auth info and base URI for the API access
37
+ # are configured in this class.
38
+ class Configuration < CoreLibrary::HttpClientConfiguration
39
+ # The attribute readers for properties.
40
+ attr_reader :environment, :client_credentials_auth_credentials
41
+
42
+ class << self
43
+ attr_reader :environments
44
+ end
45
+
46
+ def initialize(
47
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
48
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
49
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
50
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
51
+ logging_configuration: nil, environment: Environment::PRODUCTION,
52
+ client_credentials_auth_credentials: nil
53
+ )
54
+ super connection: connection, adapter: adapter, timeout: timeout,
55
+ max_retries: max_retries, retry_interval: retry_interval,
56
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
57
+ retry_methods: retry_methods, http_callback: http_callback,
58
+ proxy_settings: proxy_settings,
59
+ logging_configuration: logging_configuration
60
+
61
+ # Current API environment
62
+ @environment = String(environment)
63
+
64
+ # The object holding OAuth 2 Client Credentials Grant credentials
65
+ @client_credentials_auth_credentials = client_credentials_auth_credentials
66
+
67
+ # Initializing OAuth 2 Client Credentials Grant credentials with the provided auth parameters
68
+ @client_credentials_auth_credentials = client_credentials_auth_credentials
69
+
70
+ # The Http Client to use for making requests.
71
+ set_http_client CoreLibrary::FaradayClient.new(self)
72
+ end
73
+
74
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
75
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
76
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
77
+ proxy_settings: nil, logging_configuration: nil,
78
+ environment: nil, client_credentials_auth_credentials: nil)
79
+ connection ||= self.connection
80
+ adapter ||= self.adapter
81
+ timeout ||= self.timeout
82
+ max_retries ||= self.max_retries
83
+ retry_interval ||= self.retry_interval
84
+ backoff_factor ||= self.backoff_factor
85
+ retry_statuses ||= self.retry_statuses
86
+ retry_methods ||= self.retry_methods
87
+ http_callback ||= self.http_callback
88
+ proxy_settings ||= self.proxy_settings
89
+ logging_configuration ||= self.logging_configuration
90
+ environment ||= self.environment
91
+ client_credentials_auth_credentials ||= self.client_credentials_auth_credentials
92
+
93
+ Configuration.new(
94
+ connection: connection, adapter: adapter, timeout: timeout,
95
+ max_retries: max_retries, retry_interval: retry_interval,
96
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
97
+ retry_methods: retry_methods, http_callback: http_callback,
98
+ proxy_settings: proxy_settings,
99
+ logging_configuration: logging_configuration, environment: environment,
100
+ client_credentials_auth_credentials: client_credentials_auth_credentials
101
+ )
102
+ end
103
+
104
+
105
+ # All the environments the SDK can run in.
106
+ ENVIRONMENTS = {
107
+ Environment::PRODUCTION => {
108
+ Server::DEFAULT => 'https://api.example.com'
109
+ }
110
+ }.freeze
111
+
112
+ # Generates the appropriate base URI for the environment and the server.
113
+ # @param [Configuration::Server] server The server enum for which the base URI is
114
+ # required.
115
+ # @return [String] The base URI.
116
+ def get_base_uri(server = Server::DEFAULT)
117
+ ENVIRONMENTS[environment][server].clone
118
+ end
119
+
120
+ # Builds a Configuration instance using environment variables.
121
+ def self.build_default_config_from_env
122
+ # === Core environment ===
123
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
124
+ timeout = (ENV['TIMEOUT'] || 30).to_f
125
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
126
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
127
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
128
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
129
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
130
+ .split(',')
131
+ .map(&:strip)
132
+ .map do |item|
133
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
134
+ end
135
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
136
+ .split(',')
137
+ .map(&:strip)
138
+ .map do |item|
139
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
140
+ end
141
+
142
+ # === Authentication credentials ===
143
+ client_credentials_auth_credentials = ClientCredentialsAuthCredentials.from_env
144
+
145
+ # === Proxy settings ===
146
+ proxy_settings = ProxySettings.from_env
147
+ # === Logging Configuration ===
148
+ logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
149
+
150
+ Configuration.new(
151
+ environment: environment,
152
+ timeout: timeout,
153
+ max_retries: max_retries,
154
+ retry_interval: retry_interval,
155
+ backoff_factor: backoff_factor,
156
+ retry_statuses: retry_statuses,
157
+ retry_methods: retry_methods,
158
+ client_credentials_auth_credentials: client_credentials_auth_credentials,
159
+ proxy_settings: proxy_settings,
160
+ logging_configuration: logging_configuration
161
+ )
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,21 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
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
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
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,58 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # [RFC 7807](https://datatracker.ietf.org/doc/html/rfc7807) Problem Details
8
+ # response returned for validation errors and other non-success outcomes.
9
+ class ProblemDetailsErrorException < APIException
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Short, human-readable summary of the problem type.
14
+ # @return [String]
15
+ attr_accessor :title
16
+
17
+ # HTTP status code.
18
+ # @return [Integer]
19
+ attr_accessor :status
20
+
21
+ # Detailed, human-readable explanation specific to this occurrence.
22
+ # @return [String]
23
+ attr_accessor :detail
24
+
25
+ # The constructor.
26
+ # @param [String] reason The reason for raising an exception.
27
+ # @param [HttpResponse] response The HttpReponse of the API call.
28
+ def initialize(reason, response)
29
+ super(reason, response)
30
+ hash = APIHelper.json_deserialize(@response.raw_body)
31
+ unbox(hash)
32
+ end
33
+
34
+ # Populates this object by extracting properties from a hash.
35
+ # @param [Hash] hash The deserialized response sent by the server in the
36
+ # response body.
37
+ def unbox(hash)
38
+ return nil unless hash
39
+
40
+ @title = hash.key?('title') ? hash['title'] : SKIP
41
+ @status = hash.key?('status') ? hash['status'] : SKIP
42
+ @detail = hash.key?('detail') ? hash['detail'] : SKIP
43
+ end
44
+
45
+ # Provides a human-readable string representation of the object.
46
+ def to_s
47
+ class_name = self.class.name.split('::').last
48
+ "<#{class_name} title: #{@title}, status: #{@status}, detail: #{@detail}>"
49
+ end
50
+
51
+ # Provides a debugging-friendly string with detailed object information.
52
+ def inspect
53
+ class_name = self.class.name.split('::').last
54
+ "<#{class_name} title: #{@title.inspect}, status: #{@status.inspect}, detail:"\
55
+ " #{@detail.inspect}>"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
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,156 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
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
+ 'ClientCredentialsAuth: OAuthToken is undefined or expired.'
14
+ end
15
+
16
+ # Initialization constructor.
17
+ def initialize(client_credentials_auth_credentials, config)
18
+ @_oauth_client_id = client_credentials_auth_credentials.oauth_client_id unless
19
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_client_id.nil?
20
+ @_oauth_client_secret = client_credentials_auth_credentials.oauth_client_secret unless
21
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_client_secret.nil?
22
+ @_oauth_token = client_credentials_auth_credentials.oauth_token unless
23
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_token.nil?
24
+ @_oauth_scopes = client_credentials_auth_credentials.oauth_scopes unless
25
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_scopes.nil?
26
+ @_oauth_clock_skew = client_credentials_auth_credentials.oauth_clock_skew unless
27
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_clock_skew.nil?
28
+ @_oauth_token_provider = client_credentials_auth_credentials.oauth_token_provider unless
29
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_token_provider.nil?
30
+ @_oauth_on_token_update = client_credentials_auth_credentials.oauth_on_token_update unless
31
+ client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.oauth_on_token_update.nil?
32
+ @_o_auth_api = OauthAuthorizationApi.new(config)
33
+ super({})
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 = get_token_from_provider
40
+ @_oauth_token.is_a?(OAuthToken) && !token_expired?(@_oauth_token)
41
+ end
42
+
43
+ # Builds the basic auth header for endpoints in the OAuth Authorization Controller.
44
+ # @return [String] The value of the Authentication header.
45
+ def build_basic_auth_header
46
+ "Basic #{AuthHelper.get_base64_encoded_value(@_oauth_client_id, @_oauth_client_secret)}"
47
+ end
48
+
49
+ # Fetches the token.
50
+ # @param [Hash] additional_params Any additional form parameters.
51
+ # @return [OAuthToken] The oAuth token instance.
52
+ def fetch_token(additional_params: nil)
53
+ token = @_o_auth_api.request_token(
54
+ build_basic_auth_header,
55
+ scope: !@_oauth_scopes.nil? ? Array(@_oauth_scopes).compact.join(' ') : @_oauth_scopes,
56
+ _field_parameters: additional_params
57
+ ).data
58
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
59
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
60
+ end
61
+ token
62
+ end
63
+
64
+ # Checks if OAuth token has expired.
65
+ # @param [OAuthToken] token The oAuth token instance.
66
+ # @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
67
+ def token_expired?(token)
68
+ token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry, @_oauth_clock_skew)
69
+ end
70
+
71
+ def apply(http_request)
72
+ auth_params = { 'Authorization' => "Bearer #{@_oauth_token.access_token}" }
73
+ AuthHelper.apply(auth_params, http_request.method(:add_header))
74
+ end
75
+
76
+ private
77
+
78
+ # This provides the OAuth Token from either the user configured callbacks or from default provider.
79
+ # @return [OAuthToken] The fetched oauth token.
80
+ def get_token_from_provider
81
+ return @_oauth_token if @_oauth_token && !token_expired?(@_oauth_token)
82
+
83
+ if @_o_auth_token_provider
84
+ o_auth_token = @_o_auth_token_provider.call(@_oauth_token, self)
85
+ @_o_auth_on_token_update&.call(o_auth_token)
86
+ return o_auth_token
87
+ end
88
+ begin
89
+ o_auth_token = fetch_token
90
+ @_o_auth_on_token_update&.call(o_auth_token)
91
+ o_auth_token
92
+ rescue ApiException
93
+ @_o_auth_token
94
+ end
95
+ end
96
+ end
97
+
98
+ # Data class for ClientCredentialsAuthCredentials.
99
+ class ClientCredentialsAuthCredentials
100
+ attr_reader :oauth_client_id, :oauth_client_secret, :oauth_token,
101
+ :oauth_scopes, :oauth_token_provider, :oauth_on_token_update,
102
+ :oauth_clock_skew
103
+
104
+ def initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil,
105
+ oauth_scopes: nil, oauth_token_provider: nil,
106
+ oauth_on_token_update: nil, oauth_clock_skew: 0)
107
+ raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
108
+ raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil?
109
+
110
+ @oauth_client_id = oauth_client_id
111
+ @oauth_client_secret = oauth_client_secret
112
+ @oauth_token = oauth_token
113
+ @oauth_scopes = oauth_scopes
114
+ @oauth_token_provider = oauth_token_provider
115
+ @oauth_on_token_update = oauth_on_token_update
116
+ @oauth_clock_skew = oauth_clock_skew
117
+ end
118
+
119
+ def self.from_env
120
+ oauth_client_id = ENV['OAUTH_CLIENT_ID']
121
+ oauth_client_secret = ENV['OAUTH_CLIENT_SECRET']
122
+ oauth_scopes = ENV['OAUTH_SCOPES']
123
+ oauth_clock_skew = ENV['OAUTH_CLOCK_SKEW']
124
+ all_nil = [
125
+ oauth_client_id,
126
+ oauth_client_secret
127
+ ].all?(&:nil?)
128
+ return nil if all_nil
129
+
130
+ new(oauth_client_id: oauth_client_id,
131
+ oauth_client_secret: oauth_client_secret, oauth_scopes: oauth_scopes,
132
+ oauth_clock_skew: oauth_clock_skew)
133
+ end
134
+
135
+ def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
136
+ oauth_token: nil, oauth_scopes: nil,
137
+ oauth_token_provider: nil, oauth_on_token_update: nil,
138
+ oauth_clock_skew: nil)
139
+ oauth_client_id ||= self.oauth_client_id
140
+ oauth_client_secret ||= self.oauth_client_secret
141
+ oauth_token ||= self.oauth_token
142
+ oauth_scopes ||= self.oauth_scopes
143
+ oauth_token_provider ||= self.oauth_token_provider
144
+ oauth_on_token_update ||= self.oauth_on_token_update
145
+ oauth_clock_skew ||= self.oauth_clock_skew
146
+
147
+ ClientCredentialsAuthCredentials.new(
148
+ oauth_client_id: oauth_client_id,
149
+ oauth_client_secret: oauth_client_secret, oauth_token: oauth_token,
150
+ oauth_scopes: oauth_scopes, oauth_token_provider: oauth_token_provider,
151
+ oauth_on_token_update: oauth_on_token_update,
152
+ oauth_clock_skew: oauth_clock_skew
153
+ )
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,10 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack < CoreLibrary::HttpCallback
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end