pontoconnect_rs/apis/
transaction_api.rs1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetTransactionError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ListTransactionsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListUpdatedTransactionsForSynchronizationError {
36 UnknownValue(serde_json::Value),
37}
38
39
40pub async fn get_transaction(configuration: &configuration::Configuration, account_id: &str, id: &str) -> Result<models::TransactionSingle, Error<GetTransactionError>> {
41 let p_account_id = account_id;
43 let p_id = id;
44
45 let uri_str = format!("{}/accounts/{accountId}/transactions/{id}", configuration.base_path, accountId=crate::apis::urlencode(p_account_id), id=crate::apis::urlencode(p_id));
46 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
47
48 if let Some(ref user_agent) = configuration.user_agent {
49 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
50 }
51 if let Some(ref token) = configuration.oauth_access_token {
52 req_builder = req_builder.bearer_auth(token.to_owned());
53 };
54
55 let req = req_builder.build()?;
56 let resp = configuration.client.execute(req).await?;
57
58 let status = resp.status();
59
60 if !status.is_client_error() && !status.is_server_error() {
61 let content = resp.text().await?;
62 serde_json::from_str(&content).map_err(Error::from)
63 } else {
64 let content = resp.text().await?;
65 let entity: Option<GetTransactionError> = serde_json::from_str(&content).ok();
66 Err(Error::ResponseError(ResponseContent { status, content, entity }))
67 }
68}
69
70pub async fn list_transactions(configuration: &configuration::Configuration, account_id: &str, page_left_square_bracket_limit_right_square_bracket: Option<f64>, page_left_square_bracket_before_right_square_bracket: Option<&str>, page_left_square_bracket_after_right_square_bracket: Option<&str>) -> Result<models::TransactionCollection, Error<ListTransactionsError>> {
71 let p_account_id = account_id;
73 let p_page_left_square_bracket_limit_right_square_bracket = page_left_square_bracket_limit_right_square_bracket;
74 let p_page_left_square_bracket_before_right_square_bracket = page_left_square_bracket_before_right_square_bracket;
75 let p_page_left_square_bracket_after_right_square_bracket = page_left_square_bracket_after_right_square_bracket;
76
77 let uri_str = format!("{}/accounts/{accountId}/transactions", configuration.base_path, accountId=crate::apis::urlencode(p_account_id));
78 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
79
80 if let Some(ref param_value) = p_page_left_square_bracket_limit_right_square_bracket {
81 req_builder = req_builder.query(&[("page[limit]", ¶m_value.to_string())]);
82 }
83 if let Some(ref param_value) = p_page_left_square_bracket_before_right_square_bracket {
84 req_builder = req_builder.query(&[("page[before]", ¶m_value.to_string())]);
85 }
86 if let Some(ref param_value) = p_page_left_square_bracket_after_right_square_bracket {
87 req_builder = req_builder.query(&[("page[after]", ¶m_value.to_string())]);
88 }
89 if let Some(ref user_agent) = configuration.user_agent {
90 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
91 }
92 if let Some(ref token) = configuration.oauth_access_token {
93 req_builder = req_builder.bearer_auth(token.to_owned());
94 };
95
96 let req = req_builder.build()?;
97 let resp = configuration.client.execute(req).await?;
98
99 let status = resp.status();
100
101 if !status.is_client_error() && !status.is_server_error() {
102 let content = resp.text().await?;
103 serde_json::from_str(&content).map_err(Error::from)
104 } else {
105 let content = resp.text().await?;
106 let entity: Option<ListTransactionsError> = serde_json::from_str(&content).ok();
107 Err(Error::ResponseError(ResponseContent { status, content, entity }))
108 }
109}
110
111pub async fn list_updated_transactions_for_synchronization(configuration: &configuration::Configuration, synchronization_id: &str, page_left_square_bracket_limit_right_square_bracket: Option<f64>, page_left_square_bracket_before_right_square_bracket: Option<&str>, page_left_square_bracket_after_right_square_bracket: Option<&str>) -> Result<models::TransactionCollection, Error<ListUpdatedTransactionsForSynchronizationError>> {
112 let p_synchronization_id = synchronization_id;
114 let p_page_left_square_bracket_limit_right_square_bracket = page_left_square_bracket_limit_right_square_bracket;
115 let p_page_left_square_bracket_before_right_square_bracket = page_left_square_bracket_before_right_square_bracket;
116 let p_page_left_square_bracket_after_right_square_bracket = page_left_square_bracket_after_right_square_bracket;
117
118 let uri_str = format!("{}/synchronizations/{synchronizationId}/updated-transactions", configuration.base_path, synchronizationId=crate::apis::urlencode(p_synchronization_id));
119 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
120
121 if let Some(ref param_value) = p_page_left_square_bracket_limit_right_square_bracket {
122 req_builder = req_builder.query(&[("page[limit]", ¶m_value.to_string())]);
123 }
124 if let Some(ref param_value) = p_page_left_square_bracket_before_right_square_bracket {
125 req_builder = req_builder.query(&[("page[before]", ¶m_value.to_string())]);
126 }
127 if let Some(ref param_value) = p_page_left_square_bracket_after_right_square_bracket {
128 req_builder = req_builder.query(&[("page[after]", ¶m_value.to_string())]);
129 }
130 if let Some(ref user_agent) = configuration.user_agent {
131 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
132 }
133 if let Some(ref token) = configuration.oauth_access_token {
134 req_builder = req_builder.bearer_auth(token.to_owned());
135 };
136
137 let req = req_builder.build()?;
138 let resp = configuration.client.execute(req).await?;
139
140 let status = resp.status();
141
142 if !status.is_client_error() && !status.is_server_error() {
143 let content = resp.text().await?;
144 serde_json::from_str(&content).map_err(Error::from)
145 } else {
146 let content = resp.text().await?;
147 let entity: Option<ListUpdatedTransactionsForSynchronizationError> = serde_json::from_str(&content).ok();
148 Err(Error::ResponseError(ResponseContent { status, content, entity }))
149 }
150}
151