ruby-packageee-sdk 1.2.3
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 +68 -0
- data/lib/apimatic_calculator/api_helper.rb +10 -0
- data/lib/apimatic_calculator/client.rb +44 -0
- data/lib/apimatic_calculator/configuration.rb +92 -0
- data/lib/apimatic_calculator/controllers/base_controller.rb +66 -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 +62 -0
- data/lib/apimatic_calculator/models/operation_type_enum.rb +29 -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 +29 -0
- data/test/controllers/test_simple_calculator_controller.rb +35 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f78cfd6955a79db7e2ebacbebb090c70d0e532558e7c07dcfe83e42f33d6f88
|
4
|
+
data.tar.gz: 38bf49e55e42c06bee8115482addf90a4400e4fcaff5000941bd25124d508786
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86aaa1cd7dbec5b444bb85ddaed2cee03b75d5251441f909217513908c027ab3fe5796100d1dbdb59715c3fdac850664c6d50f7e09aaa8db81f1f3ae5b1bda97
|
7
|
+
data.tar.gz: 25d91391bbeac2a0ef5ab6200a8ff81293c039dd3fc4ba33a005827f01d26eeb7c9a014b14f6ae5dfabd7df7f80903d9553f5971ba0072d46fd4b2fa51a3ad86
|
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 - 2024 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 ruby-packageee-sdk -v 1.2.3
|
14
|
+
```
|
15
|
+
|
16
|
+
Or add the gem to your Gemfile and run `bundle`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'ruby-packageee-sdk', '1.2.3'
|
20
|
+
```
|
21
|
+
|
22
|
+
For additional gem details, see the [RubyGems page for the ruby-packageee-sdk gem](https://rubygems.org/gems/ruby-packageee-sdk/versions/1.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.](https://www.github.com/ZahraN444/rubyrepo/tree/1.2.3/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](https://www.github.com/ZahraN444/rubyrepo/tree/1.2.3/doc/controllers/simple-calculator.md)
|
62
|
+
|
63
|
+
## Classes Documentation
|
64
|
+
|
65
|
+
* [Utility Classes](https://www.github.com/ZahraN444/rubyrepo/tree/1.2.3/doc/utility-classes.md)
|
66
|
+
* [HttpResponse](https://www.github.com/ZahraN444/rubyrepo/tree/1.2.3/doc/http-response.md)
|
67
|
+
* [HttpRequest](https://www.github.com/ZahraN444/rubyrepo/tree/1.2.3/doc/http-request.md)
|
68
|
+
|
@@ -0,0 +1,44 @@
|
|
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
|
+
include CoreLibrary
|
10
|
+
attr_reader :config
|
11
|
+
|
12
|
+
# Access to simple_calculator controller.
|
13
|
+
# @return [SimpleCalculatorController] Returns the controller instance.
|
14
|
+
def simple_calculator
|
15
|
+
@simple_calculator ||= SimpleCalculatorController.new @global_configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(
|
19
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
20
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
21
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
22
|
+
retry_methods: %i[get put], http_callback: nil,
|
23
|
+
environment: Environment::PRODUCTION, config: nil
|
24
|
+
)
|
25
|
+
@config = if config.nil?
|
26
|
+
Configuration.new(connection: connection, adapter: adapter,
|
27
|
+
timeout: timeout, max_retries: max_retries,
|
28
|
+
retry_interval: retry_interval,
|
29
|
+
backoff_factor: backoff_factor,
|
30
|
+
retry_statuses: retry_statuses,
|
31
|
+
retry_methods: retry_methods,
|
32
|
+
http_callback: http_callback,
|
33
|
+
environment: environment)
|
34
|
+
else
|
35
|
+
config
|
36
|
+
end
|
37
|
+
|
38
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
39
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
40
|
+
.global_errors(BaseController::GLOBAL_ERRORS)
|
41
|
+
.user_agent(BaseController.user_agent)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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(
|
33
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
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
|
+
environment: Environment::PRODUCTION
|
38
|
+
)
|
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
|
+
|
45
|
+
# Current API environment
|
46
|
+
@environment = String(environment)
|
47
|
+
|
48
|
+
# The Http Client to use for making requests.
|
49
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
50
|
+
end
|
51
|
+
|
52
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
53
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
54
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
55
|
+
environment: nil)
|
56
|
+
connection ||= self.connection
|
57
|
+
adapter ||= self.adapter
|
58
|
+
timeout ||= self.timeout
|
59
|
+
max_retries ||= self.max_retries
|
60
|
+
retry_interval ||= self.retry_interval
|
61
|
+
backoff_factor ||= self.backoff_factor
|
62
|
+
retry_statuses ||= self.retry_statuses
|
63
|
+
retry_methods ||= self.retry_methods
|
64
|
+
http_callback ||= self.http_callback
|
65
|
+
environment ||= self.environment
|
66
|
+
|
67
|
+
Configuration.new(connection: connection, adapter: adapter,
|
68
|
+
timeout: timeout, max_retries: max_retries,
|
69
|
+
retry_interval: retry_interval,
|
70
|
+
backoff_factor: backoff_factor,
|
71
|
+
retry_statuses: retry_statuses,
|
72
|
+
retry_methods: retry_methods,
|
73
|
+
http_callback: http_callback, environment: environment)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# All the environments the SDK can run in.
|
78
|
+
ENVIRONMENTS = {
|
79
|
+
Environment::PRODUCTION => {
|
80
|
+
Server::CALCULATOR => 'https://examples.apimatic.io/apps/calculator'
|
81
|
+
}
|
82
|
+
}.freeze
|
83
|
+
|
84
|
+
# Generates the appropriate base URI for the environment and the server.
|
85
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
86
|
+
# required.
|
87
|
+
# @return [String] The base URI.
|
88
|
+
def get_base_uri(server = Server::CALCULATOR)
|
89
|
+
ENVIRONMENTS[environment][server].clone
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
+
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 builder for the Api Call instance.
|
33
|
+
# @return [ApiCall] The instance of ApiCall.
|
34
|
+
def new_api_call_builder
|
35
|
+
@api_call.new_builder
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new instance of the request builder.
|
39
|
+
# @param [String] http_method The HTTP method to use in the request.
|
40
|
+
# @param [String] path The endpoint path to use in the request.
|
41
|
+
# @param [String] server The server to extract the base uri for the request.
|
42
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
43
|
+
def new_request_builder(http_method, path, server)
|
44
|
+
RequestBuilder.new
|
45
|
+
.http_method(http_method)
|
46
|
+
.path(path)
|
47
|
+
.server(server)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates a new instance of the response handler.
|
51
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
52
|
+
def new_response_handler
|
53
|
+
ResponseHandler.new
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates a new instance of the parameter.
|
57
|
+
# @param [String|optional] key The key of the parameter.
|
58
|
+
# @param [Object] value The value of the parameter.
|
59
|
+
# @return [Parameter] The instance of Parameter.
|
60
|
+
def new_parameter(value, key: nil)
|
61
|
+
Parameter.new
|
62
|
+
.key(key)
|
63
|
+
.value(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
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,62 @@
|
|
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
|
+
# validating the model being serialized
|
12
|
+
self.class.validate(self) if self.class.respond_to?(:validate)
|
13
|
+
|
14
|
+
hash = {}
|
15
|
+
instance_variables.each do |name|
|
16
|
+
value = instance_variable_get(name)
|
17
|
+
name = name[1..]
|
18
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
19
|
+
optional_fields = self.class.optionals
|
20
|
+
nullable_fields = self.class.nullables
|
21
|
+
if value.nil?
|
22
|
+
next unless nullable_fields.include?(name)
|
23
|
+
|
24
|
+
if !optional_fields.include?(name) && !nullable_fields.include?(name)
|
25
|
+
raise ArgumentError,
|
26
|
+
"`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
hash[key] = nil
|
31
|
+
unless value.nil?
|
32
|
+
if respond_to?("to_custom_#{name}")
|
33
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
34
|
+
params = [hash, key]
|
35
|
+
hash[key] = send("to_custom_#{name}", *params)
|
36
|
+
else
|
37
|
+
hash[key] = send("to_custom_#{name}")
|
38
|
+
end
|
39
|
+
elsif respond_to?("to_union_type_#{name}")
|
40
|
+
hash[key] = send("to_union_type_#{name}")
|
41
|
+
elsif value.instance_of? Array
|
42
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
43
|
+
elsif value.instance_of? Hash
|
44
|
+
hash[key] = {}
|
45
|
+
value.each do |k, v|
|
46
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
47
|
+
end
|
48
|
+
else
|
49
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
hash
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns a JSON representation of the curent object.
|
57
|
+
def to_json(options = {})
|
58
|
+
hash = to_hash
|
59
|
+
hash.to_json(options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
|
23
|
+
def self.validate(value)
|
24
|
+
return false if value.nil?
|
25
|
+
|
26
|
+
OPERATION_TYPE_ENUM.include?(value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
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
|
+
|
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
|
+
|
26
|
+
# Logger
|
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,29 @@
|
|
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
|
+
include CoreLibrary
|
18
|
+
|
19
|
+
# Create configuration and set any test parameters
|
20
|
+
def create_configuration
|
21
|
+
Configuration.new(http_callback: HttpResponseCatcher.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Initializes the base test controller
|
25
|
+
def setup_class
|
26
|
+
_config = create_configuration
|
27
|
+
@client = Client.new(config: _config)
|
28
|
+
end
|
29
|
+
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,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-packageee-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zahra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-07 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.1
|
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.1
|
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.9
|
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.9
|
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.4
|
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.4
|
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: test
|
90
|
+
email:
|
91
|
+
- zahranaseem444@gmail.com
|
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: https://apimatic.io
|
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
|
+
rubygems_version: 3.1.6
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Testsummary -adding repo
|
139
|
+
test_files: []
|