1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use rust_decimal::Decimal;
use serde::Serialize;
use crate::{
models::{CryptoCurrencyCode, CurrencyType, FiatCurrencyCode, PayButtonName, SwapToAssets},
utils::{serialize_comma_separated_list, serialize_decimal_to_string},
};
use super::InvoiceStatus;
/* #region GetInvoicesParams */
#[derive(Debug, Default, Serialize)]
pub struct GetInvoicesParams {
/// Optional. Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet).
/// Defaults to all currencies.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) asset: Option<CryptoCurrencyCode>,
/// Optional. Fiat currency code. Supported fiat currencies: “USD”, “EUR”, “RUB”, “BYN”, “UAH”, “GBP”, “CNY”, “KZT”, “UZS”, “GEL”, “TRY”, “AMD”, “THB”, “INR”, “BRL”, “IDR”, “AZN”, “AED”, “PLN” and “ILS".
/// Defaults to all currencies.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) fiat: Option<FiatCurrencyCode>,
/// Optional. List of invoice IDs separated by comma.
#[serde(
serialize_with = "serialize_comma_separated_list",
skip_serializing_if = "GetInvoicesParams::should_skip_invoice_ids"
)]
pub(crate) invoice_ids: Option<Vec<u64>>,
/// Optional. Status of invoices to be returned. Available statuses: “active” and “paid”.
/// Defaults to all statuses.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) status: Option<InvoiceStatus>,
/// Optional. Offset needed to return a specific subset of invoices.
/// Defaults to 0.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) offset: Option<u32>,
/// Optional. Number of invoices to be returned. Values between 1-1000 are accepted.
/// Defaults to 100.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) count: Option<u16>,
}
impl GetInvoicesParams {
fn should_skip_invoice_ids(ids: &Option<Vec<u64>>) -> bool {
!matches!(ids, Some(ids) if !ids.is_empty())
}
}
/* #endregion */
/* #region CreateInvoiceParams */
#[derive(Debug, Serialize)]
pub struct CreateInvoiceParams {
/// Optional. Type of the price, can be "crypto" or "fiat". Defaults to crypto.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) currency_type: Option<CurrencyType>,
/// Optional. Required if currency_type is "crypto". Cryptocurrency alphabetic code. Supported assets: "USDT", "TON", "BTC", "ETH", "LTC", "BNB", "TRX" and "USDC".
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) asset: Option<CryptoCurrencyCode>,
/// Optional. Required if currency_type is "fiat". Fiat currency code. Supported fiat currencies: "USD", "EUR", "RUB", "BYN", "UAH", "GBP", "CNY", "KZT", "UZS", "GEL", "TRY", "AMD", "THB", "INR", "BRL", "IDR", "AZN", "AED", "PLN" and "ILS".
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) fiat: Option<FiatCurrencyCode>,
/// Optional. List of cryptocurrency alphabetic codes separated comma. Assets which can be used to pay the invoice. Available only if currency_type is "crypto". Supported assets: "USDT", "TON", "BTC", "ETH", "LTC", "BNB", "TRX" and "USDC" ("JET" for testnet). Defaults to all currencies.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) accept_asset: Option<Vec<CryptoCurrencyCode>>,
/// Amount of the invoice in float. For example: 125.50
#[serde(serialize_with = "serialize_decimal_to_string")]
pub(crate) amount: Decimal,
/// Optional. Description for the invoice. User will see this description when they pay the invoice. Up to 1024 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) description: Option<String>,
/// Optional. Text of the message which will be presented to a user after the invoice is paid. Up to 2048 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) hidden_message: Option<String>,
/// Optional. Label of the button which will be presented to a user after the invoice is paid.
/// Supported names:
/// viewItem – "View Item",
/// openChannel – "View Channel",
/// openBot – "Open Bot",
/// callback – "Return to the bot"
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) paid_btn_name: Option<PayButtonName>,
/// Optional. Required if paid_btn_name is specified. URL opened using the button which will be presented to a user after the invoice is paid.
/// You can set any callback link (for example, a success link or link to homepage).
/// Starts with https or http.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) paid_btn_url: Option<String>,
/// Optional.
/// The asset that will be attempted to be swapped into after the user makes a payment (the swap is not guaranteed). Supported assets: "USDT", "TON", "TRX", "ETH", "SOL", "BTC", "LTC".
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) swap_to: Option<SwapToAssets>,
/// Optional. Any data you want to attach to the invoice (for example, user ID, payment ID, ect).
/// Up to 4kb.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) payload: Option<String>,
/// Optional. Allow a user to add a comment to the payment.
/// Defaults to true.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) allow_comments: Option<bool>,
/// Optional. Allow a user to pay the invoice anonymously.
/// Defaults to true.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) allow_anonymous: Option<bool>,
/// Optional. You can set a payment time limit for the invoice in seconds.
/// Values between 1-2678400 are accepted.
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) expires_in: Option<u32>,
}
/* #endregion */
/* #region DeleteInvoiceParams */
#[derive(Debug, Serialize)]
pub struct DeleteInvoiceParams {
pub(crate) invoice_id: u64,
}