pontoconnect_rs/apis/
bulk_payment_api.rs1use super::{configuration, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateBulkPaymentError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum DeleteBulkPaymentError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GetBulkPaymentError {
34 UnknownValue(serde_json::Value),
35}
36
37pub async fn create_bulk_payment(
38 configuration: &configuration::Configuration,
39 account_id: &str,
40 create_bulk_payment_request: Option<models::CreateBulkPaymentRequest>,
41) -> Result<models::BulkPaymentSingle, Error<CreateBulkPaymentError>> {
42 let p_account_id = account_id;
44 let p_create_bulk_payment_request = create_bulk_payment_request;
45
46 let uri_str = format!(
47 "{}/accounts/{accountId}/bulk-payments",
48 configuration.base_path,
49 accountId = crate::apis::urlencode(p_account_id)
50 );
51 let mut req_builder = configuration
52 .client
53 .request(reqwest::Method::POST, &uri_str);
54
55 if let Some(ref user_agent) = configuration.user_agent {
56 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
57 }
58 if let Some(ref token) = configuration.oauth_access_token {
59 req_builder = req_builder.bearer_auth(token.to_owned());
60 };
61 req_builder = req_builder.json(&p_create_bulk_payment_request);
62
63 let req = req_builder.build()?;
64 let resp = configuration.client.execute(req).await?;
65
66 let status = resp.status();
67
68 if !status.is_client_error() && !status.is_server_error() {
69 let content = resp.text().await?;
70 serde_json::from_str(&content).map_err(Error::from)
71 } else {
72 let content = resp.text().await?;
73 let entity: Option<CreateBulkPaymentError> = serde_json::from_str(&content).ok();
74 Err(Error::ResponseError(ResponseContent {
75 status,
76 content,
77 entity,
78 }))
79 }
80}
81
82pub async fn delete_bulk_payment(
83 configuration: &configuration::Configuration,
84 account_id: &str,
85 id: &str,
86) -> Result<models::BulkPaymentSingle, Error<DeleteBulkPaymentError>> {
87 let p_account_id = account_id;
89 let p_id = id;
90
91 let uri_str = format!(
92 "{}/accounts/{accountId}/bulk-payments/{id}",
93 configuration.base_path,
94 accountId = crate::apis::urlencode(p_account_id),
95 id = crate::apis::urlencode(p_id)
96 );
97 let mut req_builder = configuration
98 .client
99 .request(reqwest::Method::DELETE, &uri_str);
100
101 if let Some(ref user_agent) = configuration.user_agent {
102 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
103 }
104 if let Some(ref token) = configuration.oauth_access_token {
105 req_builder = req_builder.bearer_auth(token.to_owned());
106 };
107
108 let req = req_builder.build()?;
109 let resp = configuration.client.execute(req).await?;
110
111 let status = resp.status();
112
113 if !status.is_client_error() && !status.is_server_error() {
114 let content = resp.text().await?;
115 serde_json::from_str(&content).map_err(Error::from)
116 } else {
117 let content = resp.text().await?;
118 let entity: Option<DeleteBulkPaymentError> = serde_json::from_str(&content).ok();
119 Err(Error::ResponseError(ResponseContent {
120 status,
121 content,
122 entity,
123 }))
124 }
125}
126
127pub async fn get_bulk_payment(
128 configuration: &configuration::Configuration,
129 account_id: &str,
130 id: &str,
131) -> Result<models::BulkPaymentSingle, Error<GetBulkPaymentError>> {
132 let p_account_id = account_id;
134 let p_id = id;
135
136 let uri_str = format!(
137 "{}/accounts/{accountId}/bulk-payments/{id}",
138 configuration.base_path,
139 accountId = crate::apis::urlencode(p_account_id),
140 id = crate::apis::urlencode(p_id)
141 );
142 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
143
144 if let Some(ref user_agent) = configuration.user_agent {
145 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
146 }
147 if let Some(ref token) = configuration.oauth_access_token {
148 req_builder = req_builder.bearer_auth(token.to_owned());
149 };
150
151 let req = req_builder.build()?;
152 let resp = configuration.client.execute(req).await?;
153
154 let status = resp.status();
155
156 if !status.is_client_error() && !status.is_server_error() {
157 let content = resp.text().await?;
158 serde_json::from_str(&content).map_err(Error::from)
159 } else {
160 let content = resp.text().await?;
161 let entity: Option<GetBulkPaymentError> = serde_json::from_str(&content).ok();
162 Err(Error::ResponseError(ResponseContent {
163 status,
164 content,
165 entity,
166 }))
167 }
168}