zebedee_rust/email/
types.rs

1use crate::{custom_deserializer::deserialize_from_string, StdResp, VoucherData};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4
5pub type EmailPaymentResponse = StdResp<EmailPaymentRes>;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8#[serde(untagged)]
9pub enum EmailPaymentRes {
10    /// Email is associated with an existing ZBD App account, then that user account will be credited the sats.
11    ExistingZbdAccount(EmailPaymentData),
12    /// Email not associated to a ZBD account, the sats will be issued to the email in the form of a valid ZBD Voucher that the recipient can redeem in the ZBD Mobile App.
13    Voucher(VoucherData),
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct EmailPaymentData {
18    pub id: String,
19    // TODO: Convert from string to a proper Enum
20    pub status: String,
21    #[serde(deserialize_with = "deserialize_from_string")]
22    pub amount: u64,
23    pub comment: String,
24    #[serde(rename = "receiverId")]
25    pub receiver_id: String,
26    #[serde(rename = "senderTxId")]
27    pub sender_tx_id: String,
28    #[serde(rename = "settledAt")]
29    pub settled_at: DateTime<Utc>,
30    #[serde(rename = "transactionId")]
31    pub transaction_id: String,
32}
33
34/// Send instant Bitcoin payments to any email
35#[derive(Debug, Serialize, Deserialize)]
36pub struct EmailPaymentReqest {
37    /// Recipient email to send payment to.
38    pub email: String,
39    /// Total amount of satoshis to send (in millisatoshis).
40    pub amount: String,
41    /// comment to be sent with the payment (max 150 characters).
42    pub comment: String,
43}