rtdlib/types/
payment_receipt.rs1
2use crate::types::*;
3use crate::errors::*;
4use uuid::Uuid;
5
6
7
8
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
11pub struct PaymentReceipt {
12 #[doc(hidden)]
13 #[serde(rename(serialize = "@type", deserialize = "@type"))]
14 td_name: String,
15 #[doc(hidden)]
16 #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
17 extra: Option<String>,
18 title: String,
20 description: String,
22 photo: Option<Photo>,
24 date: i64,
26 seller_bot_user_id: i64,
28 payments_provider_user_id: i64,
30 invoice: Invoice,
32 order_info: Option<OrderInfo>,
34 shipping_option: Option<ShippingOption>,
36 credentials_title: String,
38 tip_amount: i64,
40
41}
42
43impl RObject for PaymentReceipt {
44 #[doc(hidden)] fn td_name(&self) -> &'static str { "paymentReceipt" }
45 #[doc(hidden)] fn extra(&self) -> Option<String> { self.extra.clone() }
46 fn to_json(&self) -> RTDResult<String> { Ok(serde_json::to_string(self)?) }
47}
48
49
50
51impl PaymentReceipt {
52 pub fn from_json<S: AsRef<str>>(json: S) -> RTDResult<Self> { Ok(serde_json::from_str(json.as_ref())?) }
53 pub fn builder() -> RTDPaymentReceiptBuilder {
54 let mut inner = PaymentReceipt::default();
55 inner.td_name = "paymentReceipt".to_string();
56 inner.extra = Some(Uuid::new_v4().to_string());
57 RTDPaymentReceiptBuilder { inner }
58 }
59
60 pub fn title(&self) -> &String { &self.title }
61
62 pub fn description(&self) -> &String { &self.description }
63
64 pub fn photo(&self) -> &Option<Photo> { &self.photo }
65
66 pub fn date(&self) -> i64 { self.date }
67
68 pub fn seller_bot_user_id(&self) -> i64 { self.seller_bot_user_id }
69
70 pub fn payments_provider_user_id(&self) -> i64 { self.payments_provider_user_id }
71
72 pub fn invoice(&self) -> &Invoice { &self.invoice }
73
74 pub fn order_info(&self) -> &Option<OrderInfo> { &self.order_info }
75
76 pub fn shipping_option(&self) -> &Option<ShippingOption> { &self.shipping_option }
77
78 pub fn credentials_title(&self) -> &String { &self.credentials_title }
79
80 pub fn tip_amount(&self) -> i64 { self.tip_amount }
81
82}
83
84#[doc(hidden)]
85pub struct RTDPaymentReceiptBuilder {
86 inner: PaymentReceipt
87}
88
89impl RTDPaymentReceiptBuilder {
90 pub fn build(&self) -> PaymentReceipt { self.inner.clone() }
91
92
93 pub fn title<T: AsRef<str>>(&mut self, title: T) -> &mut Self {
94 self.inner.title = title.as_ref().to_string();
95 self
96 }
97
98
99 pub fn description<T: AsRef<str>>(&mut self, description: T) -> &mut Self {
100 self.inner.description = description.as_ref().to_string();
101 self
102 }
103
104
105 pub fn photo<T: AsRef<Photo>>(&mut self, photo: T) -> &mut Self {
106 self.inner.photo = Some(photo.as_ref().clone());
107 self
108 }
109
110
111 pub fn date(&mut self, date: i64) -> &mut Self {
112 self.inner.date = date;
113 self
114 }
115
116
117 pub fn seller_bot_user_id(&mut self, seller_bot_user_id: i64) -> &mut Self {
118 self.inner.seller_bot_user_id = seller_bot_user_id;
119 self
120 }
121
122
123 pub fn payments_provider_user_id(&mut self, payments_provider_user_id: i64) -> &mut Self {
124 self.inner.payments_provider_user_id = payments_provider_user_id;
125 self
126 }
127
128
129 pub fn invoice<T: AsRef<Invoice>>(&mut self, invoice: T) -> &mut Self {
130 self.inner.invoice = invoice.as_ref().clone();
131 self
132 }
133
134
135 pub fn order_info<T: AsRef<OrderInfo>>(&mut self, order_info: T) -> &mut Self {
136 self.inner.order_info = Some(order_info.as_ref().clone());
137 self
138 }
139
140
141 pub fn shipping_option<T: AsRef<ShippingOption>>(&mut self, shipping_option: T) -> &mut Self {
142 self.inner.shipping_option = Some(shipping_option.as_ref().clone());
143 self
144 }
145
146
147 pub fn credentials_title<T: AsRef<str>>(&mut self, credentials_title: T) -> &mut Self {
148 self.inner.credentials_title = credentials_title.as_ref().to_string();
149 self
150 }
151
152
153 pub fn tip_amount(&mut self, tip_amount: i64) -> &mut Self {
154 self.inner.tip_amount = tip_amount;
155 self
156 }
157
158}
159
160impl AsRef<PaymentReceipt> for PaymentReceipt {
161 fn as_ref(&self) -> &PaymentReceipt { self }
162}
163
164impl AsRef<PaymentReceipt> for RTDPaymentReceiptBuilder {
165 fn as_ref(&self) -> &PaymentReceipt { &self.inner }
166}
167
168
169