rustigram_types/suggested_post.rs
1use serde::{Deserialize, Serialize};
2
3/// The price of a suggested post.
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct SuggestedPostPrice {
6 /// Currency in which the post will be paid.
7 ///
8 /// Currently `"XTR"` for Telegram Stars or `"TON"` for toncoins.
9 pub currency: String,
10 /// Amount in the smallest units of the currency.
11 ///
12 /// Stars must be between 5–100,000; nanotoncoins between 10,000,000–10,000,000,000,000.
13 pub amount: i64,
14}
15
16/// Information about a suggested post pending review.
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct SuggestedPostInfo {
19 /// State of the suggested post.
20 ///
21 /// One of `"pending"`, `"approved"`, or `"declined"`.
22 pub state: String,
23 /// Proposed price of the post; absent if the post is unpaid.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub price: Option<SuggestedPostPrice>,
26 /// Proposed Unix timestamp when the post will be sent; absent if no date was specified.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub send_date: Option<i64>,
29}
30
31/// Parameters for a post being suggested by the bot.
32///
33/// Pass this in `suggested_post_parameters` on outgoing send methods.
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct SuggestedPostParameters {
36 /// Proposed price for the post; absent if the post is unpaid.
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub price: Option<SuggestedPostPrice>,
39 /// Proposed Unix send date; must be 300–2,678,400 seconds in the future if set.
40 #[serde(skip_serializing_if = "Option::is_none")]
41 pub send_date: Option<i64>,
42}
43
44/// Service message: a suggested post was approved.
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct SuggestedPostApproved {
47 /// Message containing the suggested post.
48 ///
49 /// Boxed to break the `Message → SuggestedPostApproved → Message` cycle.
50 /// Will not contain `reply_to_message` even if the message itself is a reply.
51 #[serde(skip_serializing_if = "Option::is_none")]
52 pub suggested_post_message: Option<Box<crate::message::Message>>,
53 /// Amount paid for the post.
54 #[serde(skip_serializing_if = "Option::is_none")]
55 pub price: Option<SuggestedPostPrice>,
56 /// Unix timestamp when the post will be published.
57 pub send_date: i64,
58}
59
60/// Service message: approval of a suggested post failed.
61///
62/// Currently only caused by insufficient user funds at the time of approval.
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct SuggestedPostApprovalFailed {
65 /// Message containing the suggested post whose approval failed.
66 ///
67 /// Boxed to break the recursive cycle. Will not contain `reply_to_message`.
68 #[serde(skip_serializing_if = "Option::is_none")]
69 pub suggested_post_message: Option<Box<crate::message::Message>>,
70 /// Expected price of the post.
71 pub price: SuggestedPostPrice,
72}
73
74/// Service message: a suggested post was declined.
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct SuggestedPostDeclined {
77 /// Message containing the suggested post.
78 ///
79 /// Boxed to break the recursive cycle. Will not contain `reply_to_message`.
80 #[serde(skip_serializing_if = "Option::is_none")]
81 pub suggested_post_message: Option<Box<crate::message::Message>>,
82 /// Comment with which the post was declined.
83 #[serde(skip_serializing_if = "Option::is_none")]
84 pub comment: Option<String>,
85}
86
87/// Service message: payment for a suggested post was received.
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct SuggestedPostPaid {
90 /// Message containing the suggested post.
91 ///
92 /// Boxed to break the recursive cycle. Will not contain `reply_to_message`.
93 #[serde(skip_serializing_if = "Option::is_none")]
94 pub suggested_post_message: Option<Box<crate::message::Message>>,
95 /// Currency in which the payment was made (`"XTR"` or `"TON"`).
96 pub currency: String,
97 /// Amount received in nanotoncoins; present only for TON payments.
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub amount: Option<i64>,
100 /// Amount of Telegram Stars received; present only for Star payments.
101 #[serde(skip_serializing_if = "Option::is_none")]
102 pub star_amount: Option<crate::payments::StarAmount>,
103}
104
105/// Service message: payment for a suggested post was refunded.
106#[derive(Debug, Clone, Serialize, Deserialize)]
107pub struct SuggestedPostRefunded {
108 /// Message containing the suggested post.
109 ///
110 /// Boxed to break the recursive cycle. Will not contain `reply_to_message`.
111 #[serde(skip_serializing_if = "Option::is_none")]
112 pub suggested_post_message: Option<Box<crate::message::Message>>,
113 /// Reason for the refund.
114 ///
115 /// One of `"post_deleted"` or `"payment_refunded"`.
116 pub reason: String,
117}