Skip to content

Commit

Permalink
Generate from spec version 1.72.0 - get txns by month
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Jul 11, 2024
1 parent 86d9dd4 commit 0b24e62
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ynab (3.1.0)
ynab (3.2.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The following methods are available in this library.
| **Transactions** | [transactions.get_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions) | Returns budget transactions |
| | [transactions.get_transactions_by_account(budget_id, account_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions_by_account) | Returns all transactions for a specified account |
| | [transactions.get_transactions_by_category(budget_id, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions_by_category) | Returns all transactions for a specified category |
| | [transactions.get_transactions_by_month(budget_id, month)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions_by_month) | Returns all transactions for a specified month |
| | [transactions.get_transaction_by_id(budget_id, transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transaction_by_id) | Returns a single transaction |
| | [transactions.create_transaction(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates a single transaction |
| | [transactions.create_transactions(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates multiple transactions |
Expand Down
24 changes: 24 additions & 0 deletions docs/TransactionsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All URIs are relative to *https://api.ynab.com/v1*
| [**get_transactions**](TransactionsApi.md#get_transactions) | **GET** /budgets/{budget_id}/transactions | List transactions |
| [**get_transactions_by_account**](TransactionsApi.md#get_transactions_by_account) | **GET** /budgets/{budget_id}/accounts/{account_id}/transactions | List account transactions |
| [**get_transactions_by_category**](TransactionsApi.md#get_transactions_by_category) | **GET** /budgets/{budget_id}/categories/{category_id}/transactions | List category transactions, excluding any pending transactions |
| [**get_transactions_by_month**](TransactionsApi.md#get_transactions_by_month) | **GET** /budgets/{budget_id}/months/{month}/transactions | List transactions in month, excluding any pending transactions |
| [**get_transactions_by_payee**](TransactionsApi.md#get_transactions_by_payee) | **GET** /budgets/{budget_id}/payees/{payee_id}/transactions | List payee transactions, excluding any pending transactions |
| [**import_transactions**](TransactionsApi.md#import_transactions) | **POST** /budgets/{budget_id}/transactions/import | Import transactions |
| [**update_transaction**](TransactionsApi.md#update_transaction) | **PUT** /budgets/{budget_id}/transactions/{transaction_id} | Updates an existing transaction |
Expand Down Expand Up @@ -144,6 +145,29 @@ Returns all transactions for a specified category
[**HybridTransactionsResponse**](HybridTransactionsResponse.md)


## get_transactions_by_month

> <HybridTransactionsResponse> get_transactions_by_month(budget_id, month, opts)
List transactions in month, excluding any pending transactions

Returns all transactions for a specified month

### Parameters

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **budget_id** | **String** | The id of the budget. \&quot;last-used\&quot; can be used to specify the last used budget and \&quot;default\&quot; can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget). | |
| **month** | **String** | The budget month in ISO format (e.g. 2016-12-01) (\&quot;current\&quot; can also be used to specify the current calendar month (UTC)) | |
| **since_date** | **Date** | If specified, only transactions on or after this date will be included. The date should be ISO formatted (e.g. 2016-12-30). | [optional] |
| **type** | **String** | If specified, only transactions of the specified type will be included. \&quot;uncategorized\&quot; and \&quot;unapproved\&quot; are currently supported. | [optional] |
| **last_knowledge_of_server** | **Integer** | The starting server knowledge. If provided, only entities that have changed since &#x60;last_knowledge_of_server&#x60; will be included. | [optional] |

### Return type

[**HybridTransactionsResponse**](HybridTransactionsResponse.md)


## get_transactions_by_payee

> <HybridTransactionsResponse> get_transactions_by_payee(budget_id, payee_id, opts)
Expand Down
78 changes: 78 additions & 0 deletions lib/ynab/api/transactions_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,84 @@ def get_transactions_by_category_with_http_info(budget_id, category_id, opts = {
return data, status_code, headers
end

# List transactions in month, excluding any pending transactions
# Returns all transactions for a specified month
# @param budget_id [String] The id of the budget. \&quot;last-used\&quot; can be used to specify the last used budget and \&quot;default\&quot; can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
# @param month [String] The budget month in ISO format (e.g. 2016-12-01) (\&quot;current\&quot; can also be used to specify the current calendar month (UTC))
# @param [Hash] opts the optional parameters
# @option opts [Date] :since_date If specified, only transactions on or after this date will be included. The date should be ISO formatted (e.g. 2016-12-30).
# @option opts [String] :type If specified, only transactions of the specified type will be included. \&quot;uncategorized\&quot; and \&quot;unapproved\&quot; are currently supported.
# @option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since &#x60;last_knowledge_of_server&#x60; will be included.
# @return [HybridTransactionsResponse]
def get_transactions_by_month(budget_id, month, opts = {})
data, _status_code, _headers = get_transactions_by_month_with_http_info(budget_id, month, opts)
data
end

# List transactions in month, excluding any pending transactions
# Returns all transactions for a specified month
# @param budget_id [String] The id of the budget. \&quot;last-used\&quot; can be used to specify the last used budget and \&quot;default\&quot; can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
# @param month [String] The budget month in ISO format (e.g. 2016-12-01) (\&quot;current\&quot; can also be used to specify the current calendar month (UTC))
# @param [Hash] opts the optional parameters
# @option opts [Date] :since_date If specified, only transactions on or after this date will be included. The date should be ISO formatted (e.g. 2016-12-30).
# @option opts [String] :type If specified, only transactions of the specified type will be included. \&quot;uncategorized\&quot; and \&quot;unapproved\&quot; are currently supported.
# @option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since &#x60;last_knowledge_of_server&#x60; will be included.
# @return [Array<(HybridTransactionsResponse, Integer, Hash)>] HybridTransactionsResponse data, response status code and response headers
def get_transactions_by_month_with_http_info(budget_id, month, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TransactionsApi.get_transactions_by_month ...'
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 TransactionsApi.get_transactions_by_month"
end
# verify the required parameter 'month' is set
if @api_client.config.client_side_validation && month.nil?
fail ArgumentError, "Missing the required parameter 'month' when calling TransactionsApi.get_transactions_by_month"
end
# resource path
local_var_path = '/budgets/{budget_id}/months/{month}/transactions'.sub('{' + 'budget_id' + '}', CGI.escape(budget_id.to_s)).sub('{' + 'month' + '}', CGI.escape(month.to_s))

# query parameters
query_params = opts[:query_params] || {}
query_params[:'since_date'] = opts[:'since_date'] if !opts[:'since_date'].nil?
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
query_params[:'last_knowledge_of_server'] = opts[:'last_knowledge_of_server'] if !opts[:'last_knowledge_of_server'].nil?

# 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] || 'HybridTransactionsResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['bearer']

new_options = opts.merge(
:operation => :"TransactionsApi.get_transactions_by_month",
: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(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: TransactionsApi#get_transactions_by_month\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# List payee transactions, excluding any pending transactions
# Returns all transactions for a specified payee
# @param budget_id [String] The id of the budget. \&quot;last-used\&quot; can be used to specify the last used budget and \&quot;default\&quot; can be used if default budget selection is enabled (see: https://api.ynab.com/#oauth-default-budget).
Expand Down
72 changes: 71 additions & 1 deletion open_api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.71.0
version: 1.72.0
servers:
- url: https://api.ynab.com/v1
security:
Expand Down Expand Up @@ -1425,6 +1425,76 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/budgets/{budget_id}/months/{month}/transactions:
get:
tags:
- Transactions
summary: List transactions in month, excluding any pending transactions
description: Returns all transactions for a specified month
operationId: getTransactionsByMonth
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: month
in: path
description: >-
The budget month in ISO format (e.g. 2016-12-01) ("current" can also
be used to specify the current calendar month (UTC))
required: true
schema:
type: string
- name: since_date
in: query
description: >-
If specified, only transactions on or after this date will be
included. The date should be ISO formatted (e.g. 2016-12-30).
schema:
type: string
format: date
- name: type
in: query
description: >-
If specified, only transactions of the specified type will be
included. "uncategorized" and "unapproved" are currently supported.
schema:
type: string
enum:
- uncategorized
- unapproved
- name: last_knowledge_of_server
in: query
description: >-
The starting server knowledge. If provided, only entities that have
changed since `last_knowledge_of_server` will be included.
schema:
type: integer
format: int64
responses:
"200":
description: The list of requested transactions
content:
application/json:
schema:
$ref: "#/components/schemas/HybridTransactionsResponse"
"404":
description: No transactions were found
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
default:
description: An error occurred
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/budgets/{budget_id}/scheduled_transactions:
get:
tags:
Expand Down
10 changes: 10 additions & 0 deletions spec/api/transactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
end
end

describe 'GET /budgets/{budget_id}/months/{month}/transactions' do
it 'returns a list of transactions for a month' do
VCR.use_cassette("month_transactions") do
response = instance.get_transactions_by_month(budget_id, "2024-07-01")
expect(client.last_request.response.options[:code]).to be 200
expect(response.data.transactions.length).to be 2
end
end
end

describe 'GET /budgets/{budget_id}/transaction/{transaction_id}' do
it 'returns a transaction' do
VCR.use_cassette("transaction") do
Expand Down
46 changes: 46 additions & 0 deletions spec/fixtures/vcr_cassettes/month_transactions.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ynab.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.email = ["[email protected]"]
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. Generated from server specification version 1.71.0 using OpenAPI Generator version 7.7.0."
s.description = "Ruby gem wrapper for the YNAB API. Generated from server specification version 1.72.0 using OpenAPI Generator version 7.7.0."
s.license = "Apache-2.0"
s.required_ruby_version = ">= 3.3"
s.metadata = {}
Expand Down

0 comments on commit 0b24e62

Please sign in to comment.