lightspark/objects/
incoming_payment_attempt.rs1use crate::objects::currency_amount::CurrencyAmount;
3use crate::objects::entity::Entity;
4use crate::objects::incoming_payment_attempt_status::IncomingPaymentAttemptStatus;
5use crate::types::custom_date_formats::custom_date_format;
6use crate::types::custom_date_formats::custom_date_format_option;
7use crate::types::entity_wrapper::EntityWrapper;
8use crate::types::get_entity::GetEntity;
9use chrono::{DateTime, Utc};
10use serde::{Deserialize, Serialize};
11
12#[derive(Debug, Clone, Deserialize, Serialize)]
14pub struct IncomingPaymentAttempt {
15 #[serde(rename = "incoming_payment_attempt_id")]
17 pub id: String,
18
19 #[serde(
21 with = "custom_date_format",
22 rename = "incoming_payment_attempt_created_at"
23 )]
24 pub created_at: DateTime<Utc>,
25
26 #[serde(
28 with = "custom_date_format",
29 rename = "incoming_payment_attempt_updated_at"
30 )]
31 pub updated_at: DateTime<Utc>,
32
33 #[serde(rename = "incoming_payment_attempt_status")]
35 pub status: IncomingPaymentAttemptStatus,
36
37 #[serde(
39 with = "custom_date_format_option",
40 rename = "incoming_payment_attempt_resolved_at"
41 )]
42 pub resolved_at: Option<DateTime<Utc>>,
43
44 #[serde(rename = "incoming_payment_attempt_amount")]
46 pub amount: CurrencyAmount,
47
48 #[serde(rename = "incoming_payment_attempt_channel")]
50 pub channel: EntityWrapper,
51
52 #[serde(rename = "__typename")]
54 pub typename: String,
55}
56
57impl Entity for IncomingPaymentAttempt {
58 fn get_id(&self) -> String {
60 self.id.clone()
61 }
62
63 fn get_created_at(&self) -> DateTime<Utc> {
65 self.created_at
66 }
67
68 fn get_updated_at(&self) -> DateTime<Utc> {
70 self.updated_at
71 }
72
73 fn type_name(&self) -> &'static str {
74 "IncomingPaymentAttempt"
75 }
76}
77
78impl GetEntity for IncomingPaymentAttempt {
79 fn get_entity_query() -> String {
80 format!(
81 "
82 query GetEntity($id: ID!) {{
83 entity(id: $id) {{
84 ... on IncomingPaymentAttempt {{
85 ... IncomingPaymentAttemptFragment
86 }}
87 }}
88 }}
89
90 {}",
91 FRAGMENT
92 )
93 }
94}
95
96pub const FRAGMENT: &str = "
97fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {
98 __typename
99 incoming_payment_attempt_id: id
100 incoming_payment_attempt_created_at: created_at
101 incoming_payment_attempt_updated_at: updated_at
102 incoming_payment_attempt_status: status
103 incoming_payment_attempt_resolved_at: resolved_at
104 incoming_payment_attempt_amount: amount {
105 __typename
106 currency_amount_original_value: original_value
107 currency_amount_original_unit: original_unit
108 currency_amount_preferred_currency_unit: preferred_currency_unit
109 currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
110 currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
111 }
112 incoming_payment_attempt_channel: channel {
113 id
114 }
115}
116";