jescie-house-sdk 1.2.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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +76 -0
  4. data/lib/cypress_test_api/api_helper.rb +10 -0
  5. data/lib/cypress_test_api/client.rb +46 -0
  6. data/lib/cypress_test_api/configuration.rb +100 -0
  7. data/lib/cypress_test_api/controllers/api_controller.rb +102 -0
  8. data/lib/cypress_test_api/controllers/base_controller.rb +60 -0
  9. data/lib/cypress_test_api/exceptions/api_exception.rb +21 -0
  10. data/lib/cypress_test_api/http/http_call_back.rb +10 -0
  11. data/lib/cypress_test_api/http/http_method_enum.rb +10 -0
  12. data/lib/cypress_test_api/http/http_request.rb +10 -0
  13. data/lib/cypress_test_api/http/http_response.rb +10 -0
  14. data/lib/cypress_test_api/models/base_model.rb +110 -0
  15. data/lib/cypress_test_api/models/custom_enum.rb +26 -0
  16. data/lib/cypress_test_api/models/deer.rb +68 -0
  17. data/lib/cypress_test_api/models/item.rb +166 -0
  18. data/lib/cypress_test_api/models/item_response.rb +80 -0
  19. data/lib/cypress_test_api/models/lion.rb +68 -0
  20. data/lib/cypress_test_api/models/message.rb +68 -0
  21. data/lib/cypress_test_api/models/message2.rb +71 -0
  22. data/lib/cypress_test_api/models/multiple_arrays_request.rb +70 -0
  23. data/lib/cypress_test_api/models/nac_tag.rb +265 -0
  24. data/lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb +29 -0
  25. data/lib/cypress_test_api/models/response_http400.rb +62 -0
  26. data/lib/cypress_test_api/models/response_http404.rb +62 -0
  27. data/lib/cypress_test_api/models/status11_enum.rb +26 -0
  28. data/lib/cypress_test_api/models/status1_enum.rb +26 -0
  29. data/lib/cypress_test_api/models/status_enum.rb +26 -0
  30. data/lib/cypress_test_api/models/tokens_request.rb +60 -0
  31. data/lib/cypress_test_api/utilities/date_time_helper.rb +11 -0
  32. data/lib/cypress_test_api/utilities/file_wrapper.rb +28 -0
  33. data/lib/cypress_test_api.rb +54 -0
  34. data/test/controllers/controller_test_base.rb +29 -0
  35. data/test/controllers/test_api_controller.rb +40 -0
  36. data/test/http_response_catcher.rb +19 -0
  37. metadata +148 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 656f10dcbfa4b0370d37fdab5e2f5f37f14adbd9b34ce545b8c772bedeec2798
