crypto_pay_api/models/transfer/
params.rs

1use rust_decimal::Decimal;
2use serde::Serialize;
3
4use crate::{
5    models::CryptoCurrencyCode,
6    utils::{serialize_comma_separated_list, serialize_decimal_to_string},
7};
8
9#[derive(Debug, Serialize, Default)]
10pub struct GetTransfersParams {
11    /// Optional. Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet).
12    /// Defaults to all currencies.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub(crate) asset: Option<CryptoCurrencyCode>,
15
16    /// Optional. List of transfer IDs separated by comma.
17    #[serde(
18        serialize_with = "serialize_comma_separated_list",
19        skip_serializing_if = "GetTransfersParams::should_skip_transfer_ids"
20    )]
21    pub(crate) transfer_ids: Option<Vec<u64>>,
22
23    /// Optional. Unique UTF-8 transfer string.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub(crate) spend_id: Option<String>,
26
27    /// Optional. Offset needed to return a specific subset of transfers.
28    /// Defaults to 0.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub(crate) offset: Option<u32>,
31
32    /// Optional. Number of transfers to be returned.
33    /// Values between 1-1000 are accepted.
34    /// Defaults to 100.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub(crate) count: Option<u16>,
37}
38
39impl GetTransfersParams {
40    fn should_skip_transfer_ids(ids: &Option<Vec<u64>>) -> bool {
41        !matches!(ids, Some(ids) if !ids.is_empty())
42    }
43}
44
45#[derive(Debug, Serialize)]
46pub struct TransferParams {
47    /// User ID in Telegram. User must have previously used @CryptoBot (@CryptoTestnetBot for testnet).
48    pub(crate) user_id: u64,
49
50    /// Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet).
51    pub(crate) asset: CryptoCurrencyCode,
52
53    /// Amount of the transfer in float.
54    /// The minimum and maximum amount limits for each of the supported assets roughly correspond to 1-25000 USD.
55    /// Use getExchangeRates to convert amounts. For example: 125.50
56    #[serde(serialize_with = "serialize_decimal_to_string")]
57    pub(crate) amount: Decimal,
58
59    /// Random UTF-8 string unique per transfer for idempotent requests.
60    /// The same spend_id can be accepted only once from your app.
61    /// Up to 64 symbols.
62    pub(crate) spend_id: String,
63
64    /// Optional. Comment for the transfer.
65    /// Users will see this comment in the notification about the transfer.
66    /// Up to 1024 symbols.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub(crate) comment: Option<String>,
69
70    /// Optional. Pass true to not send to the user the notification about the transfer.
71    /// Defaults to false.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub(crate) disable_send_notification: Option<bool>,
74}