From 0c92738c32dab7e6dd0eb05b8032869059dd3167 Mon Sep 17 00:00:00 2001 From: moneykitt Date: Thu, 2 May 2024 16:58:37 +0000 Subject: [PATCH] Update with latest OpenAPI changes --- .openapi-generator/FILES | 9 +- Gemfile.lock | 2 +- README.md | 2 +- docs/AccountNumbersApi.md | 18 +-- docs/AccountsApi.md | 18 +-- docs/Response401GetAccountNumbers.md | 22 ++++ lib/moneykit.rb | 2 +- lib/moneykit/api/account_numbers_api.rb | 14 +-- lib/moneykit/api/accounts_api.rb | 14 +-- .../models/response401_get_account_numbers.rb | 104 ++++++++++++++++++ lib/moneykit/version.rb | 2 +- .../response401_get_account_numbers_spec.rb | 21 ++++ 12 files changed, 186 insertions(+), 42 deletions(-) create mode 100644 docs/Response401GetAccountNumbers.md create mode 100644 lib/moneykit/models/response401_get_account_numbers.rb create mode 100644 spec/models/response401_get_account_numbers_spec.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 6a0192c..75817b1 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -93,7 +93,7 @@ docs/RequestedLinkPermission.md docs/Response401DisconnectLinksIdDelete.md docs/Response401ExchangeTokenLinkSessionExchangeTokenPost.md docs/Response401GetAccountLinksIdAccountsAccountIdGet.md -docs/Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet.md +docs/Response401GetAccountNumbers.md docs/Response401GetAccountsLinksIdAccountsGet.md docs/Response401GetHoldingsLinksIdInvestmentsHoldingsGet.md docs/Response401GetIdentitiesLinksIdIdentityGet.md @@ -227,7 +227,7 @@ lib/moneykit/models/requested_link_permission.rb lib/moneykit/models/response401_disconnect_links_id_delete.rb lib/moneykit/models/response401_exchange_token_link_session_exchange_token_post.rb lib/moneykit/models/response401_get_account_links_id_accounts_account_id_get.rb -lib/moneykit/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get.rb +lib/moneykit/models/response401_get_account_numbers.rb lib/moneykit/models/response401_get_accounts_links_id_accounts_get.rb lib/moneykit/models/response401_get_holdings_links_id_investments_holdings_get.rb lib/moneykit/models/response401_get_identities_links_id_identity_get.rb @@ -266,8 +266,5 @@ lib/moneykit/version.rb moneykit.gemspec spec/api_client_spec.rb spec/configuration_spec.rb -spec/models/account_numbers_legacy20230218_spec.rb -spec/models/account_with_account_numbers_legacy20230218_spec.rb -spec/models/get_account_numbers_response_legacy20230218_spec.rb -spec/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get_spec.rb +spec/models/response401_get_account_numbers_spec.rb spec/spec_helper.rb diff --git a/Gemfile.lock b/Gemfile.lock index f54e28f..a372a60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - moneykit (0.1.9) + moneykit (0.1.10) faraday (>= 1.0.1, < 3.0) faraday-multipart diff --git a/README.md b/README.md index 23dfe70..3fdcf4c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ bundle add moneykit.gemspec or add the following to your `Gemfile` ``` -gem 'moneykit', '~> 0.1.9' +gem 'moneykit', '~> 0.1.10' ``` ## Getting Started diff --git a/docs/AccountNumbersApi.md b/docs/AccountNumbersApi.md index 1faf1e4..114f513 100644 --- a/docs/AccountNumbersApi.md +++ b/docs/AccountNumbersApi.md @@ -4,12 +4,12 @@ All URIs are relative to *https://api.moneykit.com* | Method | HTTP request | Description | | ------ | ------------ | ----------- | -| [**get_account_numbers_legacy20230218**](AccountNumbersApi.md#get_account_numbers_legacy20230218) | **GET** /links/{id}/accounts/numbers | /links/{id}/accounts/numbers | +| [**get_account_numbers**](AccountNumbersApi.md#get_account_numbers) | **GET** /links/{id}/accounts/numbers | /links/{id}/accounts/numbers | -## get_account_numbers_legacy20230218 +## get_account_numbers -> get_account_numbers_legacy20230218(id) +> get_account_numbers(id) /links/{id}/accounts/numbers @@ -31,28 +31,28 @@ id = 'id_example' # String | The unique ID for this link. begin # /links/{id}/accounts/numbers - result = api_instance.get_account_numbers_legacy20230218(id) + result = api_instance.get_account_numbers(id) p result rescue MoneyKit::ApiError => e - puts "Error when calling AccountNumbersApi->get_account_numbers_legacy20230218: #{e}" + puts "Error when calling AccountNumbersApi->get_account_numbers: #{e}" end ``` -#### Using the get_account_numbers_legacy20230218_with_http_info variant +#### Using the get_account_numbers_with_http_info variant This returns an Array which contains the response data, status code and headers. -> , Integer, Hash)> get_account_numbers_legacy20230218_with_http_info(id) +> , Integer, Hash)> get_account_numbers_with_http_info(id) ```ruby begin # /links/{id}/accounts/numbers - data, status_code, headers = api_instance.get_account_numbers_legacy20230218_with_http_info(id) + data, status_code, headers = api_instance.get_account_numbers_with_http_info(id) p status_code # => 2xx p headers # => { ... } p data # => rescue MoneyKit::ApiError => e - puts "Error when calling AccountNumbersApi->get_account_numbers_legacy20230218_with_http_info: #{e}" + puts "Error when calling AccountNumbersApi->get_account_numbers_with_http_info: #{e}" end ``` diff --git a/docs/AccountsApi.md b/docs/AccountsApi.md index 5b73087..b03ec60 100644 --- a/docs/AccountsApi.md +++ b/docs/AccountsApi.md @@ -5,7 +5,7 @@ All URIs are relative to *https://api.moneykit.com* | Method | HTTP request | Description | | ------ | ------------ | ----------- | | [**get_account**](AccountsApi.md#get_account) | **GET** /links/{id}/accounts/{account_id} | /links/{id}/accounts/{account_id} | -| [**get_account_numbers_legacy20230218**](AccountsApi.md#get_account_numbers_legacy20230218) | **GET** /links/{id}/accounts/numbers | /links/{id}/accounts/numbers | +| [**get_account_numbers**](AccountsApi.md#get_account_numbers) | **GET** /links/{id}/accounts/numbers | /links/{id}/accounts/numbers | | [**get_accounts**](AccountsApi.md#get_accounts) | **GET** /links/{id}/accounts | /links/{id}/accounts | | [**get_user_accounts**](AccountsApi.md#get_user_accounts) | **GET** /users/{id}/accounts | /users/{id}/accounts | @@ -81,9 +81,9 @@ end - **Accept**: application/json -## get_account_numbers_legacy20230218 +## get_account_numbers -> get_account_numbers_legacy20230218(id) +> get_account_numbers(id) /links/{id}/accounts/numbers @@ -105,28 +105,28 @@ id = 'id_example' # String | The unique ID for this link. begin # /links/{id}/accounts/numbers - result = api_instance.get_account_numbers_legacy20230218(id) + result = api_instance.get_account_numbers(id) p result rescue MoneyKit::ApiError => e - puts "Error when calling AccountsApi->get_account_numbers_legacy20230218: #{e}" + puts "Error when calling AccountsApi->get_account_numbers: #{e}" end ``` -#### Using the get_account_numbers_legacy20230218_with_http_info variant +#### Using the get_account_numbers_with_http_info variant This returns an Array which contains the response data, status code and headers. -> , Integer, Hash)> get_account_numbers_legacy20230218_with_http_info(id) +> , Integer, Hash)> get_account_numbers_with_http_info(id) ```ruby begin # /links/{id}/accounts/numbers - data, status_code, headers = api_instance.get_account_numbers_legacy20230218_with_http_info(id) + data, status_code, headers = api_instance.get_account_numbers_with_http_info(id) p status_code # => 2xx p headers # => { ... } p data # => rescue MoneyKit::ApiError => e - puts "Error when calling AccountsApi->get_account_numbers_legacy20230218_with_http_info: #{e}" + puts "Error when calling AccountsApi->get_account_numbers_with_http_info: #{e}" end ``` diff --git a/docs/Response401GetAccountNumbers.md b/docs/Response401GetAccountNumbers.md new file mode 100644 index 0000000..5369d61 --- /dev/null +++ b/docs/Response401GetAccountNumbers.md @@ -0,0 +1,22 @@ +# MoneyKit::Response401GetAccountNumbers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **error_code** | **Object** | | [optional] | +| **error_message** | **Object** | | | +| **documentation_url** | **Object** | | [optional] | + +## Example + +```ruby +require 'moneykit' + +instance = MoneyKit::Response401GetAccountNumbers.new( + error_code: null, + error_message: null, + documentation_url: null +) +``` + diff --git a/lib/moneykit.rb b/lib/moneykit.rb index e7e3684..dc6d5c9 100644 --- a/lib/moneykit.rb +++ b/lib/moneykit.rb @@ -97,7 +97,7 @@ require 'moneykit/models/response401_disconnect_links_id_delete' require 'moneykit/models/response401_exchange_token_link_session_exchange_token_post' require 'moneykit/models/response401_get_account_links_id_accounts_account_id_get' -require 'moneykit/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get' +require 'moneykit/models/response401_get_account_numbers' require 'moneykit/models/response401_get_accounts_links_id_accounts_get' require 'moneykit/models/response401_get_holdings_links_id_investments_holdings_get' require 'moneykit/models/response401_get_identities_links_id_identity_get' diff --git a/lib/moneykit/api/account_numbers_api.rb b/lib/moneykit/api/account_numbers_api.rb index 62902c2..077f794 100644 --- a/lib/moneykit/api/account_numbers_api.rb +++ b/lib/moneykit/api/account_numbers_api.rb @@ -24,8 +24,8 @@ def initialize(api_client = ApiClient.default) # @param id [String] The unique ID for this link. # @param [Hash] opts the optional parameters # @return [GetAccountNumbersResponseLegacy20230218] - def get_account_numbers_legacy20230218(id, opts = {}) - data, _status_code, _headers = get_account_numbers_legacy20230218_with_http_info(id, opts) + def get_account_numbers(id, opts = {}) + data, _status_code, _headers = get_account_numbers_with_http_info(id, opts) data end @@ -34,13 +34,13 @@ def get_account_numbers_legacy20230218(id, opts = {}) # @param id [String] The unique ID for this link. # @param [Hash] opts the optional parameters # @return [Array<(GetAccountNumbersResponseLegacy20230218, Integer, Hash)>] GetAccountNumbersResponseLegacy20230218 data, response status code and response headers - def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) + def get_account_numbers_with_http_info(id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: AccountNumbersApi.get_account_numbers_legacy20230218 ...' + @api_client.config.logger.debug 'Calling API: AccountNumbersApi.get_account_numbers ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? - fail ArgumentError, "Missing the required parameter 'id' when calling AccountNumbersApi.get_account_numbers_legacy20230218" + fail ArgumentError, "Missing the required parameter 'id' when calling AccountNumbersApi.get_account_numbers" end # resource path local_var_path = '/links/{id}/accounts/numbers'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -66,7 +66,7 @@ def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) auth_names = opts[:debug_auth_names] || ['OAuth2ClientCredentials'] new_options = opts.merge( - :operation => :"AccountNumbersApi.get_account_numbers_legacy20230218", + :operation => :"AccountNumbersApi.get_account_numbers", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -77,7 +77,7 @@ def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging - @api_client.config.logger.debug "API called: AccountNumbersApi#get_account_numbers_legacy20230218\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: AccountNumbersApi#get_account_numbers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/lib/moneykit/api/accounts_api.rb b/lib/moneykit/api/accounts_api.rb index 989051d..88bd225 100644 --- a/lib/moneykit/api/accounts_api.rb +++ b/lib/moneykit/api/accounts_api.rb @@ -93,8 +93,8 @@ def get_account_with_http_info(id, account_id, opts = {}) # @param id [String] The unique ID for this link. # @param [Hash] opts the optional parameters # @return [GetAccountNumbersResponseLegacy20230218] - def get_account_numbers_legacy20230218(id, opts = {}) - data, _status_code, _headers = get_account_numbers_legacy20230218_with_http_info(id, opts) + def get_account_numbers(id, opts = {}) + data, _status_code, _headers = get_account_numbers_with_http_info(id, opts) data end @@ -103,13 +103,13 @@ def get_account_numbers_legacy20230218(id, opts = {}) # @param id [String] The unique ID for this link. # @param [Hash] opts the optional parameters # @return [Array<(GetAccountNumbersResponseLegacy20230218, Integer, Hash)>] GetAccountNumbersResponseLegacy20230218 data, response status code and response headers - def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) + def get_account_numbers_with_http_info(id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug 'Calling API: AccountsApi.get_account_numbers_legacy20230218 ...' + @api_client.config.logger.debug 'Calling API: AccountsApi.get_account_numbers ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? - fail ArgumentError, "Missing the required parameter 'id' when calling AccountsApi.get_account_numbers_legacy20230218" + fail ArgumentError, "Missing the required parameter 'id' when calling AccountsApi.get_account_numbers" end # resource path local_var_path = '/links/{id}/accounts/numbers'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) @@ -135,7 +135,7 @@ def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) auth_names = opts[:debug_auth_names] || ['OAuth2ClientCredentials'] new_options = opts.merge( - :operation => :"AccountsApi.get_account_numbers_legacy20230218", + :operation => :"AccountsApi.get_account_numbers", :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -146,7 +146,7 @@ def get_account_numbers_legacy20230218_with_http_info(id, opts = {}) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging - @api_client.config.logger.debug "API called: AccountsApi#get_account_numbers_legacy20230218\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + @api_client.config.logger.debug "API called: AccountsApi#get_account_numbers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end diff --git a/lib/moneykit/models/response401_get_account_numbers.rb b/lib/moneykit/models/response401_get_account_numbers.rb new file mode 100644 index 0000000..067a6ca --- /dev/null +++ b/lib/moneykit/models/response401_get_account_numbers.rb @@ -0,0 +1,104 @@ +=begin +#MoneyKit API + +#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 2023-02-18 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.1.0 + +=end + +require 'date' +require 'time' + +module MoneyKit + module Response401GetAccountNumbers + class << self + # List of class defined in anyOf (OpenAPI v3) + def openapi_any_of + [ + :'APIErrorAuthExpiredAccessTokenResponse', + :'APIErrorAuthUnauthorizedResponse', + :'LinkErrorUnauthorizedAccessResponse' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of anyOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of anyOf items and attempt to identify the appropriate one. + # Note: + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_any_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_any_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = MoneyKit.const_get(klass) + if const + if const.respond_to?(:openapi_any_of) # nested anyOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end +end diff --git a/lib/moneykit/version.rb b/lib/moneykit/version.rb index 1ccae37..4cd646c 100644 --- a/lib/moneykit/version.rb +++ b/lib/moneykit/version.rb @@ -11,5 +11,5 @@ =end module MoneyKit - VERSION = '0.1.9' + VERSION = '0.1.10' end diff --git a/spec/models/response401_get_account_numbers_spec.rb b/spec/models/response401_get_account_numbers_spec.rb new file mode 100644 index 0000000..e52ae42 --- /dev/null +++ b/spec/models/response401_get_account_numbers_spec.rb @@ -0,0 +1,21 @@ +=begin +#MoneyKit API + +#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 2023-02-18 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.1.0 + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for MoneyKit::Response401GetAccountNumbers +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe MoneyKit::Response401GetAccountNumbers do +end