ORE Studio 0.0.4
Loading...
Searching...
No Matches
currency_service.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_REFDATA_SERVICE_CURRENCY_SERVICE_HPP
21#define ORES_REFDATA_SERVICE_CURRENCY_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include "ores.database/domain/context.hpp"
27#include "ores.refdata/domain/currency.hpp"
28#include "ores.refdata/domain/currency_version_history.hpp"
29#include "ores.refdata/repository/currency_repository.hpp"
30#include "ores.logging/make_logger.hpp"
31
32namespace ores::refdata::service {
33
41private:
42 inline static std::string_view logger_name =
43 "ores.refdata.service.currency_service";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
53
59 explicit currency_service(context ctx);
60
68 std::vector<domain::currency> list_currencies(std::uint32_t offset,
69 std::uint32_t limit);
70
76 std::uint32_t count_currencies();
77
84 void save_currency(const domain::currency& currency);
85
92 void delete_currency(const std::string& iso_code);
93
100 std::optional<domain::currency> get_currency(const std::string& iso_code);
101
108 std::vector<domain::currency> get_currency_history(const std::string& iso_code);
109
120 std::optional<domain::currency_version_history>
121 get_currency_version_history(const std::string& iso_code);
122
123private:
124 context ctx_;
126};
127
128}
129
130#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:30
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:33
Reads and writes currencies off of data storage.
Definition currency_repository.hpp:35
Service for managing currencies.
Definition currency_service.hpp:40
void delete_currency(const std::string &iso_code)
Deletes a currency by its ISO code.
Definition currency_service.cpp:51
std::vector< domain::currency > list_currencies(std::uint32_t offset, std::uint32_t limit)
Lists currencies with pagination support.
Definition currency_service.cpp:31
std::vector< domain::currency > get_currency_history(const std::string &iso_code)
Retrieves all historical versions of a currency.
Definition currency_service.cpp:66
std::optional< domain::currency_version_history > get_currency_version_history(const std::string &iso_code)
Retrieves currency version history with version metadata.
Definition currency_service.cpp:73
std::uint32_t count_currencies()
Gets the total count of active currencies.
Definition currency_service.cpp:38
void save_currency(const domain::currency &currency)
Saves a currency (creates or updates).
Definition currency_service.cpp:43
std::optional< domain::currency > get_currency(const std::string &iso_code)
Retrieves a single currency by its ISO code.
Definition currency_service.cpp:56