noah_sdk/models/
common.rs

1//! Common types and enums
2
3use serde::{Deserialize, Serialize};
4
5/// Positive decimal number (string representation)
6pub type PositiveDecimal = String;
7
8/// Date in ISO format (YYYY-MM-DD)
9pub type Date = String;
10
11/// DateTime in ISO 8601 format
12pub type DateTime = String;
13
14/// Country code (ISO 3166-1 alpha-2)
15pub type CountryCode = String;
16
17/// Fiat currency code (ISO 4217)
18pub type FiatCurrencyCode = String;
19
20/// Cryptocurrency code
21#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
22#[serde(rename_all = "PascalCase")]
23pub enum CryptoCurrencyCode {
24    /// Bitcoin (production)
25    #[serde(rename = "BTC")]
26    Btc,
27    /// Bitcoin (testnet)
28    #[serde(rename = "BTC_TEST")]
29    BtcTest,
30    /// USDC (production)
31    #[serde(rename = "USDC")]
32    Usdc,
33    /// USDC (testnet)
34    #[serde(rename = "USDC_TEST")]
35    UsdcTest,
36}
37
38impl std::fmt::Display for CryptoCurrencyCode {
39    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40        match self {
41            CryptoCurrencyCode::Btc => write!(f, "BTC"),
42            CryptoCurrencyCode::BtcTest => write!(f, "BTC_TEST"),
43            CryptoCurrencyCode::Usdc => write!(f, "USDC"),
44            CryptoCurrencyCode::UsdcTest => write!(f, "USDC_TEST"),
45        }
46    }
47}
48
49/// Network identifier
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
51#[serde(rename_all = "PascalCase")]
52pub enum Network {
53    /// Bitcoin mainnet
54    Bitcoin,
55    /// Bitcoin testnet
56    BitcoinTest,
57    /// Ethereum mainnet
58    Ethereum,
59    /// Ethereum testnet (Sepolia)
60    EthereumTestSepolia,
61    /// Celo mainnet
62    Celo,
63    /// Celo testnet (Sepolia)
64    CeloTestSepolia,
65    /// Flow EVM mainnet
66    FlowEvm,
67    /// Flow EVM testnet
68    FlowEvmTest,
69    /// Gnosis mainnet
70    Gnosis,
71    /// Gnosis testnet (Chiado)
72    GnosisTestChiado,
73    /// Lightning mainnet
74    Lightning,
75    /// Lightning testnet
76    LightningTest,
77    /// Polygon PoS mainnet
78    PolygonPos,
79    /// Polygon PoS testnet (Amoy)
80    PolygonTestAmoy,
81    /// Solana mainnet
82    Solana,
83    /// Solana devnet
84    SolanaDevnet,
85    /// Off-network
86    OffNetwork,
87}
88
89/// Address format
90#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
91#[serde(rename_all = "PascalCase")]
92pub enum AddressFormat {
93    /// EVM-compatible address
94    EvmCompatible,
95    /// Segwit address
96    Segwit,
97    /// Tron Base58 address
98    TronBase58,
99    /// Solana Base58 address
100    SolanaBase58,
101}
102
103/// Blockchain address
104pub type Address = String;
105
106/// Destination address
107#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct DestinationAddress {
109    /// The address
110    #[serde(rename = "Address")]
111    pub address: Address,
112}
113
114/// Fiat amount
115#[derive(Debug, Clone, Serialize, Deserialize)]
116pub struct FiatAmount {
117    /// Amount
118    #[serde(rename = "Amount")]
119    pub amount: PositiveDecimal,
120    /// Fiat currency
121    #[serde(rename = "FiatCurrency")]
122    pub fiat_currency: FiatCurrencyCode,
123}
124
125/// Account type
126#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
127#[serde(rename_all = "PascalCase")]
128pub enum AccountType {
129    /// Current account
130    Current,
131}
132
133impl std::fmt::Display for AccountType {
134    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
135        match self {
136            AccountType::Current => write!(f, "Current"),
137        }
138    }
139}
140
141/// Payment method category
142#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
143#[serde(rename_all = "PascalCase")]
144pub enum PaymentMethodCategory {
145    /// Bank payment methods
146    Bank,
147    /// Card payment methods
148    Card,
149    /// Identifier-based payment methods
150    Identifier,
151}
152
153/// Payment method type
154#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
155#[serde(rename_all = "PascalCase")]
156pub enum PaymentMethodType {
157    /// SEPA bank transfer
158    BankSepa,
159    /// Local bank transfer
160    BankLocal,
161    /// Fedwire bank transfer
162    BankFedwire,
163    /// Tokenized card
164    TokenizedCard,
165    /// PIX identifier
166    IdentifierPix,
167}
168
169/// Processing tier
170#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
171#[serde(rename_all = "PascalCase")]
172pub enum ProcessingTier {
173    /// Standard processing
174    Standard,
175    /// Priority processing
176    Priority,
177}
178
179/// Transaction status
180#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
181#[serde(rename_all = "PascalCase")]
182pub enum TransactionStatus {
183    /// Transaction is pending
184    Pending,
185    /// Transaction failed
186    Failed,
187    /// Transaction settled
188    Settled,
189}
190
191/// Transaction direction
192#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
193#[serde(rename_all = "PascalCase")]
194pub enum TransactionDirection {
195    /// Incoming transaction
196    In,
197    /// Outgoing transaction
198    Out,
199}
200
201/// Sort direction
202#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
203#[serde(rename_all = "UPPERCASE")]
204pub enum SortDirection {
205    /// Ascending order
206    Asc,
207    /// Descending order
208    Desc,
209}
210
211/// Customer ID
212pub type CustomerID = String;
213
214/// Channel ID (UUID)
215pub type ChannelID = String;
216
217/// Payment method ID
218pub type PaymentMethodID = String;
219
220/// External ID
221pub type ExternalID = String;
222
223/// Form session ID (UUID)
224pub type FormSessionID = String;
225
226/// Nonce (unique transaction identifier)
227pub type Nonce = String;
228
229/// Phone number (E.164 format)
230pub type PhoneNumber = String;
231
232/// Return URL
233pub type ReturnURL = String;