cli-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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8f27f43739f415e48731f035f8d27c670f6b0a12f60b1c0d119fe0d4dc158bbd
4
+ data.tar.gz: 004000f8a1f95049ad32abfae24aa9dde33753f551f11decea20a703055c23d0
5
+ SHA512:
6
+ metadata.gz: 86900628a5377880e7d9e11f47e3736d9ccec2dd8e7a4072693db1f2e5a65fc23363a1f8d4d4152436ff3a6c97694317fb30e7eb0b05dfefd441d855855e7219
7
+ data.tar.gz: e3c2516e2facafab6e6e3ff11211a050559bd1fb720dab9b52dfade48168ba329fdf792840c611351565c76053945ac0eaf74fe78192de2c3c22bb76bc5b6d0a
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2026 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+
2
+ # Getting Started with APIMATIC Calculator
3
+
4
+ ## Introduction
5
+
6
+ Simple calculator API hosted on APIMATIC
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```bash
13
+ gem install cli-sdk -v 1.0.0
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'cli-sdk', '1.0.0'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the cli-sdk gem](https://rubygems.org/gems/cli-sdk/versions/1.0.0).
23
+
24
+ ## IRB Console Usage
25
+
26
+ You can explore the SDK interactively using IRB in two ways
27
+
28
+ ### 1. Use IRB with Installed Gem
29
+
30
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
31
+
32
+ ```bash
33
+ irb
34
+ ```
35
+
36
+ Now you can load the SDK in the IRB
37
+
38
+ ```ruby
39
+ require 'apimatic_calculator'
40
+ include ApimaticCalculator
41
+ ```
42
+
43
+ ### 2. Use IRB within SDK
44
+
45
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
46
+
47
+ ```
48
+ cd path/to/apimatic_calculator
49
+ ```
50
+
51
+ Now you can start the preconfigured irb console by running the following command
52
+
53
+ ```bash
54
+ ruby bin/console
55
+ ```
56
+
57
+ **_Note:_** This automatically loads the SDK from lib/
58
+
59
+ ## Initialize the API Client
60
+
61
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/client.md)
62
+
63
+ The following parameters are configurable for the API Client:
64
+
65
+ | Parameter | Type | Description |
66
+ | --- | --- | --- |
67
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
68
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
69
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
70
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
71
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
72
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
73
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
74
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
75
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
76
+ | proxy_settings | [`ProxySettings`](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
77
+
78
+ The API client can be initialized as follows:
79
+
80
+ ### Code-Based Client Initialization
81
+
82
+ ```ruby
83
+ require 'apimatic_calculator'
84
+ include ApimaticCalculator
85
+
86
+ client = Client.new
87
+ ```
88
+
89
+ ### Environment-Based Client Initialization
90
+
91
+ ```ruby
92
+ require 'apimatic_calculator'
93
+ include ApimaticCalculator
94
+
95
+ # Create client from environment
96
+ client = Client.from_env
97
+ ```
98
+
99
+ See the [`Environment-Based Client Initialization`](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
100
+
101
+ ## List of APIs
102
+
103
+ * [Simple Calculator](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/controllers/simple-calculator.md)
104
+
105
+ ## SDK Infrastructure
106
+
107
+ ### Configuration
108
+
109
+ * [ProxySettings](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
110
+ * [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
111
+
112
+ ### HTTP
113
+
114
+ * [HttpResponse](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/http-response.md)
115
+ * [HttpRequest](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/http-request.md)
116
+
117
+ ### Utilities
118
+
119
+ * [ApiHelper](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/api-helper.md)
120
+ * [DateTimeHelper](https://www.github.com/WasifMatic/acme-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
121
+
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the lib folder into Ruby's load path
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
+
6
+ # Require the gem
7
+ require 'apimatic_calculator'
8
+
9
+ puts 'ApimaticCalculator SDK loaded!'
10
+ puts 'You can now create a client with: client = ApimaticCalculator::Client.new'
11
+ puts 'Or use from_env: client = ApimaticCalculator::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # apimatic_calculator client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config
11
+
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
16
+ # Access to simple_calculator controller.
17
+ # @return [SimpleCalculatorController] Returns the controller instance.
18
+ def simple_calculator
19
+ @simple_calculator ||= SimpleCalculatorController.new @global_configuration
20
+ end
21
+
22
+ def initialize(
23
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
24
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
25
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
26
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
27
+ environment: Environment::PRODUCTION, config: nil
28
+ )
29
+ @config = if config.nil?
30
+ Configuration.new(connection: connection, adapter: adapter,
31
+ timeout: timeout, max_retries: max_retries,
32
+ retry_interval: retry_interval,
33
+ backoff_factor: backoff_factor,
34
+ retry_statuses: retry_statuses,
35
+ retry_methods: retry_methods,
36
+ http_callback: http_callback,
37
+ proxy_settings: proxy_settings,
38
+ environment: environment)
39
+ else
40
+ config
41
+ end
42
+
43
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
44
+ .base_uri_executor(@config.method(:get_base_uri))
45
+ .global_errors(BaseController::GLOBAL_ERRORS)
46
+ .user_agent(BaseController.user_agent)
47
+ end
48
+
49
+ # Creates a client directly from environment variables.
50
+ def self.from_env(**overrides)
51
+ default_config = Configuration.build_default_config_from_env
52
+ new_config = default_config.clone_with(**overrides)
53
+ new(config: new_config)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,146 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # PRODUCTION: This environment connect to the LIVE calculator API
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
41
+
42
+ class << self
43
+ attr_reader :environments
44
+ end
45
+
46
+ def initialize(
47
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
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
+ environment: Environment::PRODUCTION
52
+ )
53
+ super connection: connection, adapter: adapter, timeout: timeout,
54
+ max_retries: max_retries, retry_interval: retry_interval,
55
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
56
+ retry_methods: retry_methods, http_callback: http_callback,
57
+ proxy_settings: proxy_settings
58
+
59
+ # Current API environment
60
+ @environment = String(environment)
61
+
62
+ # The Http Client to use for making requests.
63
+ set_http_client CoreLibrary::FaradayClient.new(self)
64
+ end
65
+
66
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
67
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
68
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
69
+ proxy_settings: nil, environment: nil)
70
+ connection ||= self.connection
71
+ adapter ||= self.adapter
72
+ timeout ||= self.timeout
73
+ max_retries ||= self.max_retries
74
+ retry_interval ||= self.retry_interval
75
+ backoff_factor ||= self.backoff_factor
76
+ retry_statuses ||= self.retry_statuses
77
+ retry_methods ||= self.retry_methods
78
+ http_callback ||= self.http_callback
79
+ proxy_settings ||= self.proxy_settings
80
+ environment ||= self.environment
81
+
82
+ Configuration.new(connection: connection, adapter: adapter,
83
+ timeout: timeout, max_retries: max_retries,
84
+ retry_interval: retry_interval,
85
+ backoff_factor: backoff_factor,
86
+ retry_statuses: retry_statuses,
87
+ retry_methods: retry_methods,
88
+ http_callback: http_callback,
89
+ proxy_settings: proxy_settings,
90
+ environment: environment)
91
+ end
92
+
93
+
94
+ # All the environments the SDK can run in.
95
+ ENVIRONMENTS = {
96
+ Environment::PRODUCTION => {
97
+ Server::DEFAULT => 'https://examples.apimatic.io/apps/calculator'
98
+ }
99
+ }.freeze
100
+
101
+ # Generates the appropriate base URI for the environment and the server.
102
+ # @param [Configuration::Server] server The server enum for which the base URI is
103
+ # required.
104
+ # @return [String] The base URI.
105
+ def get_base_uri(server = Server::DEFAULT)
106
+ ENVIRONMENTS[environment][server].clone
107
+ end
108
+
109
+ # Builds a Configuration instance using environment variables.
110
+ def self.build_default_config_from_env
111
+ # === Core environment ===
112
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
113
+ timeout = (ENV['TIMEOUT'] || 60).to_f
114
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
115
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
116
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
117
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
118
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
119
+ .split(',')
120
+ .map(&:strip)
121
+ .map do |item|
122
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
123
+ end
124
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
125
+ .split(',')
126
+ .map(&:strip)
127
+ .map do |item|
128
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
129
+ end
130
+
131
+ # === Proxy settings ===
132
+ proxy_settings = ProxySettings.from_env
133
+
134
+ Configuration.new(
135
+ environment: environment,
136
+ timeout: timeout,
137
+ max_retries: max_retries,
138
+ retry_interval: retry_interval,
139
+ backoff_factor: backoff_factor,
140
+ retry_statuses: retry_statuses,
141
+ retry_methods: retry_methods,
142
+ proxy_settings: proxy_settings
143
+ )
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,60 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
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,33 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # SimpleCalculatorController
8
+ class SimpleCalculatorController < BaseController
9
+ # Calculates the expression using the specified operation.
10
+ # @param [OperationTypeEnum] operation Required parameter: The operator to
11
+ # apply on the variables
12
+ # @param [Float] x Required parameter: The LHS value
13
+ # @param [Float] y Required parameter: The RHS value
14
+ # @return [Float] Response from the API call.
15
+ def calculate(operation,
16
+ x,
17
+ y)
18
+ @api_call
19
+ .request(new_request_builder(HttpMethodEnum::GET,
20
+ '/{operation}',
21
+ Server::DEFAULT)
22
+ .template_param(new_parameter(operation, key: 'operation')
23
+ .should_encode(true))
24
+ .query_param(new_parameter(x, key: 'x'))
25
+ .query_param(new_parameter(y, key: 'y')))
26
+ .response(new_response_handler
27
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
28
+ .deserialize_into(proc do |response| response&.to_f end)
29
+ .is_primitive_response(true))
30
+ .execute
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
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,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
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
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ ##
8
+ # ProxySettings encapsulates HTTP proxy configuration for Faraday,
9
+ # including optional basic authentication.
10
+ #
11
+ class ProxySettings < CoreLibrary::ProxySettings
12
+ def self.from_env
13
+ address = ENV['PROXY_ADDRESS']
14
+ port = ENV['PROXY_PORT']
15
+ username = ENV['PROXY_USERNAME']
16
+ password = ENV['PROXY_PASSWORD']
17
+ return nil if address.nil? || address.strip.empty?
18
+
19
+ new(address: address, port: port, username: username, password: password)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,110 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # Base model.
8
+ # rubocop:disable all
9
+ class BaseModel < CoreLibrary::BaseModel
10
+ # Returns a Hash representation of the current object.
11
+ def to_hash
12
+ # validating the model being serialized
13
+ self.class.validate(self) if self.class.respond_to?(:validate)
14
+
15
+ hash = {}
16
+ instance_variables.each do |name|
17
+ value = instance_variable_get(name)
18
+ name = name[1..]
19
+ if name == 'additional_properties'
20
+ additional_properties = process_additional_properties(value, self.class.names)
21
+ hash.merge!(additional_properties)
22
+ else
23
+ key = self.class.names.key?(name) ? self.class.names[name] : name
24
+ optional_fields = self.class.optionals
25
+ nullable_fields = self.class.nullables
26
+ if value.nil?
27
+ next unless nullable_fields.include?(name)
28
+
29
+ if !optional_fields.include?(name) && !nullable_fields.include?(name)
30
+ raise ArgumentError,
31
+ "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
32
+ end
33
+ end
34
+
35
+ hash[key] = nil
36
+ unless value.nil?
37
+ if respond_to?("to_custom_#{name}")
38
+ if (value.instance_of? Array) || (value.instance_of? Hash)
39
+ params = [hash, key]
40
+ hash[key] = send("to_custom_#{name}", *params)
41
+ else
42
+ hash[key] = send("to_custom_#{name}")
43
+ end
44
+ elsif respond_to?("to_union_type_#{name}")
45
+ hash[key] = send("to_union_type_#{name}")
46
+ elsif value.instance_of? Array
47
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
48
+ elsif value.instance_of? Hash
49
+ hash[key] = {}
50
+ value.each do |k, v|
51
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
52
+ end
53
+ else
54
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
55
+ end
56
+ end
57
+ end
58
+ end
59
+ hash
60
+ end
61
+
62
+ # Processes additional properties, ensuring no conflicts with existing properties.
63
+ def process_additional_properties(additional_properties, existing_prop_names)
64
+ hash = {}
65
+ additional_properties.each do |name, value|
66
+ check_for_conflict(name, existing_prop_names)
67
+
68
+ hash[name] = if value.is_a?(Array)
69
+ process_array(value)
70
+ elsif value.is_a?(Hash)
71
+ process_hash(value)
72
+ else
73
+ process_basic_value(value)
74
+ end
75
+ end
76
+ hash
77
+ end
78
+
79
+ # Checks if an additional property conflicts with a model's existing property.
80
+ def check_for_conflict(name, existing_prop_names)
81
+ return unless existing_prop_names.key?(name)
82
+
83
+ raise ArgumentError, "An additional property key, '#{name}' conflicts with one of the model's properties"
84
+ end
85
+
86
+ # Processes an array of values, recursively calling `to_hash` on BaseModel objects.
87
+ def process_array(value)
88
+ value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
89
+ end
90
+
91
+ # Processes a hash of values, recursively calling `to_hash` on BaseModel objects.
92
+ def process_hash(value)
93
+ value.transform_values do |v|
94
+ v.is_a?(BaseModel) ? v.to_hash : v
95
+ end
96
+ end
97
+
98
+ # Processes a basic value (non-array, non-hash).
99
+ def process_basic_value(value)
100
+ value.is_a?(BaseModel) ? value.to_hash : value
101
+ end
102
+
103
+ # Returns a JSON representation of the curent object.
104
+ def to_json(options = {})
105
+ hash = to_hash
106
+ hash.to_json(options)
107
+ end
108
+ end
109
+ # rubocop:enable all
110
+ end
@@ -0,0 +1,44 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # Possible operators are sum, subtract, multiply, divide
8
+ class OperationTypeEnum
9
+ OPERATION_TYPE_ENUM = [
10
+ # TODO: Write general description for SUM
11
+ SUM = 'SUM'.freeze,
12
+
13
+ # TODO: Write general description for SUBTRACT
14
+ SUBTRACT = 'SUBTRACT'.freeze,
15
+
16
+ # TODO: Write general description for MULTIPLY
17
+ MULTIPLY = 'MULTIPLY'.freeze,
18
+
19
+ # TODO: Write general description for DIVIDE
20
+ DIVIDE = 'DIVIDE'.freeze
21
+ ].freeze
22
+
23
+ def self.validate(value)
24
+ return false if value.nil?
25
+
26
+ OPERATION_TYPE_ENUM.include?(value)
27
+ end
28
+
29
+ def self.from_value(value, default_value = SUM)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'sum' then SUM
36
+ when 'subtract' then SUBTRACT
37
+ when 'multiply' then MULTIPLY
38
+ when 'divide' then DIVIDE
39
+ else
40
+ default_value
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module ApimaticCalculator
8
+ # A utility that supports dateTime conversion to different formats
9
+ class DateTimeHelper < CoreLibrary::DateTimeHelper
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # A utility to allow users to set the content-type for files
8
+ class FileWrapper < CoreLibrary::FileWrapper
9
+ # The constructor.
10
+ # @param [File] file The file to be sent in the request.
11
+ # @param [string] content_type The content type of the provided file.
12
+ def initialize(file, content_type: 'application/octet-stream')
13
+ super
14
+ end
15
+
16
+ # Provides a human-readable string representation of the object.
17
+ def to_s
18
+ class_name = self.class.name.split('::').last
19
+ "<#{class_name} file: #{@file}, content_type: #{@content_type}>"
20
+ end
21
+
22
+ # Provides a debugging-friendly string with detailed object information.
23
+ def to_inspect
24
+ class_name = self.class.name.split('::').last
25
+ "<#{class_name} file: #{@file.inspect}, content_type: #{@content_type.inspect}>"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ require 'json'
8
+
9
+ require 'apimatic_core_interfaces'
10
+ require 'apimatic_core'
11
+ require 'apimatic_faraday_client_adapter'
12
+
13
+ require_relative 'apimatic_calculator/api_helper'
14
+ require_relative 'apimatic_calculator/client'
15
+
16
+ # Utilities
17
+ require_relative 'apimatic_calculator/utilities/file_wrapper'
18
+ require_relative 'apimatic_calculator/utilities/date_time_helper'
19
+
20
+ # Http
21
+ require_relative 'apimatic_calculator/http/http_call_back'
22
+ require_relative 'apimatic_calculator/http/http_method_enum'
23
+ require_relative 'apimatic_calculator/http/http_request'
24
+ require_relative 'apimatic_calculator/http/http_response'
25
+ require_relative 'apimatic_calculator/http/proxy_settings'
26
+
27
+
28
+
29
+ # Models
30
+ require_relative 'apimatic_calculator/models/base_model'
31
+ require_relative 'apimatic_calculator/models/operation_type_enum'
32
+
33
+ # Exceptions
34
+ require_relative 'apimatic_calculator/exceptions/api_exception'
35
+
36
+ require_relative 'apimatic_calculator/configuration'
37
+
38
+ # Controllers
39
+ require_relative 'apimatic_calculator/controllers/base_controller'
40
+ require_relative 'apimatic_calculator/controllers/simple_calculator_controller'
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cli-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - cli-user
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: apimatic_core_interfaces
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: apimatic_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.20
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.20
41
+ - !ruby/object:Gem::Dependency
42
+ name: apimatic_faraday_client_adapter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.6
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.6
55
+ description: ''
56
+ email: []
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - bin/console
64
+ - lib/apimatic_calculator.rb
65
+ - lib/apimatic_calculator/api_helper.rb
66
+ - lib/apimatic_calculator/client.rb
67
+ - lib/apimatic_calculator/configuration.rb
68
+ - lib/apimatic_calculator/controllers/base_controller.rb
69
+ - lib/apimatic_calculator/controllers/simple_calculator_controller.rb
70
+ - lib/apimatic_calculator/exceptions/api_exception.rb
71
+ - lib/apimatic_calculator/http/http_call_back.rb
72
+ - lib/apimatic_calculator/http/http_method_enum.rb
73
+ - lib/apimatic_calculator/http/http_request.rb
74
+ - lib/apimatic_calculator/http/http_response.rb
75
+ - lib/apimatic_calculator/http/proxy_settings.rb
76
+ - lib/apimatic_calculator/models/base_model.rb
77
+ - lib/apimatic_calculator/models/operation_type_enum.rb
78
+ - lib/apimatic_calculator/utilities/date_time_helper.rb
79
+ - lib/apimatic_calculator/utilities/file_wrapper.rb
80
+ homepage: https://apimatic.io
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '2.6'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.1.6
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: SDK for CLI
103
+ test_files: []