4
+ data.tar.gz: 799d780b7b305dd51cf3a420892213d4a8a63ccd2d69980c4650f60f9d720828
5
+ SHA512:
6
+ metadata.gz: 0a061003c760e226ae32bb728d60b79c6a2a0e9e76c0dfa6154a4a92bb5eb65a737d3d882ee28acd1c0d7a5703188ac607b067c97e7bdf88870b07ad68886d05
7
+ data.tar.gz: 047f5b9ff5a1cabb657b762773abb8f9ce546dc51f3aad55ef6398be21da7f6df0381c4511c4be8330196f3e6de622fdfe20f9177fc9c03758e9cb080b5a23d9
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 - 2025 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,76 @@
1
+
2
+ # Getting Started with Cypress Test API
3
+
4
+ ## Introduction
5
+
6
+ This is a sample API to demonstrate an OpenAPI spec with multiple endpoints and a custom model.
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```bash
13
+ gem install jescie-house-sdk -v 1.2.0
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'jescie-house-sdk', '1.2.0'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the jescie-house-sdk gem](https://rubygems.org/gems/jescie-house-sdk/versions/1.2.0).
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/jescie-house-ruby-sdk/tree/1.2.0/doc/client.md)
35
+
36
+ The following parameters are configurable for the API Client:
37
+
38
+ | Parameter | Type | Description |
39
+ | --- | --- | --- |
40
+ | default_host | `String` | *Default*: `'www.example.com'` |
41
+ | environment | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
42
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
43
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
44
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
45
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
46
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
47
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
48
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
49
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
50
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
51
+
52
+ The API client can be initialized as follows:
53
+
54
+ ```ruby
55
+ client = CypressTestApi::Client.new(
56
+ environment: Environment::PRODUCTION,
57
+ default_host: 'www.example.com'
58
+ )
59
+ ```
60
+
61
+ ## List of APIs
62
+
63
+ * [API](https://www.github.com/ZahraN444/jescie-house-ruby-sdk/tree/1.2.0/doc/controllers/api.md)
64
+
65
+ ## SDK Infrastructure
66
+
67
+ ### HTTP
68
+
69
+ * [HttpResponse](https://www.github.com/ZahraN444/jescie-house-ruby-sdk/tree/1.2.0/doc/http-response.md)
70
+ * [HttpRequest](https://www.github.com/ZahraN444/jescie-house-ruby-sdk/tree/1.2.0/doc/http-request.md)
71
+
72
+ ### Utilities
73
+
74
+ * [ApiHelper](https://www.github.com/ZahraN444/jescie-house-ruby-sdk/tree/1.2.0/doc/api-helper.md)
75
+ * [DateTimeHelper](https://www.github.com/ZahraN444/jescie-house-ruby-sdk/tree/1.2.0/doc/date-time-helper.md)
76
+
@@ -0,0 +1,10 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,46 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # cypress_test_api client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config
11
+
12
+ # Access to client controller.
13
+ # @return [APIController] Returns the controller instance.
14
+ def client
15
+ @client ||= APIController.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, default_host: 'www.example.com',
24
+ config: nil
25
+ )
26
+ @config = if config.nil?
27
+ Configuration.new(connection: connection, adapter: adapter,
28
+ timeout: timeout, max_retries: max_retries,
29
+ retry_interval: retry_interval,
30
+ backoff_factor: backoff_factor,
31
+ retry_statuses: retry_statuses,
32
+ retry_methods: retry_methods,
33
+ http_callback: http_callback,
34
+ environment: environment,
35
+ default_host: default_host)
36
+ else
37
+ config
38
+ end
39
+
40
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
41
+ .base_uri_executor(@config.method(:get_base_uri))
42
+ .global_errors(BaseController::GLOBAL_ERRORS)
43
+ .user_agent(BaseController.user_agent)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,100 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+ end
13
+
14
+ # An enum for API servers.
15
+ class Server
16
+ SERVER = [
17
+ DEFAULT = 'default'.freeze
18
+ ].freeze
19
+ end
20
+
21
+ # All configuration including auth info and base URI for the API access
22
+ # are configured in this class.
23
+ class Configuration < CoreLibrary::HttpClientConfiguration
24
+ # The attribute readers for properties.
25
+ attr_reader :environment, :default_host
26
+
27
+ class << self
28
+ attr_reader :environments
29
+ end
30
+
31
+ def initialize(
32
+ 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, default_host: 'www.example.com'
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
+ # defaultHost value
47
+ @default_host = default_host
48
+
49
+ # The Http Client to use for making requests.
50
+ set_http_client CoreLibrary::FaradayClient.new(self)
51
+ end
52
+
53
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
54
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
55
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
56
+ environment: nil, default_host: nil)
57
+ connection ||= self.connection
58
+ adapter ||= self.adapter
59
+ timeout ||= self.timeout
60
+ max_retries ||= self.max_retries
61
+ retry_interval ||= self.retry_interval
62
+ backoff_factor ||= self.backoff_factor
63
+ retry_statuses ||= self.retry_statuses
64
+ retry_methods ||= self.retry_methods
65
+ http_callback ||= self.http_callback
66
+ environment ||= self.environment
67
+ default_host ||= self.default_host
68
+
69
+ Configuration.new(connection: connection, adapter: adapter,
70
+ timeout: timeout, max_retries: max_retries,
71
+ retry_interval: retry_interval,
72
+ backoff_factor: backoff_factor,
73
+ retry_statuses: retry_statuses,
74
+ retry_methods: retry_methods,
75
+ http_callback: http_callback, environment: environment,
76
+ default_host: default_host)
77
+ end
78
+
79
+
80
+ # All the environments the SDK can run in.
81
+ ENVIRONMENTS = {
82
+ Environment::PRODUCTION => {
83
+ Server::DEFAULT => 'https://{defaultHost}'
84
+ }
85
+ }.freeze
86
+
87
+ # Generates the appropriate base URI for the environment and the server.
88
+ # @param [Configuration::Server] server The server enum for which the base URI is
89
+ # required.
90
+ # @return [String] The base URI.
91
+ def get_base_uri(server = Server::DEFAULT)
92
+ parameters = {
93
+ 'defaultHost' => { 'value' => default_host, 'encode' => false }
94
+ }
95
+ APIHelper.append_url_with_template_parameters(
96
+ ENVIRONMENTS[environment][server], parameters
97
+ )
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,102 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # APIController
8
+ class APIController < BaseController
9
+ # Creates a new resource in the system.
10
+ # @param [Status11Enum] status Required parameter: The status of the items
11
+ # to filter by.
12
+ # @param [Item] body Optional parameter: Custom model with additional
13
+ # properties
14
+ # @return [Object] Response from the API call.
15
+ def createanitem(status,
16
+ body: nil)
17
+ @api_call
18
+ .request(new_request_builder(HttpMethodEnum::POST,
19
+ '/items/{status}',
20
+ Server::DEFAULT)
21
+ .template_param(new_parameter(status, key: 'status')
22
+ .should_encode(true))
23
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
24
+ .body_param(new_parameter(body))
25
+ .header_param(new_parameter('application/json', key: 'accept'))
26
+ .body_serializer(proc do |param| param.to_json unless param.nil? end))
27
+ .response(new_response_handler
28
+ .deserializer(APIHelper.method(:json_deserialize))
29
+ .local_error('400',
30
+ 'Bad Syntax',
31
+ APIException)
32
+ .local_error('401',
33
+ 'Unauthorized',
34
+ APIException)
35
+ .local_error('403',
36
+ 'Permission Denied',
37
+ APIException))
38
+ .execute
39
+ end
40
+
41
+ # TODO: type endpoint description here
42
+ # @param [String] id Required parameter: The ID of the item to retrieve
43
+ # @param [String] value Required parameter: The value of the item to
44
+ # retrieve
45
+ # @return [Item] Response from the API call.
46
+ def getanitemby_id(id,
47
+ value)
48
+ @api_call
49
+ .request(new_request_builder(HttpMethodEnum::GET,
50
+ '/items/{id}',
51
+ Server::DEFAULT)
52
+ .template_param(new_parameter(id, key: 'id')
53
+ .should_encode(true))
54
+ .query_param(new_parameter(value, key: 'value'))
55
+ .header_param(new_parameter('application/json', key: 'accept')))
56
+ .response(new_response_handler
57
+ .deserializer(APIHelper.method(:custom_type_deserializer))
58
+ .deserialize_into(Item.method(:from_hash)))
59
+ .execute
60
+ end
61
+
62
+ # Generates a new OAuth token with the specified scopes.
63
+ # @param [TokensRequest] body Optional parameter: TODO: type description
64
+ # here
65
+ # @return [void] Response from the API call.
66
+ def create_o_auth_token(body: nil)
67
+ @api_call
68
+ .request(new_request_builder(HttpMethodEnum::POST,
69
+ '/tokens',
70
+ Server::DEFAULT)
71
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
72
+ .body_param(new_parameter(body))
73
+ .body_serializer(proc do |param| param.to_json unless param.nil? end))
74
+ .response(new_response_handler
75
+ .is_response_void(true)
76
+ .local_error('400',
77
+ 'Bad request',
78
+ APIException))
79
+ .execute
80
+ end
81
+
82
+ # This endpoint accepts a complex structure with multiple arrays.
83
+ # @param [MultipleArraysRequest] body Optional parameter: TODO: type
84
+ # description here
85
+ # @return [void] Response from the API call.
86
+ def test_endpointwith_arrays(body: nil)
87
+ @api_call
88
+ .request(new_request_builder(HttpMethodEnum::POST,
89
+ '/multiple-arrays',
90
+ Server::DEFAULT)
91
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
92
+ .body_param(new_parameter(body))
93
+ .body_serializer(proc do |param| param.to_json unless param.nil? end))
94
+ .response(new_response_handler
95
+ .is_response_void(true)
96
+ .local_error('400',
97
+ 'Bad request',
98
+ APIException))
99
+ .execute
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,60 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
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,21 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
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
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
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
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end
@@ -0,0 +1,110 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
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,26 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CypressTestApi
7
+ # CustomEnum.
8
+ class CustomEnum
9
+ CUSTOM_ENUM = [
10
+ # TODO: Write general description for VALUE1
11
+ VALUE1 = 'VALUE1'.freeze,
12
+
13
+ # TODO: Write general description for VALUE2
14
+ VALUE2 = 'VALUE2'.freeze,
15
+
16
+ # TODO: Write general description for VALUE3
17
+ VALUE3 = 'VALUE3'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ CUSTOM_ENUM.include?(value)
24
+ end
25
+ end
26
+ end