use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::entity::Entity;
use crate::objects::incoming_payment_attempt_status::IncomingPaymentAttemptStatus;
use crate::types::custom_date_formats::custom_date_format;
use crate::types::custom_date_formats::custom_date_format_option;
use crate::types::entity_wrapper::EntityWrapper;
use crate::types::get_entity::GetEntity;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct IncomingPaymentAttempt {
#[serde(rename = "incoming_payment_attempt_id")]
pub id: String,
#[serde(
with = "custom_date_format",
rename = "incoming_payment_attempt_created_at"
)]
pub created_at: DateTime<Utc>,
#[serde(
with = "custom_date_format",
rename = "incoming_payment_attempt_updated_at"
)]
pub updated_at: DateTime<Utc>,
#[serde(rename = "incoming_payment_attempt_status")]
pub status: IncomingPaymentAttemptStatus,
#[serde(
with = "custom_date_format_option",
rename = "incoming_payment_attempt_resolved_at"
)]
pub resolved_at: Option<DateTime<Utc>>,
#[serde(rename = "incoming_payment_attempt_amount")]
pub amount: CurrencyAmount,
#[serde(rename = "incoming_payment_attempt_channel")]
pub channel: EntityWrapper,
#[serde(rename = "__typename")]
pub typename: String,
}
impl Entity for IncomingPaymentAttempt {
fn get_id(&self) -> String {
self.id.clone()
}
fn get_created_at(&self) -> DateTime<Utc> {
self.created_at
}
fn get_updated_at(&self) -> DateTime<Utc> {
self.updated_at
}
fn type_name(&self) -> &'static str {
"IncomingPaymentAttempt"
}
}
impl GetEntity for IncomingPaymentAttempt {
fn get_entity_query() -> String {
format!(
"
query GetEntity($id: ID!) {{
entity(id: $id) {{
... on IncomingPaymentAttempt {{
... IncomingPaymentAttemptFragment
}}
}}
}}
{}",
FRAGMENT
)
}
}
pub const FRAGMENT: &str = "
fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {
__typename
incoming_payment_attempt_id: id
incoming_payment_attempt_created_at: created_at
incoming_payment_attempt_updated_at: updated_at
incoming_payment_attempt_status: status
incoming_payment_attempt_resolved_at: resolved_at
incoming_payment_attempt_amount: amount {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
incoming_payment_attempt_channel: channel {
id
}
}
";