crypto_pay_api/models/check/
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
9use super::CheckStatus;
10
11#[derive(Debug, Serialize)]
12pub struct CreateCheckParams {
13    /// Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet).
14    pub(crate) asset: CryptoCurrencyCode,
15
16    /// Amount of the check in float. For example: 125.50
17    #[serde(serialize_with = "serialize_decimal_to_string")]
18    pub(crate) amount: Decimal,
19
20    /// Optional. ID of the user who will be able to activate the check.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub(crate) pin_to_user_id: Option<u64>,
23
24    /// Optional. A user with the specified username will be able to activate the check.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub(crate) pin_to_username: Option<String>,
27}
28
29#[derive(Debug, Default, Serialize)]
30pub struct GetChecksParams {
31    /// Optional. Cryptocurrency alphabetic code. Supported assets: “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC” (and “JET” for testnet).
32    /// Defaults to all currencies.
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub(crate) asset: Option<CryptoCurrencyCode>,
35
36    /// Optional. List of check IDs separated by comma.
37    #[serde(
38        serialize_with = "serialize_comma_separated_list",
39        skip_serializing_if = "GetChecksParams::should_skip_check_ids"
40    )]
41    pub(crate) check_ids: Option<Vec<u64>>,
42
43    /// Optional. Status of check to be returned. Available statuses: “active” and “activated”.
44    /// Defaults to all statuses.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub(crate) status: Option<CheckStatus>,
47
48    /// Optional. Offset needed to return a specific subset of check.
49    /// Defaults to 0.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub(crate) offset: Option<u32>,
52
53    /// Optional. Number of check to be returned. Values between 1-1000 are accepted.
54    /// Defaults to 100.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub(crate) count: Option<u16>,
57}
58
59impl GetChecksParams {
60    fn should_skip_check_ids(check_ids: &Option<Vec<u64>>) -> bool {
61        !matches!(check_ids, Some(check_ids) if !check_ids.is_empty())
62    }
63}
64
65#[derive(Debug, Serialize)]
66pub struct DeleteCheckParams {
67    pub check_id: u64,
68}