diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index c770aa7..9bf240b 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -62,6 +62,7 @@ docs/PayeesApi.md docs/PayeesResponse.md docs/PayeesResponseData.md docs/PostAccountWrapper.md +docs/PostScheduledTransactionWrapper.md docs/PostTransactionsWrapper.md docs/PutTransactionWrapper.md docs/SaveAccount.md @@ -72,6 +73,7 @@ docs/SaveMonthCategory.md docs/SavePayee.md docs/SavePayeeResponse.md docs/SavePayeeResponseData.md +docs/SaveScheduledTransaction.md docs/SaveSubTransaction.md docs/SaveTransactionWithIdOrImportId.md docs/SaveTransactionWithOptionalFields.md @@ -79,6 +81,7 @@ docs/SaveTransactionsResponse.md docs/SaveTransactionsResponseData.md docs/ScheduledSubTransaction.md docs/ScheduledTransactionDetail.md +docs/ScheduledTransactionFrequency.md docs/ScheduledTransactionResponse.md docs/ScheduledTransactionResponseData.md docs/ScheduledTransactionSummary.md @@ -169,6 +172,7 @@ lib/ynab/models/payee_response_data.rb lib/ynab/models/payees_response.rb 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_transaction_wrapper.rb lib/ynab/models/save_account.rb @@ -179,6 +183,7 @@ lib/ynab/models/save_month_category.rb lib/ynab/models/save_payee.rb lib/ynab/models/save_payee_response.rb lib/ynab/models/save_payee_response_data.rb +lib/ynab/models/save_scheduled_transaction.rb lib/ynab/models/save_sub_transaction.rb lib/ynab/models/save_transaction_with_id_or_import_id.rb lib/ynab/models/save_transaction_with_optional_fields.rb @@ -186,6 +191,7 @@ lib/ynab/models/save_transactions_response.rb lib/ynab/models/save_transactions_response_data.rb lib/ynab/models/scheduled_sub_transaction.rb lib/ynab/models/scheduled_transaction_detail.rb +lib/ynab/models/scheduled_transaction_frequency.rb lib/ynab/models/scheduled_transaction_response.rb lib/ynab/models/scheduled_transaction_response_data.rb lib/ynab/models/scheduled_transaction_summary.rb diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index 93c8dda..1985849 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -7.6.0 +7.7.0 diff --git a/README.md b/README.md index 39302b6..98b6968 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ The following methods are available in this library. | | [transactions.import_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#import_transactions) | Imports transactions | | **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 | ## License diff --git a/Rakefile b/Rakefile index ba67db5..904f2f8 100644 --- a/Rakefile +++ b/Rakefile @@ -12,8 +12,6 @@ end task :default => [:spec] -REQUIRED_RUBY_VERSION = ">= 3.3" - desc "Run OpenAPI Generator to update the client from the spec" task :generate do spec_filename = 'open_api_spec.yaml' @@ -22,7 +20,7 @@ task :generate do # Remove existing generated files to ensure old files are not included in the gem sh "rm -r docs/ lib/ynab/models/" # Generate the client - sh "openapi-generator generate -i ./#{spec_filename} -g ruby --additional-properties=gemRequiredRubyVersion='#{REQUIRED_RUBY_VERSION}' -c config.json -t ./templates -o ./" + sh "openapi-generator generate -i ./#{spec_filename} -g ruby -c config.yaml -o ./" end task :get_current_version do diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..f4c8705 --- /dev/null +++ b/config.yaml @@ -0,0 +1,11 @@ +gemName: ynab +moduleName: YNAB +gemSummary: YNAB API Client for Ruby +gemDescription: Ruby gem wrapper for the YNAB API. +gemHomepage: https://github.com/ynab/ynab-sdk-ruby +gemLicense: Apache-2.0 +gemAuthor: YNAB +gemAuthorEmail: api@ynab.com +templateDir: ./templates +additionalProperties: + gemRequiredRubyVersion: ">= 3.3" diff --git a/docs/ExistingTransaction.md b/docs/ExistingTransaction.md index 9ebe774..82da0c9 100644 --- a/docs/ExistingTransaction.md +++ b/docs/ExistingTransaction.md @@ -7,7 +7,7 @@ | **account_id** | **String** | | [optional] | | **date** | **Date** | The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored. | [optional] | | **amount** | **Integer** | The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. | [optional] | -| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. | [optional] | +| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. | [optional] | | **payee_name** | **String** | The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. | [optional] | | **category_id** | **String** | The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied. | [optional] | | **memo** | **String** | | [optional] | diff --git a/docs/NewTransaction.md b/docs/NewTransaction.md index d95ff2a..9e34386 100644 --- a/docs/NewTransaction.md +++ b/docs/NewTransaction.md @@ -7,7 +7,7 @@ | **account_id** | **String** | | [optional] | | **date** | **Date** | The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored. | [optional] | | **amount** | **Integer** | The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. | [optional] | -| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. | [optional] | +| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. | [optional] | | **payee_name** | **String** | The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. | [optional] | | **category_id** | **String** | The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied. | [optional] | | **memo** | **String** | | [optional] | diff --git a/docs/PostScheduledTransactionWrapper.md b/docs/PostScheduledTransactionWrapper.md new file mode 100644 index 0000000..eb45f5d --- /dev/null +++ b/docs/PostScheduledTransactionWrapper.md @@ -0,0 +1,8 @@ +# YNAB::PostScheduledTransactionWrapper + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **scheduled_transaction** | [**SaveScheduledTransaction**](SaveScheduledTransaction.md) | | | + diff --git a/docs/SaveScheduledTransaction.md b/docs/SaveScheduledTransaction.md new file mode 100644 index 0000000..a5d002e --- /dev/null +++ b/docs/SaveScheduledTransaction.md @@ -0,0 +1,16 @@ +# YNAB::SaveScheduledTransaction + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | | | +| **date** | **Date** | The scheduled transaction date in ISO format (e.g. 2016-12-01). | | +| **amount** | **Integer** | The scheduled transaction amount in milliunits format. | [optional] | +| **payee_id** | **String** | The payee for the scheduled transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. | [optional] | +| **payee_name** | **String** | The payee name for the the scheduled transaction. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a payee with the same name or (2) creation of a new payee. | [optional] | +| **category_id** | **String** | The category for the scheduled transaction. Credit Card Payment categories are not permitted. Creating a split scheduled transaction is not currently supported. | [optional] | +| **memo** | **String** | | [optional] | +| **flag_color** | [**TransactionFlagColor**](TransactionFlagColor.md) | | [optional] | +| **frequency** | [**ScheduledTransactionFrequency**](ScheduledTransactionFrequency.md) | | [optional] | + diff --git a/docs/SaveTransactionWithIdOrImportId.md b/docs/SaveTransactionWithIdOrImportId.md index f33fafb..2c55a33 100644 --- a/docs/SaveTransactionWithIdOrImportId.md +++ b/docs/SaveTransactionWithIdOrImportId.md @@ -7,7 +7,7 @@ | **account_id** | **String** | | [optional] | | **date** | **Date** | The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored. | [optional] | | **amount** | **Integer** | The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. | [optional] | -| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. | [optional] | +| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. | [optional] | | **payee_name** | **String** | The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. | [optional] | | **category_id** | **String** | The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied. | [optional] | | **memo** | **String** | | [optional] | diff --git a/docs/SaveTransactionWithOptionalFields.md b/docs/SaveTransactionWithOptionalFields.md index 521490f..64c9b4e 100644 --- a/docs/SaveTransactionWithOptionalFields.md +++ b/docs/SaveTransactionWithOptionalFields.md @@ -7,7 +7,7 @@ | **account_id** | **String** | | [optional] | | **date** | **Date** | The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored. | [optional] | | **amount** | **Integer** | The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. | [optional] | -| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. | [optional] | +| **payee_id** | **String** | The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. | [optional] | | **payee_name** | **String** | The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. | [optional] | | **category_id** | **String** | The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied. | [optional] | | **memo** | **String** | | [optional] | diff --git a/docs/ScheduledTransactionFrequency.md b/docs/ScheduledTransactionFrequency.md new file mode 100644 index 0000000..fe01191 --- /dev/null +++ b/docs/ScheduledTransactionFrequency.md @@ -0,0 +1,7 @@ +# YNAB::ScheduledTransactionFrequency + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ScheduledTransactionsApi.md b/docs/ScheduledTransactionsApi.md index 2574525..c2569fa 100644 --- a/docs/ScheduledTransactionsApi.md +++ b/docs/ScheduledTransactionsApi.md @@ -4,10 +4,31 @@ 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 | | [**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 | +## create_scheduled_transaction + +> create_scheduled_transaction(budget_id, data) + +Create a single scheduled transaction + +Creates 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). | | +| **data** | [**PostScheduledTransactionWrapper**](PostScheduledTransactionWrapper.md) | The scheduled transaction to create | | + +### Return type + +[**ScheduledTransactionResponse**](ScheduledTransactionResponse.md) + + ## get_scheduled_transaction_by_id > get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id) diff --git a/docs/TransactionsApi.md b/docs/TransactionsApi.md index ae5ce97..6f024f7 100644 --- a/docs/TransactionsApi.md +++ b/docs/TransactionsApi.md @@ -22,7 +22,7 @@ All URIs are relative to *https://api.ynab.com/v1* Create a single transaction or multiple transactions -Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions cannot be created on this endpoint. +Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions (transactions with a future date) cannot be created on this endpoint. ### Parameters diff --git a/lib/ynab.rb b/lib/ynab.rb index 3a1d7ff..cd16eb4 100644 --- a/lib/ynab.rb +++ b/lib/ynab.rb @@ -70,6 +70,7 @@ require 'ynab/models/payees_response' require 'ynab/models/payees_response_data' require 'ynab/models/post_account_wrapper' +require 'ynab/models/post_scheduled_transaction_wrapper' require 'ynab/models/post_transactions_wrapper' require 'ynab/models/put_transaction_wrapper' require 'ynab/models/save_account' @@ -80,6 +81,7 @@ require 'ynab/models/save_payee' require 'ynab/models/save_payee_response' require 'ynab/models/save_payee_response_data' +require 'ynab/models/save_scheduled_transaction' require 'ynab/models/save_sub_transaction' require 'ynab/models/save_transaction_with_id_or_import_id' require 'ynab/models/save_transaction_with_optional_fields' @@ -87,6 +89,7 @@ require 'ynab/models/save_transactions_response_data' require 'ynab/models/scheduled_sub_transaction' require 'ynab/models/scheduled_transaction_detail' +require 'ynab/models/scheduled_transaction_frequency' require 'ynab/models/scheduled_transaction_response' require 'ynab/models/scheduled_transaction_response_data' require 'ynab/models/scheduled_transaction_summary' diff --git a/lib/ynab/api/scheduled_transactions_api.rb b/lib/ynab/api/scheduled_transactions_api.rb index 6c34099..addd9a3 100644 --- a/lib/ynab/api/scheduled_transactions_api.rb +++ b/lib/ynab/api/scheduled_transactions_api.rb @@ -16,6 +16,80 @@ class ScheduledTransactionsApi def initialize(api_client = ApiClient.default) @api_client = api_client end + # Create a single scheduled transaction + # Creates 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 data [PostScheduledTransactionWrapper] The scheduled transaction to create + # @param [Hash] opts the optional parameters + # @return [ScheduledTransactionResponse] + def create_scheduled_transaction(budget_id, data, opts = {}) + data, _status_code, _headers = create_scheduled_transaction_with_http_info(budget_id, data, opts) + data + end + + # Create a single scheduled transaction + # Creates 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 data [PostScheduledTransactionWrapper] The scheduled transaction to create + # @param [Hash] opts the optional parameters + # @return [Array<(ScheduledTransactionResponse, Integer, Hash)>] ScheduledTransactionResponse data, response status code and response headers + def create_scheduled_transaction_with_http_info(budget_id, data, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ScheduledTransactionsApi.create_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.create_scheduled_transaction" + end + # verify the required parameter 'data' is set + if @api_client.config.client_side_validation && data.nil? + fail ArgumentError, "Missing the required parameter 'data' when calling ScheduledTransactionsApi.create_scheduled_transaction" + end + # resource path + local_var_path = '/budgets/{budget_id}/scheduled_transactions'.sub('{' + 'budget_id' + '}', CGI.escape(budget_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(data) + + # return_type + return_type = opts[:debug_return_type] || 'ScheduledTransactionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer'] + + new_options = opts.merge( + :operation => :"ScheduledTransactionsApi.create_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(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ScheduledTransactionsApi#create_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). diff --git a/lib/ynab/api/transactions_api.rb b/lib/ynab/api/transactions_api.rb index 788da1a..eecaa92 100644 --- a/lib/ynab/api/transactions_api.rb +++ b/lib/ynab/api/transactions_api.rb @@ -17,7 +17,7 @@ def initialize(api_client = ApiClient.default) @api_client = api_client end # Create a single transaction or multiple transactions - # Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions cannot be created on this endpoint. + # Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions (transactions with a future date) cannot be created on this endpoint. # @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 data [PostTransactionsWrapper] The transaction or transactions to create. To create a single transaction you can specify a value for the `transaction` object and to create multiple transactions you can specify an array of `transactions`. It is expected that you will only provide a value for one of these objects. # @param [Hash] opts the optional parameters @@ -28,7 +28,7 @@ def create_transaction(budget_id, data, opts = {}) end # Create a single transaction or multiple transactions - # Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions cannot be created on this endpoint. + # Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions (transactions with a future date) cannot be created on this endpoint. # @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 data [PostTransactionsWrapper] The transaction or transactions to create. To create a single transaction you can specify a value for the `transaction` object and to create multiple transactions you can specify an array of `transactions`. It is expected that you will only provide a value for one of these objects. # @param [Hash] opts the optional parameters diff --git a/lib/ynab/configuration.rb b/lib/ynab/configuration.rb index e732d71..4f906c4 100644 --- a/lib/ynab/configuration.rb +++ b/lib/ynab/configuration.rb @@ -76,6 +76,14 @@ class Configuration # @return [true, false] attr_accessor :debugging + # Set this to ignore operation servers for the API client. This is useful when you need to + # send requests to a different server than the one specified in the OpenAPI document. + # Will default to the base url defined in the spec but can be overridden by setting + # `scheme`, `host`, `base_path` directly. + # Default to false. + # @return [true, false] + attr_accessor :ignore_operation_servers + # Defines the logger used for debugging. # Default to `Rails.logger` (when in Rails) or logging to STDOUT. # @@ -163,6 +171,7 @@ def initialize @timeout = 0 @params_encoding = nil @debugging = false + @ignore_operation_servers = false @inject_format = false @force_ending_format = false @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) @@ -197,6 +206,7 @@ def base_path=(base_path) # Returns base URL for specified operation based on server settings def base_url(operation = nil) + return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers if operation_server_settings.key?(operation) then index = server_operation_index.fetch(operation, server_index) server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) diff --git a/lib/ynab/models/existing_transaction.rb b/lib/ynab/models/existing_transaction.rb index c6eef1f..e91e116 100644 --- a/lib/ynab/models/existing_transaction.rb +++ b/lib/ynab/models/existing_transaction.rb @@ -20,7 +20,7 @@ class ExistingTransaction # The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. attr_accessor :amount - # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. + # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. attr_accessor :payee_id # The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. diff --git a/lib/ynab/models/new_transaction.rb b/lib/ynab/models/new_transaction.rb index 4df8740..0a8b41e 100644 --- a/lib/ynab/models/new_transaction.rb +++ b/lib/ynab/models/new_transaction.rb @@ -20,7 +20,7 @@ class NewTransaction # The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. attr_accessor :amount - # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. + # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. attr_accessor :payee_id # The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. diff --git a/lib/ynab/models/post_scheduled_transaction_wrapper.rb b/lib/ynab/models/post_scheduled_transaction_wrapper.rb new file mode 100644 index 0000000..047758d --- /dev/null +++ b/lib/ynab/models/post_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 PostScheduledTransactionWrapper + 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::PostScheduledTransactionWrapper` 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::PostScheduledTransactionWrapper`. 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_scheduled_transaction.rb b/lib/ynab/models/save_scheduled_transaction.rb new file mode 100644 index 0000000..b58c0f0 --- /dev/null +++ b/lib/ynab/models/save_scheduled_transaction.rb @@ -0,0 +1,329 @@ +=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 SaveScheduledTransaction + attr_accessor :account_id + + # The scheduled transaction date in ISO format (e.g. 2016-12-01). + attr_accessor :date + + # The scheduled transaction amount in milliunits format. + attr_accessor :amount + + # The payee for the scheduled transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. + attr_accessor :payee_id + + # The payee name for the the scheduled transaction. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a payee with the same name or (2) creation of a new payee. + attr_accessor :payee_name + + # The category for the scheduled transaction. Credit Card Payment categories are not permitted. Creating a split scheduled transaction is not currently supported. + attr_accessor :category_id + + attr_accessor :memo + + attr_accessor :flag_color + + attr_accessor :frequency + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'account_id' => :'account_id', + :'date' => :'date', + :'amount' => :'amount', + :'payee_id' => :'payee_id', + :'payee_name' => :'payee_name', + :'category_id' => :'category_id', + :'memo' => :'memo', + :'flag_color' => :'flag_color', + :'frequency' => :'frequency' + } + 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 + { + :'account_id' => :'String', + :'date' => :'Date', + :'amount' => :'Integer', + :'payee_id' => :'String', + :'payee_name' => :'String', + :'category_id' => :'String', + :'memo' => :'String', + :'flag_color' => :'TransactionFlagColor', + :'frequency' => :'ScheduledTransactionFrequency' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'payee_id', + :'payee_name', + :'category_id', + :'memo', + :'flag_color', + ]) + 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::SaveScheduledTransaction` 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::SaveScheduledTransaction`. 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?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'payee_id') + 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?(:'memo') + self.memo = attributes[:'memo'] + end + + if attributes.key?(:'flag_color') + self.flag_color = attributes[:'flag_color'] + end + + if attributes.key?(:'frequency') + self.frequency = attributes[:'frequency'] + 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 @account_id.nil? + return false if @date.nil? + return false if !@payee_name.nil? && @payee_name.to_s.length > 50 + return false if !@memo.nil? && @memo.to_s.length > 200 + true + end + + # Custom attribute writer method with validation + # @param [Object] payee_name Value to be assigned + def payee_name=(payee_name) + @payee_name = payee_name + end + + # Custom attribute writer method with validation + # @param [Object] memo Value to be assigned + def memo=(memo) + @memo = memo + 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 && + account_id == o.account_id && + date == o.date && + amount == o.amount && + payee_id == o.payee_id && + payee_name == o.payee_name && + category_id == o.category_id && + memo == o.memo && + flag_color == o.flag_color && + frequency == o.frequency + 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 + [account_id, date, amount, payee_id, payee_name, category_id, memo, flag_color, frequency].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_transaction_with_id_or_import_id.rb b/lib/ynab/models/save_transaction_with_id_or_import_id.rb index c90d2da..d8d992e 100644 --- a/lib/ynab/models/save_transaction_with_id_or_import_id.rb +++ b/lib/ynab/models/save_transaction_with_id_or_import_id.rb @@ -20,7 +20,7 @@ class SaveTransactionWithIdOrImportId # The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. attr_accessor :amount - # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. + # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. attr_accessor :payee_id # The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. diff --git a/lib/ynab/models/save_transaction_with_optional_fields.rb b/lib/ynab/models/save_transaction_with_optional_fields.rb index f41eab4..0c3cb5d 100644 --- a/lib/ynab/models/save_transaction_with_optional_fields.rb +++ b/lib/ynab/models/save_transaction_with_optional_fields.rb @@ -20,7 +20,7 @@ class SaveTransactionWithOptionalFields # The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored. attr_accessor :amount - # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource. + # The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `transfer_payee_id` on the account resource. attr_accessor :payee_id # The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee. diff --git a/lib/ynab/models/scheduled_transaction_frequency.rb b/lib/ynab/models/scheduled_transaction_frequency.rb new file mode 100644 index 0000000..f999749 --- /dev/null +++ b/lib/ynab/models/scheduled_transaction_frequency.rb @@ -0,0 +1,48 @@ +=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 ScheduledTransactionFrequency + NEVER = "never".freeze + DAILY = "daily".freeze + WEEKLY = "weekly".freeze + EVERY_OTHER_WEEK = "everyOtherWeek".freeze + TWICE_A_MONTH = "twiceAMonth".freeze + EVERY4_WEEKS = "every4Weeks".freeze + MONTHLY = "monthly".freeze + EVERY_OTHER_MONTH = "everyOtherMonth".freeze + EVERY3_MONTHS = "every3Months".freeze + EVERY4_MONTHS = "every4Months".freeze + TWICE_A_YEAR = "twiceAYear".freeze + YEARLY = "yearly".freeze + EVERY_OTHER_YEAR = "everyOtherYear".freeze + + def self.all_vars + @all_vars ||= [NEVER, DAILY, WEEKLY, EVERY_OTHER_WEEK, TWICE_A_MONTH, EVERY4_WEEKS, MONTHLY, EVERY_OTHER_MONTH, EVERY3_MONTHS, EVERY4_MONTHS, TWICE_A_YEAR, YEARLY, EVERY_OTHER_YEAR].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ScheduledTransactionFrequency.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ScheduledTransactionFrequency" + end + end +end diff --git a/open_api_spec.yaml b/open_api_spec.yaml index 0b0a6a8..5f9c44b 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.70.0 + version: 1.71.0 servers: - url: https://api.ynab.com/v1 security: @@ -959,8 +959,8 @@ paths: Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, - multiple transactions will be created. Scheduled transactions cannot be - created on this endpoint. + multiple transactions will be created. Scheduled transactions (transactions with a future date) + cannot be created on this endpoint. operationId: createTransaction parameters: - name: budget_id @@ -1469,6 +1469,47 @@ paths: application/json: schema: $ref: "#/components/schemas/ErrorResponse" + post: + tags: + - Scheduled Transactions + summary: Create a single scheduled transaction + description: >- + Creates a single scheduled transaction. + operationId: createScheduledTransaction + 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 + requestBody: + description: >- + The scheduled transaction to create + content: + "application/json": + schema: + $ref: "#/components/schemas/PostScheduledTransactionWrapper" + required: true + responses: + "201": + description: The scheduled transaction was successfully created + 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" + x-codegen-request-body-name: data /budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id}: get: tags: @@ -2401,7 +2442,7 @@ components: The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as - `tranfer_payee_id` on the account resource. + `transfer_payee_id` on the account resource. format: uuid payee_name: maxLength: 50 @@ -2875,6 +2916,64 @@ components: properties: scheduled_transaction: $ref: "#/components/schemas/ScheduledTransactionDetail" + PostScheduledTransactionWrapper: + required: + - scheduled_transaction + type: object + properties: + scheduled_transaction: + $ref: "#/components/schemas/SaveScheduledTransaction" + SaveScheduledTransaction: + required: + - account_id + - date + type: object + properties: + account_id: + type: string + format: uuid + date: + type: string + description: >- + The scheduled transaction date in ISO format (e.g. 2016-12-01). + format: date + amount: + type: integer + description: >- + The scheduled transaction amount in milliunits format. + format: int64 + payee_id: + type: string + nullable: true + description: >- + The payee for the scheduled transaction. To create a transfer between two + accounts, use the account transfer payee pointing to the target + account. Account transfer payees are specified as + `transfer_payee_id` on the account resource. + format: uuid + payee_name: + maxLength: 50 + type: string + nullable: true + description: >- + The payee name for the the scheduled transaction. If a `payee_name` value is provided and `payee_id` + has a null value, the `payee_name` value will be used to resolve the + payee by either (1) a payee with the same name or (2) creation of a new payee. + category_id: + type: string + nullable: true + description: >- + The category for the scheduled transaction. Credit Card Payment categories are not permitted. + Creating a split scheduled transaction is not currently supported. + format: uuid + memo: + maxLength: 200 + type: string + nullable: true + flag_color: + $ref: "#/components/schemas/TransactionFlagColor" + frequency: + $ref: "#/components/schemas/ScheduledTransactionFrequency" ScheduledTransactionSummary: required: - account_id @@ -3127,6 +3226,23 @@ components: - cleared - uncleared - reconciled + ScheduledTransactionFrequency: + type: string + description: The scheduled transaction frequency + enum: + - never + - daily + - weekly + - everyOtherWeek + - twiceAMonth + - every4Weeks + - monthly + - everyOtherMonth + - every3Months + - every4Months + - twiceAYear + - yearly + - everyOtherYear securitySchemes: bearer: type: http diff --git a/spec/api/scheduled_transactions_spec.rb b/spec/api/scheduled_transactions_spec.rb index 079c970..255f30f 100644 --- a/spec/api/scheduled_transactions_spec.rb +++ b/spec/api/scheduled_transactions_spec.rb @@ -34,7 +34,7 @@ end end - describe 'GET /budgets/{budget_id}/transactions' do + describe 'GET /budgets/{budget_id}/scheduled_transactions' do it 'returns a list of transactions' do VCR.use_cassette("scheduled_transactions") do response = instance.get_scheduled_transactions(budget_id) @@ -44,7 +44,7 @@ end end - describe 'GET /budgets/{budget_id}/transaction/{payee_id}' do + describe 'GET /budgets/{budget_id}/scheduled_transactions/{payee_id}' do it 'returns a payee' do VCR.use_cassette("scheduled_transaction") do response = instance.get_scheduled_transaction_by_id(budget_id, '1a8e4929-3ad1-4859-8443-2aeeab0684ab') @@ -53,4 +53,22 @@ end end end + + describe 'POST /budgets/{budget_id}/scheduled_transactions' do + it 'creates a scheduled transaction' do + VCR.use_cassette("create_scheduled_transaction") do + response = instance.create_scheduled_transaction(budget_id, { + scheduled_transaction: { + date: "#{Time.now.year + 1}-01-01", + account_id: '49b0c987-7d2b-46ec-ba14-f8a7e79fb830', + amount: 20000, + frequency: 'weekly', + } + }) + expect(client.last_request.response.options[:code]).to be 201 + expect(response.data.scheduled_transaction).to be + expect(response.data.scheduled_transaction.amount).to eq 20000 + end + end + end end diff --git a/spec/fixtures/vcr_cassettes/create_scheduled_transaction.yml b/spec/fixtures/vcr_cassettes/create_scheduled_transaction.yml new file mode 100644 index 0000000..c966786 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/create_scheduled_transaction.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/scheduled_transactions + body: + encoding: UTF-8 + string: '{"scheduled_transaction":{"date":"2025-01-01","account_id":"49b0c987-7d2b-46ec-ba14-f8a7e79fb830","amount":20000,"frequency":"weekly"}}' + headers: + User-Agent: + - api_client/ruby/3.2.0 + Content-Type: + - application/json + Accept: + - application/json + Authorization: + - Bearer 9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045 + Expect: + - '' + response: + status: + code: 201 + message: Created + headers: + x-frame-options: + - deny + x-xss-protection: + - '0' + x-content-type-options: + - nosniff + x-download-options: + - noopen + x-permitted-cross-domain-policies: + - none + referrer-policy: + - strict-origin-when-cross-origin + content-type: + - application/json; charset=utf-8 + vary: + - Accept-Encoding, Origin + etag: + - W/"a2fe3b102465b2515af0f411970ca861" + cache-control: + - max-age=0, private, must-revalidate + x-request-id: + - 0ccaa271-1563-4ab8-a6ad-db09893e62db + x-runtime: + - '0.104987' + server-timing: + - start_processing.action_controller;dur=0.01, sql.active_record;dur=31.01, + instantiation.active_record;dur=0.56, cache_read.active_support;dur=0.21, + cache_fetch_hit.active_support;dur=0.00, transaction.active_record;dur=26.93, + render.active_model_serializers;dur=15.03, process_action.action_controller;dur=50.91 + Content-Length: + - '463' + body: + encoding: ASCII-8BIT + string: '{"data":{"scheduled_transaction":{"id":"5901eada-db36-4d95-b737-c1a5cc43a915","date_first":"2025-01-01","date_next":"2025-01-01","frequency":"weekly","amount":20000,"memo":null,"flag_color":null,"flag_name":null,"account_id":"49b0c987-7d2b-46ec-ba14-f8a7e79fb830","account_name":"Checking","payee_id":null,"payee_name":null,"category_id":null,"category_name":"Uncategorized","transfer_account_id":null,"deleted":false,"subtransactions":[]},"server_knowledge":64}}' + http_version: '1.1' + adapter_metadata: + effective_url: http://localhost:3000/papi/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/scheduled_transactions + recorded_at: Mon, 08 Jul 2024 23:16:33 GMT +recorded_with: VCR 6.2.0 diff --git a/ynab.gemspec b/ynab.gemspec index 93efa76..397bb60 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 Endpoints Ruby Gem" - s.description = "Ruby gem wrapper for the YNAB API. Read the documentation at https://api.ynab.com Generated from server specification version 1.70.0 using OpenAPI Generator version 7.6.0." + s.summary = "YNAB API Client for Ruby" + s.description = "Ruby gem wrapper for the YNAB API. Generated from server specification version 1.71.0 using OpenAPI Generator version 7.7.0." s.license = "Apache-2.0" s.required_ruby_version = ">= 3.3" s.metadata = {}