diff --git a/.gemini/config.yaml b/.gemini/config.yaml new file mode 100644 index 0000000..fc94b38 --- /dev/null +++ b/.gemini/config.yaml @@ -0,0 +1,3 @@ +have_fun: false +code_review: + disable: true diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 9bf240b..6aafe0f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -64,6 +64,7 @@ docs/PayeesResponseData.md docs/PostAccountWrapper.md docs/PostScheduledTransactionWrapper.md docs/PostTransactionsWrapper.md +docs/PutScheduledTransactionWrapper.md docs/PutTransactionWrapper.md docs/SaveAccount.md docs/SaveCategory.md @@ -174,6 +175,7 @@ lib/ynab/models/payees_response_data.rb lib/ynab/models/post_account_wrapper.rb lib/ynab/models/post_scheduled_transaction_wrapper.rb lib/ynab/models/post_transactions_wrapper.rb +lib/ynab/models/put_scheduled_transaction_wrapper.rb lib/ynab/models/put_transaction_wrapper.rb lib/ynab/models/save_account.rb lib/ynab/models/save_category.rb diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 1985849..5f84a81 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.7.0 +7.12.0 diff --git a/.tool-versions b/.tool-versions index 51f617d..041df9a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -ruby 3.3.1 +ruby 3.4.1 diff --git a/Gemfile.lock b/Gemfile.lock index e67a936..36f9c71 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ynab (3.5.0) + ynab (3.6.0) typhoeus (~> 1.0, >= 1.0.1) GEM diff --git a/README.md b/README.md index 7b090aa..a56228a 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ The following methods are available in this library. | **Categories** | [categories.get_categories(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#get_categories) | Returns all categories grouped by category group. | | | [categories.get_category_by_id(budget_id, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#get_category_by_id) | Returns a single category | | | [categories.get_month_category_by_id(budget_id, month, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#get_month_category_by_id) | Returns a single category for a specific budget month +| | [categories.update_category(budget_id, category_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#update_category) | Update an existing category +| | [categories.update_month_category(budget_id, month, category_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#update_month_category) | Update an existing month category | **Payees** | [payees.get_payees(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeesApi.md#get_payees) | Returns all payees | | | [payees.get_payee_by_id(budget_id, payee_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeesApi.md#get_payee_by_id) | Returns single payee | | **Payee Locations** | [payee_locations.get_payee_locations(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeeLocationsApi.md#get_payee_locations) | Returns all payee locations | @@ -78,6 +80,8 @@ The following methods are available in this library. | **Scheduled Transactions** | [scheduled_transactions.get_scheduled_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#get_scheduled_transactions) | Returns all scheduled transactions | | | [scheduled_transactions.get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#get_scheduled_transaction_by_id) | Returns a single scheduled transaction | | | [scheduled_transactions.create_scheduled_transaction(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#create_scheduled_transaction) | Creates a single scheduled transaction | +| | [scheduled_transactions.update_scheduled_transaction(budget_id, scheduled_transaction_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#update_scheduled_transaction) | Updates a single scheduled transaction | +| | [scheduled_transactions.delete_scheduled_transaction(budget_id, scheduled_transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#delete_scheduled_transaction) | Deletes a single scheduled transaction | ## Versioning diff --git a/docs/PutScheduledTransactionWrapper.md b/docs/PutScheduledTransactionWrapper.md new file mode 100644 index 0000000..31c7614 --- /dev/null +++ b/docs/PutScheduledTransactionWrapper.md @@ -0,0 +1,8 @@ +# YNAB::PutScheduledTransactionWrapper + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **scheduled_transaction** | [**SaveScheduledTransaction**](SaveScheduledTransaction.md) | | | + diff --git a/docs/SaveCategory.md b/docs/SaveCategory.md index ed9e9cb..55b215d 100644 --- a/docs/SaveCategory.md +++ b/docs/SaveCategory.md @@ -7,4 +7,5 @@ | **name** | **String** | | [optional] | | **note** | **String** | | [optional] | | **category_group_id** | **String** | | [optional] | +| **goal_target** | **Integer** | The goal target amount in milliunits format. This amount can only be changed if the category already has a configured goal (goal_type != null). | [optional] | diff --git a/docs/ScheduledSubTransaction.md b/docs/ScheduledSubTransaction.md index f69a2e9..48d4238 100644 --- a/docs/ScheduledSubTransaction.md +++ b/docs/ScheduledSubTransaction.md @@ -9,7 +9,9 @@ | **amount** | **Integer** | The scheduled subtransaction amount in milliunits format | | | **memo** | **String** | | [optional] | | **payee_id** | **String** | | [optional] | +| **payee_name** | **String** | | [optional] | | **category_id** | **String** | | [optional] | +| **category_name** | **String** | | [optional] | | **transfer_account_id** | **String** | If a transfer, the account_id which the scheduled subtransaction transfers to | [optional] | | **deleted** | **Boolean** | Whether or not the scheduled subtransaction has been deleted. Deleted scheduled subtransactions will only be included in delta requests. | | diff --git a/docs/ScheduledTransactionsApi.md b/docs/ScheduledTransactionsApi.md index 372f623..1b4fc44 100644 --- a/docs/ScheduledTransactionsApi.md +++ b/docs/ScheduledTransactionsApi.md @@ -5,8 +5,10 @@ All URIs are relative to *https://api.ynab.com/v1* | Method | HTTP request | Description | | ------ | ------------ | ----------- | | [**create_scheduled_transaction**](ScheduledTransactionsApi.md#create_scheduled_transaction) | **POST** /budgets/{budget_id}/scheduled_transactions | Create a single scheduled transaction | +| [**delete_scheduled_transaction**](ScheduledTransactionsApi.md#delete_scheduled_transaction) | **DELETE** /budgets/{budget_id}/scheduled_transactions | Deletes an existing scheduled transaction | | [**get_scheduled_transaction_by_id**](ScheduledTransactionsApi.md#get_scheduled_transaction_by_id) | **GET** /budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id} | Single scheduled transaction | | [**get_scheduled_transactions**](ScheduledTransactionsApi.md#get_scheduled_transactions) | **GET** /budgets/{budget_id}/scheduled_transactions | List scheduled transactions | +| [**update_scheduled_transaction**](ScheduledTransactionsApi.md#update_scheduled_transaction) | **PUT** /budgets/{budget_id}/scheduled_transactions | Updates an existing scheduled transaction | ## create_scheduled_transaction @@ -29,6 +31,26 @@ Creates a single scheduled transaction (a transaction with a future date). [**ScheduledTransactionResponse**](ScheduledTransactionResponse.md) +## delete_scheduled_transaction + +> delete_scheduled_transaction(budget_id, scheduled_transaction_id) + +Deletes an existing scheduled transaction + +Deletes a scheduled transaction + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **budget_id** | **String** | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). | | +| **scheduled_transaction_id** | **String** | The id of the scheduled transaction | | + +### Return type + +[**ScheduledTransactionResponse**](ScheduledTransactionResponse.md) + + ## get_scheduled_transaction_by_id > get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id) @@ -68,3 +90,24 @@ Returns all scheduled transactions [**ScheduledTransactionsResponse**](ScheduledTransactionsResponse.md) + +## update_scheduled_transaction + +> update_scheduled_transaction(budget_id, scheduled_transaction_id, put_scheduled_transaction_wrapper) + +Updates an existing scheduled transaction + +Updates a single scheduled transaction + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **budget_id** | **String** | The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). | | +| **scheduled_transaction_id** | **String** | The id of the scheduled transaction | | +| **put_scheduled_transaction_wrapper** | [**PutScheduledTransactionWrapper**](PutScheduledTransactionWrapper.md) | The scheduled transaction to update | | + +### Return type + +[**ScheduledTransactionResponse**](ScheduledTransactionResponse.md) + diff --git a/lib/ynab.rb b/lib/ynab.rb index cd16eb4..c65dce5 100644 --- a/lib/ynab.rb +++ b/lib/ynab.rb @@ -72,6 +72,7 @@ require 'ynab/models/post_account_wrapper' require 'ynab/models/post_scheduled_transaction_wrapper' require 'ynab/models/post_transactions_wrapper' +require 'ynab/models/put_scheduled_transaction_wrapper' require 'ynab/models/put_transaction_wrapper' require 'ynab/models/save_account' require 'ynab/models/save_category' diff --git a/lib/ynab/api/scheduled_transactions_api.rb b/lib/ynab/api/scheduled_transactions_api.rb index e9c0ab1..f30d252 100644 --- a/lib/ynab/api/scheduled_transactions_api.rb +++ b/lib/ynab/api/scheduled_transactions_api.rb @@ -90,6 +90,75 @@ def create_scheduled_transaction_with_http_info(budget_id, data, opts = {}) return data, status_code, headers end + # Deletes an existing scheduled transaction + # Deletes a scheduled transaction + # @param budget_id [String] The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). + # @param scheduled_transaction_id [String] The id of the scheduled transaction + # @param [Hash] opts the optional parameters + # @return [ScheduledTransactionResponse] + def delete_scheduled_transaction(budget_id, scheduled_transaction_id, opts = {}) + data, _status_code, _headers = delete_scheduled_transaction_with_http_info(budget_id, scheduled_transaction_id, opts) + data + end + + # Deletes an existing scheduled transaction + # Deletes a scheduled transaction + # @param budget_id [String] The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). + # @param scheduled_transaction_id [String] The id of the scheduled transaction + # @param [Hash] opts the optional parameters + # @return [Array<(ScheduledTransactionResponse, Integer, Hash)>] ScheduledTransactionResponse data, response status code and response headers + def delete_scheduled_transaction_with_http_info(budget_id, scheduled_transaction_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ScheduledTransactionsApi.delete_scheduled_transaction ...' + end + # verify the required parameter 'budget_id' is set + if @api_client.config.client_side_validation && budget_id.nil? + fail ArgumentError, "Missing the required parameter 'budget_id' when calling ScheduledTransactionsApi.delete_scheduled_transaction" + end + # verify the required parameter 'scheduled_transaction_id' is set + if @api_client.config.client_side_validation && scheduled_transaction_id.nil? + fail ArgumentError, "Missing the required parameter 'scheduled_transaction_id' when calling ScheduledTransactionsApi.delete_scheduled_transaction" + end + # resource path + local_var_path = '/budgets/{budget_id}/scheduled_transactions'.sub('{' + 'budget_id' + '}', CGI.escape(budget_id.to_s)).sub('{' + 'scheduled_transaction_id' + '}', CGI.escape(scheduled_transaction_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ScheduledTransactionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer'] + + new_options = opts.merge( + :operation => :"ScheduledTransactionsApi.delete_scheduled_transaction", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ScheduledTransactionsApi#delete_scheduled_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Single scheduled transaction # Returns a single scheduled transaction # @param budget_id [String] The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). @@ -224,5 +293,85 @@ def get_scheduled_transactions_with_http_info(budget_id, opts = {}) end return data, status_code, headers end + + # Updates an existing scheduled transaction + # Updates a single scheduled transaction + # @param budget_id [String] The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). + # @param scheduled_transaction_id [String] The id of the scheduled transaction + # @param put_scheduled_transaction_wrapper [PutScheduledTransactionWrapper] The scheduled transaction to update + # @param [Hash] opts the optional parameters + # @return [ScheduledTransactionResponse] + def update_scheduled_transaction(budget_id, scheduled_transaction_id, put_scheduled_transaction_wrapper, opts = {}) + data, _status_code, _headers = update_scheduled_transaction_with_http_info(budget_id, scheduled_transaction_id, put_scheduled_transaction_wrapper, opts) + data + end + + # Updates an existing scheduled transaction + # Updates a single scheduled transaction + # @param budget_id [String] The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). + # @param scheduled_transaction_id [String] The id of the scheduled transaction + # @param put_scheduled_transaction_wrapper [PutScheduledTransactionWrapper] The scheduled transaction to update + # @param [Hash] opts the optional parameters + # @return [Array<(ScheduledTransactionResponse, Integer, Hash)>] ScheduledTransactionResponse data, response status code and response headers + def update_scheduled_transaction_with_http_info(budget_id, scheduled_transaction_id, put_scheduled_transaction_wrapper, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ScheduledTransactionsApi.update_scheduled_transaction ...' + end + # verify the required parameter 'budget_id' is set + if @api_client.config.client_side_validation && budget_id.nil? + fail ArgumentError, "Missing the required parameter 'budget_id' when calling ScheduledTransactionsApi.update_scheduled_transaction" + end + # verify the required parameter 'scheduled_transaction_id' is set + if @api_client.config.client_side_validation && scheduled_transaction_id.nil? + fail ArgumentError, "Missing the required parameter 'scheduled_transaction_id' when calling ScheduledTransactionsApi.update_scheduled_transaction" + end + # verify the required parameter 'put_scheduled_transaction_wrapper' is set + if @api_client.config.client_side_validation && put_scheduled_transaction_wrapper.nil? + fail ArgumentError, "Missing the required parameter 'put_scheduled_transaction_wrapper' when calling ScheduledTransactionsApi.update_scheduled_transaction" + end + # resource path + local_var_path = '/budgets/{budget_id}/scheduled_transactions'.sub('{' + 'budget_id' + '}', CGI.escape(budget_id.to_s)).sub('{' + 'scheduled_transaction_id' + '}', CGI.escape(scheduled_transaction_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(put_scheduled_transaction_wrapper) + + # return_type + return_type = opts[:debug_return_type] || 'ScheduledTransactionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer'] + + new_options = opts.merge( + :operation => :"ScheduledTransactionsApi.update_scheduled_transaction", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ScheduledTransactionsApi#update_scheduled_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/ynab/models/category.rb b/lib/ynab/models/category.rb index 1a4b15c..98fff09 100644 --- a/lib/ynab/models/category.rb +++ b/lib/ynab/models/category.rb @@ -316,7 +316,7 @@ def valid? return false if @budgeted.nil? return false if @activity.nil? return false if @balance.nil? - goal_type_validator = EnumAttributeValidator.new('String', ["TB", "TBD", "MF", "NEED", "DEBT", "null"]) + goal_type_validator = EnumAttributeValidator.new('String', ["TB", "TBD", "MF", "NEED", "DEBT"]) return false unless goal_type_validator.valid?(@goal_type) return false if @deleted.nil? true diff --git a/lib/ynab/models/hybrid_transaction.rb b/lib/ynab/models/hybrid_transaction.rb index c6938c8..dc6d0db 100644 --- a/lib/ynab/models/hybrid_transaction.rb +++ b/lib/ynab/models/hybrid_transaction.rb @@ -317,7 +317,7 @@ def valid? return false if @cleared.nil? return false if @approved.nil? return false if @account_id.nil? - debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge", "null"]) + debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge"]) return false unless debt_transaction_type_validator.valid?(@debt_transaction_type) return false if @deleted.nil? return false if @type.nil? diff --git a/lib/ynab/models/put_scheduled_transaction_wrapper.rb b/lib/ynab/models/put_scheduled_transaction_wrapper.rb new file mode 100644 index 0000000..5c5f080 --- /dev/null +++ b/lib/ynab/models/put_scheduled_transaction_wrapper.rb @@ -0,0 +1,210 @@ +=begin +#YNAB API Endpoints + +#Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com + +Generated by: OpenAPI Generator (https://openapi-generator.tech) + +=end + +require 'date' +require 'time' + +module YNAB + class PutScheduledTransactionWrapper + attr_accessor :scheduled_transaction + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'scheduled_transaction' => :'scheduled_transaction' + } + 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 + { + :'scheduled_transaction' => :'SaveScheduledTransaction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::PutScheduledTransactionWrapper` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::PutScheduledTransactionWrapper`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'scheduled_transaction') + self.scheduled_transaction = attributes[:'scheduled_transaction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @scheduled_transaction.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + scheduled_transaction == o.scheduled_transaction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [scheduled_transaction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{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[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = YNAB.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + 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 + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/ynab/models/save_category.rb b/lib/ynab/models/save_category.rb index 806a50a..bfc96f9 100644 --- a/lib/ynab/models/save_category.rb +++ b/lib/ynab/models/save_category.rb @@ -18,12 +18,16 @@ class SaveCategory attr_accessor :category_group_id + # The goal target amount in milliunits format. This amount can only be changed if the category already has a configured goal (goal_type != null). + attr_accessor :goal_target + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'name' => :'name', :'note' => :'note', - :'category_group_id' => :'category_group_id' + :'category_group_id' => :'category_group_id', + :'goal_target' => :'goal_target' } end @@ -37,7 +41,8 @@ def self.openapi_types { :'name' => :'String', :'note' => :'String', - :'category_group_id' => :'String' + :'category_group_id' => :'String', + :'goal_target' => :'Integer' } end @@ -46,6 +51,7 @@ def self.openapi_nullable Set.new([ :'name', :'note', + :'goal_target' ]) end @@ -75,6 +81,10 @@ def initialize(attributes = {}) if attributes.key?(:'category_group_id') self.category_group_id = attributes[:'category_group_id'] end + + if attributes.key?(:'goal_target') + self.goal_target = attributes[:'goal_target'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -97,7 +107,8 @@ def ==(o) self.class == o.class && name == o.name && note == o.note && - category_group_id == o.category_group_id + category_group_id == o.category_group_id && + goal_target == o.goal_target end # @see the `==` method @@ -109,7 +120,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [name, note, category_group_id].hash + [name, note, category_group_id, goal_target].hash end # Builds the object from hash diff --git a/lib/ynab/models/scheduled_sub_transaction.rb b/lib/ynab/models/scheduled_sub_transaction.rb index b362404..b4823a3 100644 --- a/lib/ynab/models/scheduled_sub_transaction.rb +++ b/lib/ynab/models/scheduled_sub_transaction.rb @@ -23,8 +23,12 @@ class ScheduledSubTransaction attr_accessor :payee_id + attr_accessor :payee_name + attr_accessor :category_id + attr_accessor :category_name + # If a transfer, the account_id which the scheduled subtransaction transfers to attr_accessor :transfer_account_id @@ -39,7 +43,9 @@ def self.attribute_map :'amount' => :'amount', :'memo' => :'memo', :'payee_id' => :'payee_id', + :'payee_name' => :'payee_name', :'category_id' => :'category_id', + :'category_name' => :'category_name', :'transfer_account_id' => :'transfer_account_id', :'deleted' => :'deleted' } @@ -58,7 +64,9 @@ def self.openapi_types :'amount' => :'Integer', :'memo' => :'String', :'payee_id' => :'String', + :'payee_name' => :'String', :'category_id' => :'String', + :'category_name' => :'String', :'transfer_account_id' => :'String', :'deleted' => :'Boolean' } @@ -69,7 +77,9 @@ def self.openapi_nullable Set.new([ :'memo', :'payee_id', + :'payee_name', :'category_id', + :'category_name', :'transfer_account_id', ]) end @@ -109,10 +119,18 @@ def initialize(attributes = {}) self.payee_id = attributes[:'payee_id'] end + if attributes.key?(:'payee_name') + self.payee_name = attributes[:'payee_name'] + end + if attributes.key?(:'category_id') self.category_id = attributes[:'category_id'] end + if attributes.key?(:'category_name') + self.category_name = attributes[:'category_name'] + end + if attributes.key?(:'transfer_account_id') self.transfer_account_id = attributes[:'transfer_account_id'] end @@ -149,7 +167,9 @@ def ==(o) amount == o.amount && memo == o.memo && payee_id == o.payee_id && + payee_name == o.payee_name && category_id == o.category_id && + category_name == o.category_name && transfer_account_id == o.transfer_account_id && deleted == o.deleted end @@ -163,7 +183,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, scheduled_transaction_id, amount, memo, payee_id, category_id, transfer_account_id, deleted].hash + [id, scheduled_transaction_id, amount, memo, payee_id, payee_name, category_id, category_name, transfer_account_id, deleted].hash end # Builds the object from hash diff --git a/lib/ynab/models/transaction_detail.rb b/lib/ynab/models/transaction_detail.rb index 53c8e91..dd8b675 100644 --- a/lib/ynab/models/transaction_detail.rb +++ b/lib/ynab/models/transaction_detail.rb @@ -310,7 +310,7 @@ def valid? return false if @cleared.nil? return false if @approved.nil? return false if @account_id.nil? - debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge", "null"]) + debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge"]) return false unless debt_transaction_type_validator.valid?(@debt_transaction_type) return false if @deleted.nil? return false if @account_name.nil? diff --git a/lib/ynab/models/transaction_flag_color.rb b/lib/ynab/models/transaction_flag_color.rb index 4f126db..aa55c77 100644 --- a/lib/ynab/models/transaction_flag_color.rb +++ b/lib/ynab/models/transaction_flag_color.rb @@ -18,10 +18,9 @@ class TransactionFlagColor GREEN = "green".freeze BLUE = "blue".freeze PURPLE = "purple".freeze - NULL = "null".freeze def self.all_vars - @all_vars ||= [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, NULL].freeze + @all_vars ||= [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE].freeze end # Builds the enum from string diff --git a/lib/ynab/models/transaction_summary.rb b/lib/ynab/models/transaction_summary.rb index 19da3fe..836f8e7 100644 --- a/lib/ynab/models/transaction_summary.rb +++ b/lib/ynab/models/transaction_summary.rb @@ -265,7 +265,7 @@ def valid? return false if @cleared.nil? return false if @approved.nil? return false if @account_id.nil? - debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge", "null"]) + debt_transaction_type_validator = EnumAttributeValidator.new('String', ["payment", "refund", "fee", "interest", "escrow", "balanceAdjustment", "credit", "charge"]) return false unless debt_transaction_type_validator.valid?(@debt_transaction_type) return false if @deleted.nil? true diff --git a/open_api_spec.yaml b/open_api_spec.yaml index e555b3b..8e990c3 100644 --- a/open_api_spec.yaml +++ b/open_api_spec.yaml @@ -6,7 +6,7 @@ info: upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com - version: 1.72.1 + version: 1.74.0 servers: - url: https://api.ynab.com/v1 security: @@ -1580,6 +1580,85 @@ paths: schema: $ref: "#/components/schemas/ErrorResponse" x-codegen-request-body-name: data + put: + tags: + - Scheduled Transactions + summary: Updates an existing scheduled transaction + description: Updates a single scheduled transaction + operationId: updateScheduledTransaction + parameters: + - name: budget_id + in: path + description: >- + The id of the budget. "last-used" can be used to specify the last + used budget and "default" can be used if default budget selection is + enabled (see: https://api.ynab.com/#oauth-default-budget). + required: true + schema: + type: string + - name: scheduled_transaction_id + in: path + description: The id of the scheduled transaction + required: true + schema: + type: string + requestBody: + description: The scheduled transaction to update + content: + "application/json": + schema: + $ref: "#/components/schemas/PutScheduledTransactionWrapper" + required: true + responses: + "200": + description: The scheduled transaction was successfully updated + content: + application/json: + schema: + $ref: "#/components/schemas/ScheduledTransactionResponse" + "400": + description: >- + The request could not be understood due to malformed syntax or + validation error(s) + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + delete: + tags: + - Scheduled Transactions + summary: Deletes an existing scheduled transaction + description: Deletes a scheduled transaction + operationId: deleteScheduledTransaction + parameters: + - name: budget_id + in: path + description: >- + The id of the budget. "last-used" can be used to specify the last + used budget and "default" can be used if default budget selection is + enabled (see: https://api.ynab.com/#oauth-default-budget). + required: true + schema: + type: string + - name: scheduled_transaction_id + in: path + description: The id of the scheduled transaction + required: true + schema: + type: string + responses: + "200": + description: The scheduled transaction was successfully deleted + content: + application/json: + schema: + $ref: "#/components/schemas/ScheduledTransactionResponse" + "404": + description: The scheduled transaction was not found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" /budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id}: get: tags: @@ -2836,6 +2915,11 @@ components: category_group_id: type: string format: uuid + goal_target: + type: integer + description: The goal target amount in milliunits format. This amount can only be changed if the category already has a configured goal (goal_type != null). + format: int64 + nullable: true PatchMonthCategoryWrapper: required: - category @@ -2986,6 +3070,13 @@ components: properties: scheduled_transaction: $ref: "#/components/schemas/ScheduledTransactionDetail" + PutScheduledTransactionWrapper: + required: + - scheduled_transaction + type: object + properties: + scheduled_transaction: + $ref: "#/components/schemas/SaveScheduledTransaction" PostScheduledTransactionWrapper: required: - scheduled_transaction @@ -3165,10 +3256,16 @@ components: type: string nullable: true format: uuid + payee_name: + type: string + nullable: true category_id: type: string nullable: true format: uuid + category_name: + type: string + nullable: true transfer_account_id: type: string nullable: true diff --git a/templates/gemspec.mustache b/templates/gemspec.mustache index 80f38ee..7324f8b 100644 --- a/templates/gemspec.mustache +++ b/templates/gemspec.mustache @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"] s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}" s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}" - s.description = "{{gemDescription}}{{/gemDescription}} Generated from server specification version {{version}}." + s.description = "{{gemDescription}}{{^gemDescription}}{{/gemDescription}} Generated from server specification version {{version}}." s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}" s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.7{{/gemRequiredRubyVersion}}" s.metadata = {{{gemMetadata}}}{{^gemMetadata}}{}{{/gemMetadata}} diff --git a/ynab.gemspec b/ynab.gemspec index 5ed4cf4..8bbc28c 100644 --- a/ynab.gemspec +++ b/ynab.gemspec @@ -19,8 +19,8 @@ Gem::Specification.new do |s| s.authors = ["YNAB"] s.email = ["api@ynab.com"] s.homepage = "https://github.com/ynab/ynab-sdk-ruby" - s.summary = "YNAB API Client for Ruby" - s.description = "Ruby gem wrapper for the YNAB API. API documentation available at https://api.ynab.com. Generated from server specification version 1.72.1 using OpenAPI Generator version 7.7.0." + s.summary = "Official Ruby client for the YNAB API" + s.description = "Official Ruby client for the YNAB API. API documentation available at https://api.ynab.com. Generated from server specification version 1.74.0." s.license = "Apache-2.0" s.required_ruby_version = ">= 3.3" s.metadata = {}