-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathresource.rs
More file actions
174 lines (161 loc) · 5.43 KB
/
resource.rs
File metadata and controls
174 lines (161 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
use crate::types::common::{Amount, Receiver};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct IncomingPayment {
pub id: String,
pub wallet_address: String,
pub completed: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub incoming_amount: Option<Amount>,
pub received_amount: Amount,
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
pub created_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub methods: Option<Vec<PaymentMethod>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct IncomingPaymentWithMethods {
#[serde(flatten)]
pub payment: IncomingPayment,
pub methods: Vec<PaymentMethod>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum PaymentMethod {
#[serde(rename = "ilp")]
Ilp {
#[serde(rename = "ilpAddress")]
ilp_address: String,
#[serde(rename = "sharedSecret")]
shared_secret: String,
},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicIncomingPayment {
pub received_amount: Amount,
pub auth_server: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct CreateIncomingPaymentRequest {
pub wallet_address: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub incoming_amount: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct OutgoingPayment {
pub id: String,
pub wallet_address: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub quote_id: Option<String>,
pub failed: bool,
pub receiver: Receiver,
pub receive_amount: Amount,
pub debit_amount: Amount,
pub sent_amount: Amount,
pub grant_spent_debit_amount: Amount,
pub grant_spent_receive_amount: Amount,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Value>,
pub created_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum CreateQuoteRequest {
FixedReceiveAmountQuote {
#[serde(rename = "walletAddress")]
wallet_address: String,
receiver: Receiver,
method: PaymentMethodType,
#[serde(rename = "receiveAmount")]
receive_amount: Amount,
},
FixedSendAmountQuote {
#[serde(rename = "walletAddress")]
wallet_address: String,
receiver: Receiver,
method: PaymentMethodType,
#[serde(rename = "debitAmount")]
debit_amount: Amount,
},
NoAmountQuote {
#[serde(rename = "walletAddress")]
wallet_address: String,
receiver: Receiver,
method: PaymentMethodType,
},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum CreateOutgoingPaymentRequest {
FromQuote {
#[serde(rename = "walletAddress")]
wallet_address: String,
#[serde(rename = "quoteId")]
quote_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<Value>,
},
FromIncomingPayment {
#[serde(rename = "walletAddress")]
wallet_address: String,
#[serde(rename = "incomingPayment")]
incoming_payment_id: String,
#[serde(rename = "debitAmount")]
debit_amount: Amount,
#[serde(skip_serializing_if = "Option::is_none")]
metadata: Option<Value>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Quote {
pub id: String,
pub wallet_address: String,
pub receiver: Receiver,
pub receive_amount: Amount,
pub debit_amount: Amount,
pub method: PaymentMethodType,
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum PaymentMethodType {
Ilp,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PageInfo {
#[serde(skip_serializing_if = "Option::is_none")]
pub start_cursor: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_cursor: Option<String>,
pub has_next_page: bool,
pub has_previous_page: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct PaginatedResponse<T> {
pub pagination: PageInfo,
pub result: Vec<T>,
}
pub type ListIncomingPaymentsResponse = PaginatedResponse<IncomingPayment>;
pub type ListOutgoingPaymentsResponse = PaginatedResponse<OutgoingPayment>;