use crate::models::prelude::*;
use derive_getters::Getters;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone, Getters)]
pub struct TransactionResponseLinks {
#[serde(rename = "self")]
self_link: Link,
account: Link,
ledger: Link,
operations: Link,
effects: Link,
precedes: Link,
succeeds: Link,
transaction: Link,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)]
pub struct Preconditions {
timebounds: TimeBounds,
ledger_bounds: Option<LedgerBounds>,
min_account_sequence: Option<String>,
min_account_sequence_age: Option<i64>,
min_account_sequence_ledger_gap: Option<i64>,
extra_signers: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)]
pub struct TimeBounds {
min_time: String,
max_time: Option<String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize, Getters)]
pub struct LedgerBounds {
min_ledger: String,
max_ledger: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Getters)]
#[serde(rename_all = "camelCase")]
pub struct AllTransactionsResponse {
#[serde(rename = "_links")]
links: ResponseLinks,
#[serde(rename = "_embedded")]
embedded: Embedded<TransactionResponse>,
}
impl Response for AllTransactionsResponse {
fn from_json(json: String) -> Result<Self, String> {
let response = serde_json::from_str(&json).map_err(|e| e.to_string())?;
Ok(response)
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Getters)]
pub struct TransactionResponse {
#[serde(rename = "_links")]
links: TransactionResponseLinks,
id: String,
paging_token: String,
successful: bool,
hash: String,
ledger: i64,
created_at: String,
source_account: String,
account_muxed: Option<String>,
account_muxed_id: Option<String>,
source_account_sequence: String,
fee_account: String,
fee_charged: String,
max_fee: String,
operation_count: i64,
envelope_xdr: String,
result_xdr: String,
result_meta_xdr: String,
fee_meta_xdr: String,
memo: Option<String>,
memo_type: String,
signatures: Vec<String>,
valid_after: Option<String>,
valid_before: Option<String>,
preconditions: Option<Preconditions>,
}
impl Response for TransactionResponse {
fn from_json(json: String) -> Result<Self, String> {
serde_json::from_str(&json).map_err(|e| e.to_string())
}
}