Skip to main content

talea_core/api/
responses.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4use crate::{
5    api::requests::WireAmount,
6    types::{Direction, ExternalRef, Seq},
7};
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
11pub struct Posted {
12    pub tx_id: String,
13    pub seq: Seq,
14    pub at: DateTime<Utc>,
15    pub deduplicated: bool,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
20pub struct BalanceView {
21    pub account: String,
22    pub asset: String,
23    pub balance: String,
24    pub as_of: Option<DateTime<Utc>>,
25    pub updated_seq: Seq,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
30pub struct PostingView {
31    pub seq: Seq,
32    pub tx_id: String,
33    pub account: String,
34    pub amount: WireAmount,
35    pub direction: Direction,
36    pub at: DateTime<Utc>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
41pub struct TransactionView {
42    pub tx_id: String,
43    pub book: String,
44    pub seq: Seq,
45    pub at: DateTime<Utc>,
46    pub postings: Vec<PostingView>,
47    pub external_refs: Vec<ExternalRef>,
48    pub metadata: serde_json::Value,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
53pub struct TrialBalanceLine {
54    pub asset: String,
55    pub debits: i64,
56    pub credits: i64,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
61pub struct TrialBalance {
62    pub book: String,
63    pub as_of: Option<DateTime<Utc>>,
64    pub lines: Vec<TrialBalanceLine>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
69pub struct Paged<T> {
70    pub items: Vec<T>,
71    pub next: Option<Seq>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
76pub struct EventEnvelope {
77    pub seq: Seq,
78    pub at: DateTime<Utc>,
79    pub kind: String,
80    pub payload: serde_json::Value,
81}