ORE Studio 0.0.4
Loading...
Searching...
No Matches
currency_protocol.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_MESSAGING_CURRENCY_PROTOCOL_HPP
21#define ORES_REFDATA_MESSAGING_CURRENCY_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <cstdint>
27#include <expected>
28#include <rfl.hpp>
29#include <rfl/json.hpp>
30#include "ores.comms/messaging/message_types.hpp"
31#include "ores.comms/messaging/message_traits.hpp"
32#include "ores.refdata/domain/currency.hpp"
33
35
43 std::uint32_t offset = 0;
45 std::uint32_t limit = 100;
46
54 std::vector<std::byte> serialize() const;
55
59 static std::expected<get_currencies_request, ores::utility::serialization::error_code>
60 deserialize(std::span<const std::byte> data);
61};
62
63std::ostream& operator<<(std::ostream& s, const get_currencies_request& v);
64
69 std::vector<domain::currency> currencies;
71 std::uint32_t total_available_count = 0;
72
103 std::vector<std::byte> serialize() const;
104
108 static std::expected<get_currencies_response, ores::utility::serialization::error_code>
109 deserialize(std::span<const std::byte> data);
110};
111
112std::ostream& operator<<(std::ostream& s, const get_currencies_response& v);
113
122 domain::currency currency;
123
127 std::vector<std::byte> serialize() const;
128
132 static std::expected<save_currency_request, ores::utility::serialization::error_code>
133 deserialize(std::span<const std::byte> data);
134};
135
136std::ostream& operator<<(std::ostream& s, const save_currency_request& v);
137
142 bool success;
143 std::string message;
144
148 std::vector<std::byte> serialize() const;
149
153 static std::expected<save_currency_response, ores::utility::serialization::error_code>
154 deserialize(std::span<const std::byte> data);
155};
156
157std::ostream& operator<<(std::ostream& s, const save_currency_response& v);
158
166 std::vector<std::string> iso_codes;
167
177 std::vector<std::byte> serialize() const;
178
182 static std::expected<delete_currency_request, ores::utility::serialization::error_code>
183 deserialize(std::span<const std::byte> data);
184};
185
186std::ostream& operator<<(std::ostream& s, const delete_currency_request& v);
187
192 std::string iso_code;
193 bool success;
194 std::string message;
195};
196
197std::ostream& operator<<(std::ostream& s, const delete_currency_result& v);
198
206 std::vector<delete_currency_result> results;
207
220 std::vector<std::byte> serialize() const;
221
225 static std::expected<delete_currency_response, ores::utility::serialization::error_code>
226 deserialize(std::span<const std::byte> data);
227};
228
229std::ostream& operator<<(std::ostream& s, const delete_currency_response& v);
230
231}
232
233namespace ores::comms::messaging {
234
238template<>
239struct message_traits<refdata::messaging::get_currencies_request> {
242 static constexpr message_type request_message_type =
243 message_type::get_currencies_request;
244};
245
249template<>
250struct message_traits<refdata::messaging::save_currency_request> {
253 static constexpr message_type request_message_type =
254 message_type::save_currency_request;
255};
256
260template<>
261struct message_traits<refdata::messaging::delete_currency_request> {
264 static constexpr message_type request_message_type =
265 message_type::delete_currency_request;
266};
267
268}
269
270#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > &stream, boost_severity level)
Inserter for boost_severity enum.
Definition boost_severity.hpp:80
Network messaging infrastructure for the risk module.
Definition country_protocol.hpp:34
Traits template for mapping request types to their response types and message type enum values.
Definition message_traits.hpp:66
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:33
Request to retrieve currencies with pagination support.
Definition currency_protocol.hpp:41
std::uint32_t limit
Maximum number of records to return.
Definition currency_protocol.hpp:45
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:255
static std::expected< get_currencies_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:263
std::uint32_t offset
Number of records to skip (0-based)
Definition currency_protocol.hpp:43
Response containing currencies with pagination metadata.
Definition currency_protocol.hpp:68
std::uint32_t total_available_count
Total number of currencies available (not just in this page)
Definition currency_protocol.hpp:71
static std::expected< get_currencies_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:301
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:283
Request to save a currency (create or update).
Definition currency_protocol.hpp:121
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:337
static std::expected< save_currency_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:344
Response confirming currency save operation.
Definition currency_protocol.hpp:141
static std::expected< save_currency_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:365
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:357
Request to delete one or more currencies.
Definition currency_protocol.hpp:165
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:146
static std::expected< delete_currency_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:161
Result for a single currency deletion.
Definition currency_protocol.hpp:191
Response confirming currency deletion(s).
Definition currency_protocol.hpp:205
static std::expected< delete_currency_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:211
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:194