From 4c8f0f5fd64a46f4e4815764be3ffb677be425db Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Mon, 30 Aug 2021 14:00:01 -0700 Subject: [PATCH] Update to generator 5.2.1 (#36) * Update to generator 5.0.0 * 5.1.0 * Test with standard for model generic * Re-add partial * Bite some bullets * Remove custom template * Generate version automatically * 5.2.1 * Things * Fix missing_method * Fix error message * Update version * Update changelog * Remove explicit json dependency * Update CHANGELOG.md Co-authored-by: James Klein Co-authored-by: James Klein --- CHANGELOG.md | 6 + Gemfile | 3 +- Gemfile.lock | 45 +++--- lib/patch_ruby.rb | 2 +- lib/patch_ruby/api/estimates_api.rb | 58 ++++---- lib/patch_ruby/api/orders_api.rb | 37 ++--- lib/patch_ruby/api/preferences_api.rb | 30 ++-- lib/patch_ruby/api/projects_api.rb | 16 ++- lib/patch_ruby/api_client.rb | 100 +++++++------- lib/patch_ruby/api_error.rb | 2 +- lib/patch_ruby/configuration.rb | 47 +++++-- lib/patch_ruby/models/allocation.rb | 32 +++-- .../models/create_bitcoin_estimate_request.rb | 44 +++--- .../create_ethereum_estimate_request.rb | 47 ++++--- .../models/create_mass_estimate_request.rb | 35 +++-- lib/patch_ruby/models/create_order_request.rb | 32 +++-- .../models/create_preference_request.rb | 32 +++-- lib/patch_ruby/models/error_response.rb | 35 +++-- lib/patch_ruby/models/estimate.rb | 35 +++-- .../models/estimate_list_response.rb | 35 +++-- lib/patch_ruby/models/estimate_response.rb | 35 +++-- lib/patch_ruby/models/meta_index_object.rb | 38 ++++-- lib/patch_ruby/models/order.rb | 38 ++++-- lib/patch_ruby/models/order_list_response.rb | 35 +++-- lib/patch_ruby/models/order_response.rb | 35 +++-- lib/patch_ruby/models/photo.rb | 32 +++-- lib/patch_ruby/models/preference.rb | 32 +++-- .../models/preference_list_response.rb | 35 +++-- lib/patch_ruby/models/preference_response.rb | 35 +++-- lib/patch_ruby/models/project.rb | 41 +++--- .../models/project_list_response.rb | 35 +++-- lib/patch_ruby/models/project_response.rb | 35 +++-- lib/patch_ruby/models/sdg.rb | 32 +++-- lib/patch_ruby/models/standard.rb | 32 +++-- lib/patch_ruby/version.rb | 4 +- patch_ruby.gemspec | 10 +- spec/api_client_spec.rb | 47 +++++-- spec/configuration_spec.rb | 2 +- spec/integration/preferences_spec.rb | 2 +- .../create_mass_estimate_request_spec.rb | 2 +- spec/models/error_response_spec.rb | 2 +- spec/models/estimate_list_response_spec.rb | 2 +- spec/models/estimate_response_spec.rb | 2 +- spec/models/estimate_spec.rb | 2 +- spec/models/meta_index_object_spec.rb | 2 +- spec/models/order_list_response_spec.rb | 2 +- spec/models/order_response_spec.rb | 2 +- spec/models/order_spec.rb | 2 +- spec/models/preference_list_response_spec.rb | 2 +- spec/models/preference_response_spec.rb | 2 +- spec/models/project_list_response_spec.rb | 2 +- spec/models/project_response_spec.rb | 2 +- spec/models/project_spec.rb | 2 +- spec/spec_helper.rb | 129 +++++++++--------- 54 files changed, 835 insertions(+), 550 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91a394f..8964974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.10.0] - 2021-08-27 + +### Added + +- Adds custom User-Agent header + ## [1.9.0] - 2021-08-17 ### Added diff --git a/Gemfile b/Gemfile index 76018c7..c2e3127 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,5 @@ gemspec group :development, :test do gem 'rake', '~> 13.0.1' gem 'pry-byebug' - gem 'rubocop' - gem 'factory_bot' + gem 'rubocop', '~> 0.66.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 31a2694..97b2324 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,36 +1,35 @@ PATH remote: . specs: - patch_ruby (1.9.0) - json (~> 2.1, >= 2.1.0) + patch_ruby (1.10.0) typhoeus (~> 1.0, >= 1.0.1) GEM remote: https://rubygems.org/ specs: - activesupport (6.1.1) + activesupport (6.1.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - ast (2.4.1) + ast (2.4.2) byebug (11.1.3) coderay (1.1.3) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.9) diff-lcs (1.4.3) ethon (0.14.0) ffi (>= 1.15.0) - factory_bot (6.1.0) + factory_bot (6.2.0) activesupport (>= 5.0.0) ffi (1.15.3) - i18n (1.8.7) + i18n (1.8.10) concurrent-ruby (~> 1.0) - json (2.5.1) + jaro_winkler (1.5.4) method_source (1.0.0) - minitest (5.14.3) - parallel (1.19.2) - parser (2.7.1.4) + minitest (5.14.4) + parallel (1.20.1) + parser (3.0.2.0) ast (~> 2.4.1) pry (0.13.1) coderay (~> 1.1) @@ -38,10 +37,9 @@ GEM pry-byebug (3.9.0) byebug (~> 11.0) pry (~> 0.13.0) + psych (4.0.1) rainbow (3.0.0) rake (13.0.1) - regexp_parser (1.7.1) - rexml (3.2.4) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) @@ -55,35 +53,32 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-support (3.9.3) - rubocop (0.88.0) + rubocop (0.66.0) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.7.1.1) + parser (>= 2.5, != 2.5.1.1) + psych (>= 3.1.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) - rexml - rubocop-ast (>= 0.1.0, < 1.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (0.3.0) - parser (>= 2.7.1.4) - ruby-progressbar (1.10.1) + unicode-display_width (>= 1.4.0, < 1.6) + ruby-progressbar (1.11.0) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - unicode-display_width (1.7.0) + unicode-display_width (1.5.0) zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES - factory_bot + factory_bot (~> 6.2) patch_ruby! pry-byebug rake (~> 13.0.1) rspec (~> 3.6, >= 3.6.0) - rubocop + rubocop (~> 0.66.0) BUNDLED WITH 2.2.14 diff --git a/lib/patch_ruby.rb b/lib/patch_ruby.rb index 520e35a..34c5133 100644 --- a/lib/patch_ruby.rb +++ b/lib/patch_ruby.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end diff --git a/lib/patch_ruby/api/estimates_api.rb b/lib/patch_ruby/api/estimates_api.rb index 1c81b11..a6ab02a 100644 --- a/lib/patch_ruby/api/estimates_api.rb +++ b/lib/patch_ruby/api/estimates_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -70,15 +70,16 @@ def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_bitcoin_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_bitcoin_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_bitcoin_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -134,15 +135,16 @@ def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, op form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_ethereum_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_ethereum_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_ethereum_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -198,15 +200,16 @@ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_flight_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_flight_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_flight_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -262,15 +265,16 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_mass_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_mass_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_mass_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -326,15 +330,16 @@ def create_shipping_estimate_with_http_info(create_shipping_estimate_request, op form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_shipping_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_shipping_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_shipping_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -390,15 +395,16 @@ def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_vehicle_estimate_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_vehicle_estimate_request) # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.create_vehicle_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -452,15 +458,16 @@ def retrieve_estimate_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'EstimateResponse' + return_type = opts[:debug_return_type] || 'EstimateResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.retrieve_estimate", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -511,15 +518,16 @@ def retrieve_estimates_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'EstimateListResponse' + return_type = opts[:debug_return_type] || 'EstimateListResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"EstimatesApi.retrieve_estimates", :header_params => header_params, :query_params => query_params, :form_params => form_params, diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index 901c8ad..18cba61 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -65,15 +65,16 @@ def cancel_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:debug_return_type] || 'OrderResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"OrdersApi.cancel_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -129,15 +130,16 @@ def create_order_with_http_info(create_order_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_order_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_order_request) # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:debug_return_type] || 'OrderResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"OrdersApi.create_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -191,15 +193,16 @@ def place_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:debug_return_type] || 'OrderResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"OrdersApi.place_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -253,15 +256,16 @@ def retrieve_order_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'OrderResponse' + return_type = opts[:debug_return_type] || 'OrderResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"OrdersApi.retrieve_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -321,15 +325,16 @@ def retrieve_orders_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'OrderListResponse' + return_type = opts[:debug_return_type] || 'OrderListResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"OrdersApi.retrieve_orders", :header_params => header_params, :query_params => query_params, :form_params => form_params, diff --git a/lib/patch_ruby/api/preferences_api.rb b/lib/patch_ruby/api/preferences_api.rb index 4d3f868..facc61a 100644 --- a/lib/patch_ruby/api/preferences_api.rb +++ b/lib/patch_ruby/api/preferences_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -66,15 +66,16 @@ def create_preference_with_http_info(create_preference_request, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] || @api_client.object_to_http_body(create_preference_request) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_preference_request) # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:debug_return_type] || 'PreferenceResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"PreferencesApi.create_preference", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -128,15 +129,16 @@ def delete_preference_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:debug_return_type] || 'PreferenceResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"PreferencesApi.delete_preference", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -190,15 +192,16 @@ def retrieve_preference_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'PreferenceResponse' + return_type = opts[:debug_return_type] || 'PreferenceResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"PreferencesApi.retrieve_preference", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -249,15 +252,16 @@ def retrieve_preferences_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'PreferenceListResponse' + return_type = opts[:debug_return_type] || 'PreferenceListResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"PreferencesApi.retrieve_preferences", :header_params => header_params, :query_params => query_params, :form_params => form_params, diff --git a/lib/patch_ruby/api/projects_api.rb b/lib/patch_ruby/api/projects_api.rb index 15b05c7..02bb7f6 100644 --- a/lib/patch_ruby/api/projects_api.rb +++ b/lib/patch_ruby/api/projects_api.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -62,15 +62,16 @@ def retrieve_project_with_http_info(id, opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'ProjectResponse' + return_type = opts[:debug_return_type] || 'ProjectResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"ProjectsApi.retrieve_project", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -130,15 +131,16 @@ def retrieve_projects_with_http_info(opts = {}) form_params = opts[:form_params] || {} # http body (model) - post_body = opts[:body] + post_body = opts[:debug_body] # return_type - return_type = opts[:return_type] || 'ProjectListResponse' + return_type = opts[:debug_return_type] || 'ProjectListResponse' # auth_names - auth_names = opts[:auth_names] || ['bearer_auth'] + auth_names = opts[:debug_auth_names] || ['bearer_auth'] new_options = opts.merge( + :operation => :"ProjectsApi.retrieve_projects", :header_params => header_params, :query_params => query_params, :form_params => form_params, diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 517be7d..74c1f4f 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -14,6 +14,7 @@ require 'json' require 'logger' require 'tempfile' +require 'time' require 'typhoeus' module Patch @@ -30,7 +31,7 @@ class ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config - @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" + @user_agent = "patch-ruby/1.10.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent @@ -86,7 +87,7 @@ def call_api(http_method, path, opts = {}) # @option opts [Object] :body HTTP body (JSON/XML) # @return [Typhoeus::Request] A Typhoeus Request def build_request(http_method, path, opts = {}) - url = build_request_url(path) + url = build_request_url(path, opts) http_method = http_method.to_sym.downcase header_params = @default_headers.merge(opts[:header_params] || {}) @@ -155,6 +156,44 @@ def build_request_body(header_params, form_params, body) data end + # Save response body into a file in (the defined) temporary folder, using the filename + # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. + # + # @see Configuration#temp_folder_path + def download_file(request) + tempfile = nil + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |response| + if tempfile + tempfile.close + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" + end + end + end + # Check if the given MIME is a JSON MIME. # JSON MIME examples: # application/json @@ -191,7 +230,7 @@ def deserialize(response, return_type) begin data = JSON.parse("[#{body}]", :symbolize_names => true)[0] rescue JSON::ParserError => e - if %w(String Date DateTime).include?(return_type) + if %w(String Date Time).include?(return_type) data = body else raise e @@ -216,9 +255,9 @@ def convert_to_type(data, return_type) data.to_f when 'Boolean' data == true - when 'DateTime' + when 'Time' # parse date time (expecting ISO 8601 format) - DateTime.parse data + Time.parse data when 'Date' # parse date time (expecting ISO 8601 format) Date.parse data @@ -236,46 +275,9 @@ def convert_to_type(data, return_type) data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } end else - # models, e.g. Pet - Patch.const_get(return_type).build_from_hash(data) - end - end - - # Save response body into a file in (the defined) temporary folder, using the filename - # from the "Content-Disposition" header if provided, otherwise a random filename. - # The response body is written to the file in chunks in order to handle files which - # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby - # process can use. - # - # @see Configuration#temp_folder_path - def download_file(request) - tempfile = nil - encoding = nil - request.on_headers do |response| - content_disposition = response.headers['Content-Disposition'] - if content_disposition && content_disposition =~ /filename=/i - filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] - prefix = sanitize_filename(filename) - else - prefix = 'download-' - end - prefix = prefix + '-' unless prefix.end_with?('-') - encoding = response.body.encoding - tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) - @tempfile = tempfile - end - request.on_body do |chunk| - chunk.force_encoding(encoding) - tempfile.write(chunk) - end - request.on_complete do |response| - if tempfile - tempfile.close - @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ - "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ - "will be deleted automatically with GC. It's also recommended to delete the temp file "\ - "explicitly with `tempfile.delete`" - end + # models (e.g. Pet) or oneOf + klass = Patch.const_get(return_type) + klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) end end @@ -288,10 +290,10 @@ def sanitize_filename(filename) filename.gsub(/.*[\/\\]/, '') end - def build_request_url(path) + def build_request_url(path, opts = {}) # Add leading and trailing slashes to path path = "/#{path}".gsub(/\/+/, '/') - @config.base_url + path + @config.base_url(opts[:operation]) + path end # Update hearder and query params based on authentication settings. @@ -306,7 +308,7 @@ def update_params_for_auth!(header_params, query_params, auth_names) case auth_setting[:in] when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] - else fail ArgumentError, 'Authentication token must be in `query` of `header`' + else fail ArgumentError, 'Authentication token must be in `query` or `header`' end end end diff --git a/lib/patch_ruby/api_error.rb b/lib/patch_ruby/api_error.rb index 611c81e..0966543 100644 --- a/lib/patch_ruby/api_error.rb +++ b/lib/patch_ruby/api_error.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end diff --git a/lib/patch_ruby/configuration.rb b/lib/patch_ruby/configuration.rb index 641dc97..b5dc452 100644 --- a/lib/patch_ruby/configuration.rb +++ b/lib/patch_ruby/configuration.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -21,6 +21,18 @@ class Configuration # Defines url base path attr_accessor :base_path + # Define server configuration index + attr_accessor :server_index + + # Define server operation configuration index + attr_accessor :server_operation_index + + # Default server variables + attr_accessor :server_variables + + # Default server operation variables + attr_accessor :server_operation_variables + # Defines API keys used with API Key authentications. # # @return [Hash] key: parameter name, value: parameter value (API key) @@ -129,6 +141,10 @@ def initialize @scheme = 'https' @host = 'api.patch.io' @base_path = '' + @server_index = 0 + @server_operation_index = {} + @server_variables = {} + @server_operation_variables = {} @api_key = {} @api_key_prefix = {} @timeout = 0 @@ -171,17 +187,23 @@ def base_path=(base_path) @base_path = '' if @base_path == '/' end - def base_url - "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') + # Returns base URL for specified operation based on server settings + def base_url(operation = nil) + index = server_operation_index.fetch(operation, server_index) + return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil + + server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) end # Gets API key (with prefix if set). # @param [String] param_name the parameter name of API key auth - def api_key_with_prefix(param_name) + def api_key_with_prefix(param_name, param_alias = nil) + key = @api_key[param_name] + key = @api_key.fetch(param_alias, key) unless param_alias.nil? if @api_key_prefix[param_name] - "#{@api_key_prefix[param_name]} #{@api_key[param_name]}" + "#{@api_key_prefix[param_name]} #{key}" else - @api_key[param_name] + key end end @@ -219,12 +241,17 @@ def server_settings ] end + def operation_server_settings + { + } + end + # Returns URL based on server settings # # @param index array index of the server settings # @param variables hash of variable and the corresponding value - def server_url(index, variables = {}) - servers = server_settings + def server_url(index, variables = {}, servers = nil) + servers = server_settings if servers == nil # check array index out of bound if (index < 0 || index >= servers.size) @@ -234,10 +261,12 @@ def server_url(index, variables = {}) server = servers[index] url = server[:url] + return url unless server.key? :variables + # go through variable and assign a value server[:variables].each do |name, variable| if variables.key?(name) - if (server[:variables][name][:enum_values].include? variables[name]) + if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) url.gsub! "{" + name.to_s + "}", variables[name] else fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." diff --git a/lib/patch_ruby/models/allocation.rb b/lib/patch_ruby/models/allocation.rb index 47d40b8..5981ce8 100644 --- a/lib/patch_ruby/models/allocation.rb +++ b/lib/patch_ruby/models/allocation.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Allocation @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -41,13 +47,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -150,7 +156,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -158,7 +166,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -170,8 +178,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -201,7 +209,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -227,7 +237,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_bitcoin_estimate_request.rb b/lib/patch_ruby/models/create_bitcoin_estimate_request.rb index 6ef64aa..6dbc564 100644 --- a/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +++ b/lib/patch_ruby/models/create_bitcoin_estimate_request.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class CreateBitcoinEstimateRequest @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,21 +48,17 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("timestamp") - - nullable_properties.add("transaction_value_btc_sats") - - nullable_properties.add("project_id") - - nullable_properties.add("create_order") - - nullable_properties + Set.new([ + :'timestamp', + :'transaction_value_btc_sats', + :'project_id', + :'create_order' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -149,7 +151,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -157,7 +161,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -169,8 +173,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -200,7 +204,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -226,7 +232,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_ethereum_estimate_request.rb b/lib/patch_ruby/models/create_ethereum_estimate_request.rb index b5d30bf..6593eac 100644 --- a/lib/patch_ruby/models/create_ethereum_estimate_request.rb +++ b/lib/patch_ruby/models/create_ethereum_estimate_request.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class CreateEthereumEstimateRequest @@ -35,6 +36,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -46,23 +52,18 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("timestamp") - - nullable_properties.add("gas_used") - - nullable_properties.add("transaction_value_eth_gwei") - - nullable_properties.add("project_id") - - nullable_properties.add("create_order") - - nullable_properties + Set.new([ + :'timestamp', + :'gas_used', + :'transaction_value_eth_gwei', + :'project_id', + :'create_order' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -160,7 +161,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -168,7 +171,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -180,8 +183,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -211,7 +214,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -237,7 +242,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_mass_estimate_request.rb b/lib/patch_ruby/models/create_mass_estimate_request.rb index 0646ba9..ba169a2 100644 --- a/lib/patch_ruby/models/create_mass_estimate_request.rb +++ b/lib/patch_ruby/models/create_mass_estimate_request.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class CreateMassEstimateRequest @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("create_order") - - nullable_properties + Set.new([ + :'create_order', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -167,7 +172,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -175,7 +182,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -187,8 +194,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -218,7 +225,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -244,7 +253,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_order_request.rb b/lib/patch_ruby/models/create_order_request.rb index 127efbc..db38a97 100644 --- a/lib/patch_ruby/models/create_order_request.rb +++ b/lib/patch_ruby/models/create_order_request.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class CreateOrderRequest @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,13 +48,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -180,7 +186,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -188,7 +196,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -200,8 +208,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -231,7 +239,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -257,7 +267,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/create_preference_request.rb b/lib/patch_ruby/models/create_preference_request.rb index d069ac7..51cbc73 100644 --- a/lib/patch_ruby/models/create_preference_request.rb +++ b/lib/patch_ruby/models/create_preference_request.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class CreatePreferenceRequest @@ -23,6 +24,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -30,13 +36,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -119,7 +125,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -127,7 +135,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -139,8 +147,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -170,7 +178,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -196,7 +206,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/error_response.rb b/lib/patch_ruby/models/error_response.rb index dd0ff95..8d73d5d 100644 --- a/lib/patch_ruby/models/error_response.rb +++ b/lib/patch_ruby/models/error_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class ErrorResponse @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("data") - - nullable_properties + Set.new([ + :'data' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -144,7 +149,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -152,7 +159,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -164,8 +171,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -195,7 +202,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -221,7 +230,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate.rb b/lib/patch_ruby/models/estimate.rb index 3ab7b3d..cec5f22 100644 --- a/lib/patch_ruby/models/estimate.rb +++ b/lib/patch_ruby/models/estimate.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Estimate @@ -40,6 +41,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -51,15 +57,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("order") - - nullable_properties + Set.new([ + :'order' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -172,7 +177,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -180,7 +187,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -192,8 +199,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -223,7 +230,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -249,7 +258,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate_list_response.rb b/lib/patch_ruby/models/estimate_list_response.rb index 8762d98..217d901 100644 --- a/lib/patch_ruby/models/estimate_list_response.rb +++ b/lib/patch_ruby/models/estimate_list_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class EstimateListResponse @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,15 +48,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -160,7 +165,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -168,7 +175,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -180,8 +187,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -211,7 +218,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -237,7 +246,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/estimate_response.rb b/lib/patch_ruby/models/estimate_response.rb index bc36f5f..ddb7103 100644 --- a/lib/patch_ruby/models/estimate_response.rb +++ b/lib/patch_ruby/models/estimate_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class EstimateResponse @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -144,7 +149,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -152,7 +159,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -164,8 +171,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -195,7 +202,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -221,7 +230,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/meta_index_object.rb b/lib/patch_ruby/models/meta_index_object.rb index 5eac744..9ae86a4 100644 --- a/lib/patch_ruby/models/meta_index_object.rb +++ b/lib/patch_ruby/models/meta_index_object.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class MetaIndexObject @@ -26,6 +27,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -34,17 +40,15 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("prev_page") - - nullable_properties.add("next_page") - - nullable_properties + Set.new([ + :'prev_page', + :'next_page' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -127,7 +131,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -135,7 +141,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -147,8 +153,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -178,7 +184,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -204,7 +212,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order.rb b/lib/patch_ruby/models/order.rb index 57a232a..5cc67a4 100644 --- a/lib/patch_ruby/models/order.rb +++ b/lib/patch_ruby/models/order.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Order @@ -82,6 +83,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -98,17 +104,15 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("price_cents_usd") - - nullable_properties.add("patch_fee_cents_usd") - - nullable_properties + Set.new([ + :'price_cents_usd', + :'patch_fee_cents_usd', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -320,7 +324,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -328,7 +334,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -340,8 +346,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -371,7 +377,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -397,7 +405,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order_list_response.rb b/lib/patch_ruby/models/order_list_response.rb index 5786b7c..d39f4e3 100644 --- a/lib/patch_ruby/models/order_list_response.rb +++ b/lib/patch_ruby/models/order_list_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class OrderListResponse @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,15 +48,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -160,7 +165,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -168,7 +175,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -180,8 +187,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -211,7 +218,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -237,7 +246,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/order_response.rb b/lib/patch_ruby/models/order_response.rb index f42405a..5618c8e 100644 --- a/lib/patch_ruby/models/order_response.rb +++ b/lib/patch_ruby/models/order_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class OrderResponse @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -144,7 +149,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -152,7 +159,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -164,8 +171,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -195,7 +202,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -221,7 +230,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/photo.rb b/lib/patch_ruby/models/photo.rb index 81b69db..d890173 100644 --- a/lib/patch_ruby/models/photo.rb +++ b/lib/patch_ruby/models/photo.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Photo @@ -26,6 +27,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -34,13 +40,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -133,7 +139,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -141,7 +149,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -153,8 +161,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -184,7 +192,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -210,7 +220,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference.rb b/lib/patch_ruby/models/preference.rb index 48678c6..3614209 100644 --- a/lib/patch_ruby/models/preference.rb +++ b/lib/patch_ruby/models/preference.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Preference @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -41,13 +47,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -150,7 +156,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -158,7 +166,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -170,8 +178,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -201,7 +209,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -227,7 +237,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference_list_response.rb b/lib/patch_ruby/models/preference_list_response.rb index 94ff4fc..0e19bc8 100644 --- a/lib/patch_ruby/models/preference_list_response.rb +++ b/lib/patch_ruby/models/preference_list_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class PreferenceListResponse @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,15 +48,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -160,7 +165,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -168,7 +175,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -180,8 +187,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -211,7 +218,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -237,7 +246,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/preference_response.rb b/lib/patch_ruby/models/preference_response.rb index b3af523..e53a99b 100644 --- a/lib/patch_ruby/models/preference_response.rb +++ b/lib/patch_ruby/models/preference_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class PreferenceResponse @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -144,7 +149,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -152,7 +159,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -164,8 +171,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -195,7 +202,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -221,7 +230,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project.rb b/lib/patch_ruby/models/project.rb index 3e76d2b..bc94974 100644 --- a/lib/patch_ruby/models/project.rb +++ b/lib/patch_ruby/models/project.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Project @@ -90,6 +91,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -108,19 +114,16 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("photos") - - nullable_properties.add("standard") - - nullable_properties.add("sdgs") - - nullable_properties + Set.new([ + :'photos', + :'standard', + :'sdgs' + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -309,7 +312,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -317,7 +322,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -329,8 +334,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -360,7 +365,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -386,7 +393,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project_list_response.rb b/lib/patch_ruby/models/project_list_response.rb index c3ccb92..344f257 100644 --- a/lib/patch_ruby/models/project_list_response.rb +++ b/lib/patch_ruby/models/project_list_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class ProjectListResponse @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -42,15 +48,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -160,7 +165,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -168,7 +175,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -180,8 +187,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -211,7 +218,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -237,7 +246,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/project_response.rb b/lib/patch_ruby/models/project_response.rb index 96cb48b..462171a 100644 --- a/lib/patch_ruby/models/project_response.rb +++ b/lib/patch_ruby/models/project_response.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class ProjectResponse @@ -29,6 +30,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -38,15 +44,14 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("error") - - nullable_properties + Set.new([ + :'error', + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -144,7 +149,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -152,7 +159,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -164,8 +171,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -195,7 +202,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -221,7 +230,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/sdg.rb b/lib/patch_ruby/models/sdg.rb index 3258317..18c73bb 100644 --- a/lib/patch_ruby/models/sdg.rb +++ b/lib/patch_ruby/models/sdg.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Sdg @@ -36,6 +37,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -46,13 +52,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -165,7 +171,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -173,7 +181,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -185,8 +193,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -216,7 +224,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -242,7 +252,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/models/standard.rb b/lib/patch_ruby/models/standard.rb index 04a9cf1..c7925eb 100644 --- a/lib/patch_ruby/models/standard.rb +++ b/lib/patch_ruby/models/standard.rb @@ -6,11 +6,12 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end require 'date' +require 'time' module Patch class Standard @@ -32,6 +33,11 @@ def self.attribute_map } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { @@ -41,13 +47,13 @@ def self.openapi_types } end - # Set with nullable attributes. + # List of attributes with nullable: true def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties + Set.new([ + ]) end + # Allows models with corresponding API classes to delegate API operations to those API classes # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order @@ -150,7 +156,9 @@ def self.build_from_hash(attributes) def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) @@ -158,7 +166,7 @@ def build_from_hash(attributes) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + end end self @@ -170,8 +178,8 @@ def build_from_hash(attributes) # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String @@ -201,7 +209,9 @@ def _deserialize(type, value) end end else # model - Patch.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end @@ -227,7 +237,7 @@ def to_hash is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index f992fe1..1fc616e 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -6,10 +6,10 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end module Patch - VERSION = '1.9.0' + VERSION = '1.10.0' end diff --git a/patch_ruby.gemspec b/patch_ruby.gemspec index a08f74f..b9298b8 100644 --- a/patch_ruby.gemspec +++ b/patch_ruby.gemspec @@ -8,7 +8,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end @@ -24,11 +24,10 @@ Gem::Specification.new do |s| s.homepage = "https://www.patch.io" s.summary = "Ruby wrapper for the Patch API" s.description = "Ruby wrapper for the Patch API" - s.license = 'MIT' + s.license = "MIT" s.required_ruby_version = ">= 1.9" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' - s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' @@ -36,4 +35,9 @@ Gem::Specification.new do |s| s.test_files = `find spec/*`.split("\n") s.executables = [] s.require_paths = ["lib"] + + # Start custom + s.add_development_dependency 'factory_bot', '~> 6.2' + # End custom + end diff --git a/spec/api_client_spec.rb b/spec/api_client_spec.rb index 323a5bf..fc99edf 100644 --- a/spec/api_client_spec.rb +++ b/spec/api_client_spec.rb @@ -6,26 +6,47 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end +require 'spec_helper' + describe Patch::ApiClient do context 'initialization' do - context 'base_path' do - it "prepends a slash to base_path" do - Patch.configure { |c| c.base_path = 'v4/dog' } - expect(Patch::Configuration.default.base_path).to eq('/v4/dog') - end - - it "doesn't prepend a slash if one is already there" do - Patch.configure { |c| c.base_path = '/v4/dog' } - expect(Patch::Configuration.default.base_path).to eq('/v4/dog') + context 'URL stuff' do + context 'host' do + it 'removes http from host' do + Patch.configure { |c| c.host = 'http://example.com' } + expect(Patch::Configuration.default.host).to eq('example.com') + end + + it 'removes https from host' do + Patch.configure { |c| c.host = 'https://wookiee.com' } + expect(Patch::ApiClient.default.config.host).to eq('wookiee.com') + end + + it 'removes trailing path from host' do + Patch.configure { |c| c.host = 'hobo.com/v4' } + expect(Patch::Configuration.default.host).to eq('hobo.com') + end end - it "ends up as a blank string if nil" do - Patch.configure { |c| c.base_path = nil } - expect(Patch::Configuration.default.base_path).to eq('') + context 'base_path' do + it "prepends a slash to base_path" do + Patch.configure { |c| c.base_path = 'v4/dog' } + expect(Patch::Configuration.default.base_path).to eq('/v4/dog') + end + + it "doesn't prepend a slash if one is already there" do + Patch.configure { |c| c.base_path = '/v4/dog' } + expect(Patch::Configuration.default.base_path).to eq('/v4/dog') + end + + it "ends up as a blank string if nil" do + Patch.configure { |c| c.base_path = nil } + expect(Patch::Configuration.default.base_path).to eq('') + end end end end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index f9faa7a..1eb0c49 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -6,7 +6,7 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end diff --git a/spec/integration/preferences_spec.rb b/spec/integration/preferences_spec.rb index 55021f6..2802afc 100644 --- a/spec/integration/preferences_spec.rb +++ b/spec/integration/preferences_spec.rb @@ -7,7 +7,7 @@ begin create_preference_response = Patch::Preference.create_preference(project_id: project_id) preference_id = create_preference_response.data.id - rescue => Patch::ApiError + rescue Patch::ApiError => e preference_id = Patch::Preference.retrieve_preferences().data.first.id end diff --git a/spec/models/create_mass_estimate_request_spec.rb b/spec/models/create_mass_estimate_request_spec.rb index 17f5224..4d13bc3 100644 --- a/spec/models/create_mass_estimate_request_spec.rb +++ b/spec/models/create_mass_estimate_request_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g } } - let(:nullable_properties) { Set.new(["create_order"]) } + let(:nullable_properties) { Set.new([:create_order]) } end describe 'test an instance of CreateMassEstimateRequest' do diff --git a/spec/models/error_response_spec.rb b/spec/models/error_response_spec.rb index ca04fbc..732206f 100644 --- a/spec/models/error_response_spec.rb +++ b/spec/models/error_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new(["data"]) } + let(:nullable_properties) { Set.new([:data]) } end describe 'test an instance of ErrorResponse' do diff --git a/spec/models/estimate_list_response_spec.rb b/spec/models/estimate_list_response_spec.rb index 68c2af6..60dd673 100644 --- a/spec/models/estimate_list_response_spec.rb +++ b/spec/models/estimate_list_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of EstimateListResponse' do diff --git a/spec/models/estimate_response_spec.rb b/spec/models/estimate_response_spec.rb index 1d41216..651328d 100644 --- a/spec/models/estimate_response_spec.rb +++ b/spec/models/estimate_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of EstimateResponse' do diff --git a/spec/models/estimate_spec.rb b/spec/models/estimate_spec.rb index 34ddae7..141b094 100644 --- a/spec/models/estimate_spec.rb +++ b/spec/models/estimate_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { id: @instance.id, order: @instance.order.to_hash, production: @instance.production, type: @instance.type } } - let(:nullable_properties) { Set.new(["order"]) } + let(:nullable_properties) { Set.new([:order]) } end describe 'test an instance of Estimate' do diff --git a/spec/models/meta_index_object_spec.rb b/spec/models/meta_index_object_spec.rb index 0ea5c08..4151fe1 100644 --- a/spec/models/meta_index_object_spec.rb +++ b/spec/models/meta_index_object_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { next_page: @instance.next_page, prev_page: @instance.prev_page } } - let(:nullable_properties) { Set.new(["next_page", "prev_page"]) } + let(:nullable_properties) { Set.new([:next_page, :prev_page]) } end describe 'test an instance of MetaIndexObject' do diff --git a/spec/models/order_list_response_spec.rb b/spec/models/order_list_response_spec.rb index 4e85078..592dcc0 100644 --- a/spec/models/order_list_response_spec.rb +++ b/spec/models/order_list_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of OrderListResponse' do diff --git a/spec/models/order_response_spec.rb b/spec/models/order_response_spec.rb index 9880ff9..4d805e2 100644 --- a/spec/models/order_response_spec.rb +++ b/spec/models/order_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of OrderResponse' do diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index a1e49d7..deb9673 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -41,7 +41,7 @@ metadata: @instance.metadata } } - let(:nullable_properties) { Set.new(["patch_fee_cents_usd", "price_cents_usd"]) } + let(:nullable_properties) { Set.new([:patch_fee_cents_usd, :price_cents_usd]) } end describe 'test an instance of Order' do diff --git a/spec/models/preference_list_response_spec.rb b/spec/models/preference_list_response_spec.rb index 7388d7f..6cbc01b 100644 --- a/spec/models/preference_list_response_spec.rb +++ b/spec/models/preference_list_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of PreferenceListResponse' do diff --git a/spec/models/preference_response_spec.rb b/spec/models/preference_response_spec.rb index e19ad9d..8453e0a 100644 --- a/spec/models/preference_response_spec.rb +++ b/spec/models/preference_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of PreferenceResponse' do diff --git a/spec/models/project_list_response_spec.rb b/spec/models/project_list_response_spec.rb index c83f631..5c792d9 100644 --- a/spec/models/project_list_response_spec.rb +++ b/spec/models/project_list_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of ProjectListResponse' do diff --git a/spec/models/project_response_spec.rb b/spec/models/project_response_spec.rb index 49f0965..00f028a 100644 --- a/spec/models/project_response_spec.rb +++ b/spec/models/project_response_spec.rb @@ -30,7 +30,7 @@ it_behaves_like "a generated class" do let(:instance) { @instance } let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new(["error"]) } + let(:nullable_properties) { Set.new([:error]) } end describe 'test an instance of ProjectResponse' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c886407..01b5cea 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -44,7 +44,7 @@ standard: @instance.standard } } - let(:nullable_properties) { Set.new(["photos", "standard", "sdgs"]) } + let(:nullable_properties) { Set.new([:photos, :standard, :sdgs]) } end describe 'test an instance of Project' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7dd5a5d..cdf847f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,17 +6,19 @@ The version of the OpenAPI document: v1 Contact: developers@usepatch.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +OpenAPI Generator version: 5.2.1 =end # load the gem require 'patch_ruby' +# Start custom require 'constants' require 'factory_bot' +# End custom # Require shared spec examples -Dir["./spec/support/**/*.rb"].sort.each { |f| require f } +Dir['./spec/support/**/*.rb'].sort.each { |f| require f } # The following was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. @@ -37,21 +39,6 @@ # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - # Use FactoryBot for test factories - config.include FactoryBot::Syntax::Methods - config.before(:suite) do - FactoryBot.find_definitions - Patch.configure do |config| - if ENV.fetch('LOCAL_SDK_TEST', false) - config.access_token = ENV.fetch('LOCAL_PATCH_API_KEY') - config.scheme = 'http' - config.host = 'api.patch.test:3000' - else - config.access_token = ENV.fetch('SANDBOX_API_KEY') - end - end - end - # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. @@ -75,57 +62,77 @@ mocks.verify_partial_doubles = true end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # These two settings work together to allow you to limit a spec run + # # to individual examples or groups you care about by tagging them with + # # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # # get run. + # config.filter_run :focus + # config.run_all_when_everything_filtered = true + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # This setting enables warnings. It's recommended, but in some cases may + # # be too noisy due to issues in dependencies. + # config.warnings = true + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = 'doc' + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = :random -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! + ###################### + # Start custom section + ###################### - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' + # Use FactoryBot for test factories + config.include FactoryBot::Syntax::Methods + config.before(:suite) do + FactoryBot.find_definitions + Patch.configure do |config| + if ENV.fetch('LOCAL_SDK_TEST', false) + config.access_token = ENV.fetch('LOCAL_PATCH_API_KEY') + config.scheme = 'http' + config.host = 'api.patch.test:3000' + else + config.access_token = ENV.fetch('SANDBOX_API_KEY') + end + end end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + ###################### + # End custom section + ###################### end