Class: PbAPI::Resources::TransactionResource
- Inherits:
-
PbAPI::Resource
- Object
- PbAPI::Resource
- PbAPI::Resources::TransactionResource
- Defined in:
- lib/pb_api/resources/transaction_resource.rb
Overview
TransactionResource is responsible for fetching transaction data from the API. It supports three endpoints:
- Standard transactions endpoint (with a date interval).
- Interim transactions endpoint (for data from the last day up to today).
- Final transactions endpoint (for final transactions on the last day).
Each endpoint is paginated. The methods in this class return an Enumerator that lazily fetches and yields transactions page by page.
Constant Summary
Constants inherited from PbAPI::Resource
PbAPI::Resource::DATE_FORMAT_STRING
Instance Attribute Summary
Attributes inherited from PbAPI::Resource
Instance Method Summary collapse
-
#common(uri:, query_params:) ⇒ Enumerator
Executes a paginated request for transactions.
-
#list(start_date:, end_date: nil, account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves transactions for a specified date range.
-
#list_final(account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves final transactions.
-
#list_interim(account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves interim transactions.
Methods inherited from PbAPI::Resource
Constructor Details
This class inherits a constructor from PbAPI::Resource
Instance Method Details
#common(uri:, query_params:) ⇒ Enumerator
Executes a paginated request for transactions.
27 28 29 30 31 32 |
# File 'lib/pb_api/resources/transaction_resource.rb', line 27 def common(uri:, query_params:) PbAPI::PaginationHelper .paginate(params_hash: query_params, key: "transactions", type: PbAPI::Models::Transaction) do |params| get_request(uri, params: params) end end |
#list(start_date:, end_date: nil, account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves transactions for a specified date range.
This method is used when you need to filter transactions by a start (and optional end) date. )
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pb_api/resources/transaction_resource.rb', line 53 def list(start_date:, end_date: nil, account: nil, next_page_id: nil, results_per_page: 20) query_params = form_query( start_date:, end_date:, account:, follow_id: next_page_id, limit: results_per_page ) common(uri: "statements/transactions", query_params: query_params) end |
#list_final(account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves final transactions.
Final endpoints return transactions for the final (last) day. Like the interim endpoint, date parameters are not required.
95 96 97 98 99 100 101 102 |
# File 'lib/pb_api/resources/transaction_resource.rb', line 95 def list_final(account: nil, next_page_id: nil, results_per_page: 20) query_params = form_query( account: account, follow_id: next_page_id, limit: results_per_page ) common(uri: "statements/transactions/final", query_params: query_params) end |
#list_interim(account: nil, next_page_id: nil, results_per_page: 20) ⇒ Enumerator
Retrieves interim transactions.
Interim endpoints do not require date parameters; they return transactions for the period from the last day to today.
75 76 77 78 79 80 81 82 |
# File 'lib/pb_api/resources/transaction_resource.rb', line 75 def list_interim(account: nil, next_page_id: nil, results_per_page: 20) query_params = form_query( account: account, follow_id: next_page_id, limit: results_per_page ) common(uri: "statements/transactions/interim", query_params: query_params) end |