ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
currency_service Class Reference

Service for managing currencies. More...

#include <currency_service.hpp>

Collaboration diagram for currency_service:
Collaboration graph

Public Types

using context = ores::database::context
 

Public Member Functions

 currency_service (context ctx)
 Constructs a currency_service with a database context.
 
std::vector< domain::currencylist_currencies (std::uint32_t offset, std::uint32_t limit)
 Lists currencies with pagination support.
 
std::uint32_t count_currencies ()
 Gets the total count of active currencies.
 
void save_currency (const domain::currency &currency)
 Saves a currency (creates or updates).
 
void delete_currency (const std::string &iso_code)
 Deletes a currency by its ISO code.
 
std::optional< domain::currencyget_currency (const std::string &iso_code)
 Retrieves a single currency by its ISO code.
 
std::vector< domain::currencyget_currency_history (const std::string &iso_code)
 Retrieves all historical versions of a currency.
 
std::optional< domain::currency_version_historyget_currency_version_history (const std::string &iso_code)
 Retrieves currency version history with version metadata.
 

Detailed Description

Service for managing currencies.

Provides a higher-level interface for currency operations, wrapping the underlying repository.

Constructor & Destructor Documentation

◆ currency_service()

currency_service ( context  ctx)
explicit

Constructs a currency_service with a database context.

Parameters
ctxThe database context for operations.

Member Function Documentation

◆ list_currencies()

std::vector< domain::currency > list_currencies ( std::uint32_t  offset,
std::uint32_t  limit 
)

Lists currencies with pagination support.

Parameters
offsetNumber of records to skip.
limitMaximum number of records to return.
Returns
Vector of currencies for the requested page.

◆ count_currencies()

std::uint32_t count_currencies ( )

Gets the total count of active currencies.

Returns
Total number of active currencies.

◆ save_currency()

void save_currency ( const domain::currency currency)

Saves a currency (creates or updates).

Parameters
currencyThe currency to save.
Exceptions
std::exceptionon failure.

◆ delete_currency()

void delete_currency ( const std::string &  iso_code)

Deletes a currency by its ISO code.

Parameters
iso_codeThe ISO code of the currency to delete.
Exceptions
std::exceptionon failure.

◆ get_currency()

std::optional< domain::currency > get_currency ( const std::string &  iso_code)

Retrieves a single currency by its ISO code.

Parameters
iso_codeThe ISO code of the currency.
Returns
The currency if found, std::nullopt otherwise.

◆ get_currency_history()

std::vector< domain::currency > get_currency_history ( const std::string &  iso_code)

Retrieves all historical versions of a currency.

Parameters
iso_codeThe ISO code of the currency.
Returns
Vector of all historical versions of the currency.

◆ get_currency_version_history()

std::optional< domain::currency_version_history > get_currency_version_history ( const std::string &  iso_code)

Retrieves currency version history with version metadata.

Converts raw currency records to currency_version objects with version numbers, recorded_by, and recorded_at metadata. Versions are ordered from newest to oldest.

Parameters
iso_codeThe ISO code of the currency.
Returns
The version history, or std::nullopt if currency not found.