tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
StarTransaction.hpp
Go to the documentation of this file.
1#pragma once
4#include <vector>
5
6namespace tgbotxx {
7
14 StarTransaction() = default;
15 explicit StarTransaction(const nl::json& json) {
16 fromJson(json);
17 }
18
22 std::string id;
23
25 std::int64_t amount{};
26
28 std::int32_t nanostarAmount{};
29
31 std::time_t date{};
32
35
38
41 nl::json toJson() const {
42 nl::json json = nl::json::object();
43 OBJECT_SERIALIZE_FIELD(json, "id", id);
44 OBJECT_SERIALIZE_FIELD(json, "amount", amount);
45 OBJECT_SERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount);
46 OBJECT_SERIALIZE_FIELD(json, "date", date);
47 OBJECT_SERIALIZE_FIELD_PTR(json, "source", source);
48 OBJECT_SERIALIZE_FIELD_PTR(json, "receiver", receiver);
49 return json;
50 }
51
53 void fromJson(const nl::json& json) {
54 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
55 OBJECT_DESERIALIZE_FIELD(json, "amount", amount, 0, false);
56 OBJECT_DESERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount, 0, true);
57 OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
58 OBJECT_DESERIALIZE_FIELD_PTR(json, "source", source, true);
59 OBJECT_DESERIALIZE_FIELD_PTR(json, "receiver", receiver, true);
60 }
61 };
62
63
64}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment...
nl::json toJson() const
Serializes this object to JSON.
std::string id
Unique identifier of the transaction. Coincides with the identifier of the original transaction for r...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
StarTransaction(const nl::json &json)
std::int32_t nanostarAmount
Optional. The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 ...
std::int64_t amount
Integer amount of Telegram Stars transferred by the transaction.
Ptr< TransactionPartner > receiver
Optional. Receiver of an outgoing transaction (e.g., a user for a purchase refund,...
Ptr< TransactionPartner > source
Optional. Source of an incoming transaction (e.g., a user purchasing goods or services,...
std::time_t date
Date the transaction was created in Unix time.