apimatic-calculator-test-sdk-sdk 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +28 -0
  3. data/README.md +68 -0
  4. data/lib/apimatic_calculator/api_helper.rb +10 -0
  5. data/lib/apimatic_calculator/client.rb +41 -0
  6. data/lib/apimatic_calculator/configuration.rb +89 -0
  7. data/lib/apimatic_calculator/controllers/base_controller.rb +65 -0
  8. data/lib/apimatic_calculator/controllers/simple_calculator_controller.rb +31 -0
  9. data/lib/apimatic_calculator/exceptions/api_exception.rb +10 -0
  10. data/lib/apimatic_calculator/http/http_call_back.rb +10 -0
  11. data/lib/apimatic_calculator/http/http_method_enum.rb +10 -0
  12. data/lib/apimatic_calculator/http/http_request.rb +10 -0
  13. data/lib/apimatic_calculator/http/http_response.rb +10 -0
  14. data/lib/apimatic_calculator/models/base_model.rb +62 -0
  15. data/lib/apimatic_calculator/models/operation_type_enum.rb +29 -0
  16. data/lib/apimatic_calculator/utilities/date_time_helper.rb +11 -0
  17. data/lib/apimatic_calculator/utilities/file_wrapper.rb +16 -0
  18. data/lib/apimatic_calculator.rb +39 -0
  19. data/test/controllers/controller_test_base.rb +28 -0
  20. data/test/controllers/test_simple_calculator_controller.rb +35 -0
  21. data/test/http_response_catcher.rb +19 -0
  22. metadata +21 -104
  23. data/bin/arch +0 -1
  24. data/bin/ash +0 -1
  25. data/bin/base64 +0 -1
  26. data/bin/bbconfig +0 -1
  27. data/bin/busybox +0 -0
  28. data/bin/cat +0 -1
  29. data/bin/chattr +0 -1
  30. data/bin/chgrp +0 -1
  31. data/bin/chmod +0 -1
  32. data/bin/chown +0 -1
  33. data/bin/cp +0 -1
  34. data/bin/date +0 -1
  35. data/bin/dd +0 -1
  36. data/bin/df +0 -1
  37. data/bin/dmesg +0 -1
  38. data/bin/dnsdomainname +0 -1
  39. data/bin/dumpkmap +0 -1
  40. data/bin/echo +0 -1
  41. data/bin/ed +0 -1
  42. data/bin/egrep +0 -1
  43. data/bin/false +0 -1
  44. data/bin/fatattr +0 -1
  45. data/bin/fdflush +0 -1
  46. data/bin/fgrep +0 -1
  47. data/bin/fsync +0 -1
  48. data/bin/getopt +0 -1
  49. data/bin/grep +0 -1
  50. data/bin/gunzip +0 -1
  51. data/bin/gzip +0 -1
  52. data/bin/hostname +0 -1
  53. data/bin/ionice +0 -1
  54. data/bin/iostat +0 -1
  55. data/bin/ipcalc +0 -1
  56. data/bin/kbd_mode +0 -1
  57. data/bin/kill +0 -1
  58. data/bin/link +0 -1
  59. data/bin/linux32 +0 -1
  60. data/bin/linux64 +0 -1
  61. data/bin/ln +0 -1
  62. data/bin/login +0 -1
  63. data/bin/ls +0 -1
  64. data/bin/lsattr +0 -1
  65. data/bin/lzop +0 -1
  66. data/bin/makemime +0 -1
  67. data/bin/mkdir +0 -1
  68. data/bin/mknod +0 -1
  69. data/bin/mktemp +0 -1
  70. data/bin/more +0 -1
  71. data/bin/mount +0 -1
  72. data/bin/mountpoint +0 -1
  73. data/bin/mpstat +0 -1
  74. data/bin/mv +0 -1
  75. data/bin/netstat +0 -1
  76. data/bin/nice +0 -1
  77. data/bin/pidof +0 -0
  78. data/bin/ping +0 -1
  79. data/bin/ping6 +0 -1
  80. data/bin/pipe_progress +0 -1
  81. data/bin/printenv +0 -1
  82. data/bin/ps +0 -0
  83. data/bin/pwait +0 -0
  84. data/bin/pwd +0 -1
  85. data/bin/reformime +0 -1
  86. data/bin/rev +0 -1
  87. data/bin/rm +0 -1
  88. data/bin/rmdir +0 -1
  89. data/bin/run-parts +0 -1
  90. data/bin/sed +0 -1
  91. data/bin/setpriv +0 -1
  92. data/bin/setserial +0 -1
  93. data/bin/sh +0 -1
  94. data/bin/slabtop +0 -0
  95. data/bin/sleep +0 -1
  96. data/bin/stat +0 -1
  97. data/bin/stty +0 -1
  98. data/bin/su +0 -1
  99. data/bin/sync +0 -1
  100. data/bin/tar +0 -1
  101. data/bin/tload +0 -0
  102. data/bin/touch +0 -1
  103. data/bin/true +0 -1
  104. data/bin/umount +0 -1
  105. data/bin/uname +0 -1
  106. data/bin/usleep +0 -1
  107. data/bin/vmstat +0 -0
  108. data/bin/w +0 -0
  109. data/bin/watch +0 -0
  110. data/bin/zcat +0 -1
  111. data/lib/apk/db/installed +0 -3582
  112. data/lib/apk/db/lock +0 -0
  113. data/lib/apk/db/scripts.tar +0 -0
  114. data/lib/apk/db/triggers +0 -2
  115. data/lib/ld-musl-x86_64.so.1 +0 -0
  116. data/lib/libapk.so.3.12.0 +0 -0
  117. data/lib/libc.musl-x86_64.so.1 +0 -1
  118. data/lib/libcrypto.so.1.1 +0 -0
  119. data/lib/libprocps.so.8 +0 -1
  120. data/lib/libprocps.so.8.0.3 +0 -0
  121. data/lib/libssl.so.1.1 +0 -0
  122. data/lib/libz.so +0 -1
  123. data/lib/libz.so.1 +0 -1
  124. data/lib/libz.so.1.2.12 +0 -0
  125. data/lib/sysctl.d/00-alpine.conf +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cb344eb75e1c577791cc5ab1e78df32581a358963bb8826be6c0ad1d7b9404a
