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_RISK_MESSAGING_CURRENCY_PROTOCOL_HPP
21#define ORES_RISK_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.risk/domain/currency.hpp"
32
33namespace ores::risk::messaging {
34
42 std::uint32_t offset = 0;
44 std::uint32_t limit = 100;
45
53 std::vector<std::byte> serialize() const;
54
58 static std::expected<get_currencies_request, comms::messaging::error_code>
59 deserialize(std::span<const std::byte> data);
60};
61
62std::ostream& operator<<(std::ostream& s, const get_currencies_request& v);
63
68 std::vector<domain::currency> currencies;
70 std::uint32_t total_available_count = 0;
71
102 std::vector<std::byte> serialize() const;
103
107 static std::expected<get_currencies_response, comms::messaging::error_code>
108 deserialize(std::span<const std::byte> data);
109};
110
111std::ostream& operator<<(std::ostream& s, const get_currencies_response& v);
112
121 domain::currency currency;
122
126 std::vector<std::byte> serialize() const;
127
131 static std::expected<save_currency_request, comms::messaging::error_code>
132 deserialize(std::span<const std::byte> data);
133};
134
135std::ostream& operator<<(std::ostream& s, const save_currency_request& v);
136
141 bool success;
142 std::string message;
143
147 std::vector<std::byte> serialize() const;
148
152 static std::expected<save_currency_response, comms::messaging::error_code>
153 deserialize(std::span<const std::byte> data);
154};
155
156std::ostream& operator<<(std::ostream& s, const save_currency_response& v);
157
165 std::vector<std::string> iso_codes;
166
176 std::vector<std::byte> serialize() const;
177
181 static std::expected<delete_currency_request, comms::messaging::error_code>
182 deserialize(std::span<const std::byte> data);
183};
184
185std::ostream& operator<<(std::ostream& s, const delete_currency_request& v);
186
191 std::string iso_code;
192 bool success;
193 std::string message;
194};
195
196std::ostream& operator<<(std::ostream& s, const delete_currency_result& v);
197
205 std::vector<delete_currency_result> results;
206
219 std::vector<std::byte> serialize() const;
220
224 static std::expected<delete_currency_response, comms::messaging::error_code>
225 deserialize(std::span<const std::byte> data);
226};
227
228std::ostream& operator<<(std::ostream& s, const delete_currency_response& v);
229
230}
231
232#endif
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:30
Request to retrieve currencies with pagination support.
Definition currency_protocol.hpp:40
std::uint32_t limit
Maximum number of records to return.
Definition currency_protocol.hpp:44
static std::expected< get_currencies_request, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:230
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:222
std::uint32_t offset
Number of records to skip (0-based)
Definition currency_protocol.hpp:42
Response containing currencies with pagination metadata.
Definition currency_protocol.hpp:67
std::uint32_t total_available_count
Total number of currencies available (not just in this page)
Definition currency_protocol.hpp:70
static std::expected< get_currencies_response, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:280
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:250
Request to save a currency (create or update).
Definition currency_protocol.hpp:120
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:366
static std::expected< save_currency_request, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:373
Response confirming currency save operation.
Definition currency_protocol.hpp:140
static std::expected< save_currency_response, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:394
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:386
Request to delete one or more currencies.
Definition currency_protocol.hpp:164
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition currency_protocol.cpp:113
static std::expected< delete_currency_request, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition currency_protocol.cpp:128
Result for a single currency deletion.
Definition currency_protocol.hpp:190
Response confirming currency deletion(s).
Definition currency_protocol.hpp:204
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition currency_protocol.cpp:161
static std::expected< delete_currency_response, comms::messaging::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition currency_protocol.cpp:178