tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
AffiliateInfo.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
7
11 AffiliateInfo() = default;
12 explicit AffiliateInfo(const nl::json& json) {
13 fromJson(json);
14 }
15
18
21
23 std::int32_t commissionPerMille{};
24
26 std::int32_t amount{};
27
29 std::int32_t nanostarAmount{};
30
33 nl::json toJson() const {
34 nl::json json = nl::json::object();
35 OBJECT_SERIALIZE_FIELD_PTR(json, "affiliate_user", affiliateUser);
36 OBJECT_SERIALIZE_FIELD_PTR(json, "affiliate_chat", affiliateChat);
37 OBJECT_SERIALIZE_FIELD(json, "commission_per_mille", commissionPerMille);
38 OBJECT_SERIALIZE_FIELD(json, "amount", amount);
39 OBJECT_SERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount);
40 return json;
41 }
42
44 void fromJson(const nl::json& json) {
45 OBJECT_DESERIALIZE_FIELD_PTR(json, "affiliate_user", affiliateUser, true);
46 OBJECT_DESERIALIZE_FIELD_PTR(json, "affiliate_chat", affiliateChat, true);
47 OBJECT_DESERIALIZE_FIELD(json, "commission_per_mille", commissionPerMille, 0, false);
48 OBJECT_DESERIALIZE_FIELD(json, "amount", amount, 0, false);
49 OBJECT_DESERIALIZE_FIELD(json, "nanostar_amount", nanostarAmount, 0, true);
50 }
51 };
52
53}
#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
Contains information about the affiliate that received a commission via a transaction https://core....
Ptr< User > affiliateUser
Optional. The bot or user that received an affiliate commission.
std::int32_t amount
Integer amount of Telegram Stars received by the affiliate from the transaction; can be negative for ...
nl::json toJson() const
Serializes this object to JSON.
Ptr< Chat > affiliateChat
Optional. The chat that received an affiliate commission.
std::int32_t nanostarAmount
Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; can be negat...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::int32_t commissionPerMille
The number of Telegram Stars received by the affiliate for each 1000 Stars received by the bot.
AffiliateInfo(const nl::json &json)