testingToday1047 3.2.3
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 +68 -0
- data/lib/apimatic_calculator/api_helper.rb +10 -0
- data/lib/apimatic_calculator/client.rb +42 -0
- data/lib/apimatic_calculator/configuration.rb +89 -0
- data/lib/apimatic_calculator/controllers/base_controller.rb +65 -0
- data/lib/apimatic_calculator/controllers/simple_calculator_controller.rb +31 -0
- data/lib/apimatic_calculator/exceptions/api_exception.rb +10 -0
- data/lib/apimatic_calculator/http/http_call_back.rb +10 -0
- data/lib/apimatic_calculator/http/http_method_enum.rb +10 -0
- data/lib/apimatic_calculator/http/http_request.rb +10 -0
- data/lib/apimatic_calculator/http/http_response.rb +10 -0
- data/lib/apimatic_calculator/models/base_model.rb +58 -0
- data/lib/apimatic_calculator/models/operation_type_enum.rb +23 -0
- data/lib/apimatic_calculator/utilities/date_time_helper.rb +11 -0
- data/lib/apimatic_calculator/utilities/file_wrapper.rb +16 -0
- data/lib/apimatic_calculator.rb +39 -0
- data/test/controllers/controller_test_base.rb +28 -0
- data/test/controllers/test_simple_calculator_controller.rb +35 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13f4e8271101a38fe6eaad1a6903307a27c84beca1e1477ce13cdba8ed0134e0
|
4
|
+
data.tar.gz: 8095d0007bc76e507ffa6f470800c443e2c03ec35c92a5055eeb960f47c8802d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d47a548382316e44946bfcdcc9b3be4590652db0a0d50e3d39259af346545ac62ce74f3f96d6397b6bd7127c9b63512be20058baf4289c78740283807fd78607
|
7
|
+
data.tar.gz: 3e6a488672a342629c691e15da483f1bb6a21d02b6ec1aa7173eff04dc28606f379ee6b722807ae28a3419174bd35a2dd13d19055834fe2f54ea0e47ddb17b17
|
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 - 2023 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,68 @@
|
|
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
|
+
```ruby
|
13
|
+
gem install testingToday1047 -v 3.2.3
|
14
|
+
```
|
15
|
+
|
16
|
+
Or add the gem to your Gemfile and run `bundle`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'testingToday1047', '3.2.3'
|
20
|
+
```
|
21
|
+
|
22
|
+
For additional gem details, see the [RubyGems page for the testingToday1047 gem](https://rubygems.org/gems/testingToday1047/versions/3.2.3).
|
23
|
+
|
24
|
+
## Test the SDK
|
25
|
+
|
26
|
+
To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
|
27
|
+
|
28
|
+
```
|
29
|
+
rake
|
30
|
+
```
|
31
|
+
|
32
|
+
## Initialize the API Client
|
33
|
+
|
34
|
+
**_Note:_** Documentation for the client can be found [here.](doc/client.md)
|
35
|
+
|
36
|
+
The following parameters are configurable for the API Client:
|
37
|
+
|
38
|
+
| Parameter | Type | Description |
|
39
|
+
| --- | --- | --- |
|
40
|
+
| `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION`** |
|
41
|
+
| `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
42
|
+
| `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
43
|
+
| `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
|
44
|
+
| `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
45
|
+
| `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
|
46
|
+
| `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
|
47
|
+
| `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
48
|
+
| `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
49
|
+
| `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
50
|
+
|
51
|
+
The API client can be initialized as follows:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
client = ApimaticCalculator::Client.new(
|
55
|
+
environment: Environment::PRODUCTION
|
56
|
+
)
|
57
|
+
```
|
58
|
+
|
59
|
+
## List of APIs
|
60
|
+
|
61
|
+
* [Simple Calculator](doc/controllers/simple-calculator.md)
|
62
|
+
|
63
|
+
## Classes Documentation
|
64
|
+
|
65
|
+
* [Utility Classes](doc/utility-classes.md)
|
66
|
+
* [HttpResponse](doc/http-response.md)
|
67
|
+
* [HttpRequest](doc/http-request.md)
|
68
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ApimaticCalculator
|
7
|
+
# apimatic_calculator client class.
|
8
|
+
class Client
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
# Access to simple_calculator controller.
|
12
|
+
# @return [SimpleCalculatorController] Returns the controller instance.
|
13
|
+
def simple_calculator
|
14
|
+
@simple_calculator ||= SimpleCalculatorController.new @global_configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
18
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
19
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
20
|
+
retry_methods: %i[get put], http_callback: nil,
|
21
|
+
environment: Environment::PRODUCTION, config: nil)
|
22
|
+
@config = if config.nil?
|
23
|
+
Configuration.new(connection: connection, adapter: adapter,
|
24
|
+
timeout: timeout, max_retries: max_retries,
|
25
|
+
retry_interval: retry_interval,
|
26
|
+
backoff_factor: backoff_factor,
|
27
|
+
retry_statuses: retry_statuses,
|
28
|
+
retry_methods: retry_methods,
|
29
|
+
http_callback: http_callback,
|
30
|
+
environment: environment)
|
31
|
+
else
|
32
|
+
config
|
33
|
+
end
|
34
|
+
|
35
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
36
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
37
|
+
.global_errors(BaseController::GLOBAL_ERRORS)
|
38
|
+
.user_agent(BaseController.user_agent)
|
39
|
+
.sdk_module(ApimaticCalculator)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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
|
+
end
|
14
|
+
|
15
|
+
# An enum for API servers.
|
16
|
+
class Server
|
17
|
+
SERVER = [
|
18
|
+
CALCULATOR = 'Calculator'.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
|
27
|
+
|
28
|
+
class << self
|
29
|
+
attr_reader :environments
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
33
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
34
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
35
|
+
retry_methods: %i[get put], http_callback: nil,
|
36
|
+
environment: Environment::PRODUCTION)
|
37
|
+
|
38
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
39
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
40
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
41
|
+
retry_methods: retry_methods, http_callback: http_callback
|
42
|
+
|
43
|
+
# Current API environment
|
44
|
+
@environment = String(environment)
|
45
|
+
|
46
|
+
# The Http Client to use for making requests.
|
47
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
48
|
+
end
|
49
|
+
|
50
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
51
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
52
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
53
|
+
environment: nil)
|
54
|
+
connection ||= self.connection
|
55
|
+
adapter ||= self.adapter
|
56
|
+
timeout ||= self.timeout
|
57
|
+
max_retries ||= self.max_retries
|
58
|
+
retry_interval ||= self.retry_interval
|
59
|
+
backoff_factor ||= self.backoff_factor
|
60
|
+
retry_statuses ||= self.retry_statuses
|
61
|
+
retry_methods ||= self.retry_methods
|
62
|
+
http_callback ||= self.http_callback
|
63
|
+
environment ||= self.environment
|
64
|
+
|
65
|
+
Configuration.new(connection: connection, adapter: adapter,
|
66
|
+
timeout: timeout, max_retries: max_retries,
|
67
|
+
retry_interval: retry_interval,
|
68
|
+
backoff_factor: backoff_factor,
|
69
|
+
retry_statuses: retry_statuses,
|
70
|
+
retry_methods: retry_methods,
|
71
|
+
http_callback: http_callback, environment: environment)
|
72
|
+
end
|
73
|
+
|
74
|
+
# All the environments the SDK can run in.
|
75
|
+
ENVIRONMENTS = {
|
76
|
+
Environment::PRODUCTION => {
|
77
|
+
Server::CALCULATOR => 'https://examples.apimatic.io/apps/calculator'
|
78
|
+
}
|
79
|
+
}.freeze
|
80
|
+
|
81
|
+
# Generates the appropriate base URI for the environment and the server.
|
82
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
83
|
+
# required.
|
84
|
+
# @return [String] The base URI.
|
85
|
+
def get_base_uri(server = Server::CALCULATOR)
|
86
|
+
ENVIRONMENTS[environment][server].clone
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ApimaticCalculator
|
7
|
+
# BaseController.
|
8
|
+
class BaseController
|
9
|
+
attr_accessor :config, :http_call_back
|
10
|
+
|
11
|
+
def self.user_agent
|
12
|
+
'APIMATIC 3.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
GLOBAL_ERRORS = {
|
17
|
+
'default' => ErrorCase.new
|
18
|
+
.error_message('HTTP response not OK.')
|
19
|
+
.exception_type(APIException)
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
# Initialization constructor.
|
23
|
+
# @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
|
24
|
+
def initialize(global_configuration)
|
25
|
+
@global_configuration = global_configuration
|
26
|
+
@config = @global_configuration.client_configuration
|
27
|
+
@http_call_back = @config.http_callback
|
28
|
+
@api_call = ApiCall.new(@global_configuration)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Creates a new builder for the Api Call instance.
|
32
|
+
# @return [ApiCall] The instance of ApiCall.
|
33
|
+
def new_api_call_builder
|
34
|
+
@api_call.new_builder
|
35
|
+
end
|
36
|
+
|
37
|
+
# Creates a new instance of the request builder.
|
38
|
+
# @param [HttpMethodEnum] http_method The HTTP method to use in the request.
|
39
|
+
# @param [String] path The endpoint path to use in the request.
|
40
|
+
# @param [String] server The server to extract the base uri for the request.
|
41
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
42
|
+
def new_request_builder(http_method, path, server)
|
43
|
+
RequestBuilder.new
|
44
|
+
.http_method(http_method)
|
45
|
+
.path(path)
|
46
|
+
.server(server)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Creates a new instance of the response handler.
|
50
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
51
|
+
def new_response_handler
|
52
|
+
ResponseHandler.new
|
53
|
+
end
|
54
|
+
|
55
|
+
# Creates a new instance of the parameter.
|
56
|
+
# @param [String|optional] key The key of the parameter.
|
57
|
+
# @param [Object] value The value of the parameter.
|
58
|
+
# @return [Parameter] The instance of Parameter.
|
59
|
+
def new_parameter(value, key: nil)
|
60
|
+
Parameter.new
|
61
|
+
.key(key)
|
62
|
+
.value(value)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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 get_calculate(options = {})
|
16
|
+
new_api_call_builder
|
17
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
18
|
+
'/{operation}',
|
19
|
+
Server::CALCULATOR)
|
20
|
+
.template_param(new_parameter(options['operation'], key: 'operation')
|
21
|
+
.should_encode(true))
|
22
|
+
.query_param(new_parameter(options['x'], key: 'x'))
|
23
|
+
.query_param(new_parameter(options['y'], key: 'y')))
|
24
|
+
.response(new_response_handler
|
25
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
26
|
+
.deserialize_into(proc do |response| response.to_f end)
|
27
|
+
.is_primitive_response(true))
|
28
|
+
.execute
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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,58 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ApimaticCalculator
|
7
|
+
# Base model.
|
8
|
+
class BaseModel < CoreLibrary::BaseModel
|
9
|
+
# Returns a Hash representation of the current object.
|
10
|
+
def to_hash
|
11
|
+
hash = {}
|
12
|
+
instance_variables.each do |name|
|
13
|
+
value = instance_variable_get(name)
|
14
|
+
name = name[1..]
|
15
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
16
|
+
|
17
|
+
optional_fields = self.class.optionals
|
18
|
+
nullable_fields = self.class.nullables
|
19
|
+
if value.nil?
|
20
|
+
next unless nullable_fields.include?(name)
|
21
|
+
|
22
|
+
if !optional_fields.include?(name) && !nullable_fields.include?(name)
|
23
|
+
raise ArgumentError,
|
24
|
+
"`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
hash[key] = nil
|
29
|
+
unless value.nil?
|
30
|
+
if respond_to?("to_#{name}")
|
31
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
32
|
+
params = [hash, key]
|
33
|
+
hash[key] = send("to_#{name}", *params)
|
34
|
+
else
|
35
|
+
hash[key] = send("to_#{name}")
|
36
|
+
end
|
37
|
+
elsif value.instance_of? Array
|
38
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
39
|
+
elsif value.instance_of? Hash
|
40
|
+
hash[key] = {}
|
41
|
+
value.each do |k, v|
|
42
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
43
|
+
end
|
44
|
+
else
|
45
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a JSON representation of the curent object.
|
53
|
+
def to_json(options = {})
|
54
|
+
hash = to_hash
|
55
|
+
hash.to_json(options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module ApimaticCalculator
|
7
|
+
# Possible operators are sum, subtract, multiply, divide
|
8
|
+
class OperationTypeEnum
|
9
|
+
OPERATION_TYPE_ENUM = [
|
10
|
+
# Represents the sum operator
|
11
|
+
SUM = 'SUM'.freeze,
|
12
|
+
|
13
|
+
# Represents the subtract operator
|
14
|
+
SUBTRACT = 'SUBTRACT'.freeze,
|
15
|
+
|
16
|
+
# Represents the multiply operator
|
17
|
+
MULTIPLY = 'MULTIPLY'.freeze,
|
18
|
+
|
19
|
+
# Represents the divide operator
|
20
|
+
DIVIDE = 'DIVIDE'.freeze
|
21
|
+
].freeze
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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,16 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://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
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
require 'json'
|
8
|
+
require 'apimatic_core_interfaces'
|
9
|
+
require 'apimatic_core'
|
10
|
+
require 'apimatic_faraday_client_adapter'
|
11
|
+
# rubocop:disable Style/MixinUsage
|
12
|
+
include CoreLibrary
|
13
|
+
# rubocop:enable Style/MixinUsage
|
14
|
+
|
15
|
+
require_relative 'apimatic_calculator/api_helper'
|
16
|
+
require_relative 'apimatic_calculator/client'
|
17
|
+
|
18
|
+
# Utilities
|
19
|
+
require_relative 'apimatic_calculator/utilities/file_wrapper'
|
20
|
+
require_relative 'apimatic_calculator/utilities/date_time_helper'
|
21
|
+
|
22
|
+
# Http
|
23
|
+
require_relative 'apimatic_calculator/http/http_call_back'
|
24
|
+
require_relative 'apimatic_calculator/http/http_method_enum'
|
25
|
+
require_relative 'apimatic_calculator/http/http_request'
|
26
|
+
require_relative 'apimatic_calculator/http/http_response'
|
27
|
+
|
28
|
+
# Models
|
29
|
+
require_relative 'apimatic_calculator/models/base_model'
|
30
|
+
require_relative 'apimatic_calculator/models/operation_type_enum'
|
31
|
+
|
32
|
+
# Exceptions
|
33
|
+
require_relative 'apimatic_calculator/exceptions/api_exception'
|
34
|
+
|
35
|
+
require_relative 'apimatic_calculator/configuration'
|
36
|
+
|
37
|
+
# Controllers
|
38
|
+
require_relative 'apimatic_calculator/controllers/base_controller'
|
39
|
+
require_relative 'apimatic_calculator/controllers/simple_calculator_controller'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/hell'
|
9
|
+
require 'minitest/pride'
|
10
|
+
require 'minitest/proveit'
|
11
|
+
require 'apimatic_calculator'
|
12
|
+
require_relative '../http_response_catcher'
|
13
|
+
|
14
|
+
class ControllerTestBase < Minitest::Test
|
15
|
+
parallelize_me!
|
16
|
+
include ApimaticCalculator
|
17
|
+
|
18
|
+
# Create configuration and set any test parameters
|
19
|
+
def create_configuration
|
20
|
+
Configuration.new(http_callback: HttpResponseCatcher.new)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Initializes the base test controller
|
24
|
+
def setup_class
|
25
|
+
_config = create_configuration
|
26
|
+
@client = Client.new(config: _config)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require_relative 'controller_test_base'
|
7
|
+
|
8
|
+
class SimpleCalculatorControllerTests < ControllerTestBase
|
9
|
+
# Called only once for the class before any test has executed
|
10
|
+
def setup
|
11
|
+
setup_class
|
12
|
+
@controller = @client.simple_calculator
|
13
|
+
@response_catcher = @controller.http_call_back
|
14
|
+
end
|
15
|
+
|
16
|
+
# Check if multiplication works
|
17
|
+
def test_multiply()
|
18
|
+
# Parameters for the API call
|
19
|
+
options = {}
|
20
|
+
options['operation'] = 'MULTIPLY'
|
21
|
+
options['x'] = 4
|
22
|
+
options['y'] = 5
|
23
|
+
|
24
|
+
# Perform the API call through the SDK function
|
25
|
+
result = @controller.get_calculate(options)
|
26
|
+
|
27
|
+
# Test response code
|
28
|
+
assert_equal(200, @response_catcher.response.status_code)
|
29
|
+
|
30
|
+
# Test whether the captured response is as we expected
|
31
|
+
refute_nil(result)
|
32
|
+
assert_equal('20', @response_catcher.response.raw_body)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < ApimaticCalculator::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(response)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testingToday1047
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- APIMatic SDK Generator
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-14 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.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
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.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.0
|
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.0
|
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.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.14'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 5.14.1
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '5.14'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 5.14.1
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest-proveit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.0'
|
89
|
+
description: ''
|
90
|
+
email:
|
91
|
+
- support@apimatic.io
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- lib/apimatic_calculator.rb
|
99
|
+
- lib/apimatic_calculator/api_helper.rb
|
100
|
+
- lib/apimatic_calculator/client.rb
|
101
|
+
- lib/apimatic_calculator/configuration.rb
|
102
|
+
- lib/apimatic_calculator/controllers/base_controller.rb
|
103
|
+
- lib/apimatic_calculator/controllers/simple_calculator_controller.rb
|
104
|
+
- lib/apimatic_calculator/exceptions/api_exception.rb
|
105
|
+
- lib/apimatic_calculator/http/http_call_back.rb
|
106
|
+
- lib/apimatic_calculator/http/http_method_enum.rb
|
107
|
+
- lib/apimatic_calculator/http/http_request.rb
|
108
|
+
- lib/apimatic_calculator/http/http_response.rb
|
109
|
+
- lib/apimatic_calculator/models/base_model.rb
|
110
|
+
- lib/apimatic_calculator/models/operation_type_enum.rb
|
111
|
+
- lib/apimatic_calculator/utilities/date_time_helper.rb
|
112
|
+
- lib/apimatic_calculator/utilities/file_wrapper.rb
|
113
|
+
- test/controllers/controller_test_base.rb
|
114
|
+
- test/controllers/test_simple_calculator_controller.rb
|
115
|
+
- test/http_response_catcher.rb
|
116
|
+
homepage: ''
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2.6'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.7.6
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: apimatic_calculator
|
140
|
+
test_files: []
|