4
- data.tar.gz: cd102b61a2aa3b90a054a25b9befb65d3065273f73e33b807c73058de6ac9f00
3
+ metadata.gz: 9d63a50883bc2b5142026787e78e93dd71d9d0192a5f1b76ea2f0c273130f9c4
4
+ data.tar.gz: 38073b3f31099f03df199bcf415ec871f8db0e9fb96fb42a73799d2ea208e066
5
5
  SHA512:
6
- metadata.gz: 441a0f25a7e56795982081c71eb368f11f680744ca060670aeb569bc8dd676fdf6c0822873b32bc1e5212cdf7521249f16079b037e12929884ba33c5717e1ea8
7
- data.tar.gz: 690ad8b90fb6b7437da229deaf0f0d9b6fb2c04c204c363c922080724af5a27a0ec504ecd24ae8caa95e497528cb90a28534d65bdebe477b879c6f21c318bb9a
6
+ metadata.gz: 6dfff9e4dbdecf9a9802854e40004e91828400cdf98b766930a846b8e58f6edea0f6e530a31774a4b9ac5b3a113fab38735f645a4caf7dcde3be36e9564b5ee4
7
+ data.tar.gz: e010ca437e508378ce266307267a2405ac3e257217ee8f44f529cb21e3c929e03626394b9641001d5861730df4370418d4218d0066baafdafc4e1219c7639bce
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 apimatic-calculator-test-sdk-sdk -v 0.0.2
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'apimatic-calculator-test-sdk-sdk', '0.0.2'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the apimatic-calculator-test-sdk-sdk gem](https://rubygems.org/gems/apimatic-calculator-test-sdk-sdk/versions/0.0.2).
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,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,41 @@
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
+ end
40
+ end
41
+ 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 [String] 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,10 @@
1
+ # apimatic_calculator
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://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 v2.0
4
+ # ( https://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 v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module ApimaticCalculator
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
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
+ 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
+