ynab_api/apis/
transactions_api.rs

1/*
2 * YNAB API Endpoints
3 *
4 * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body.  API Documentation is at https://api.ynab.com
5 *
6 * The version of the OpenAPI document: 1.72.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_transaction`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateTransactionError {
22    Status400(models::ErrorResponse),
23    Status409(models::ErrorResponse),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`delete_transaction`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum DeleteTransactionError {
31    Status404(models::ErrorResponse),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`get_transaction_by_id`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum GetTransactionByIdError {
39    Status404(models::ErrorResponse),
40    DefaultResponse(models::ErrorResponse),
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`get_transactions`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetTransactionsError {
48    Status400(models::ErrorResponse),
49    Status404(models::ErrorResponse),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_transactions_by_account`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetTransactionsByAccountError {
57    Status404(models::ErrorResponse),
58    DefaultResponse(models::ErrorResponse),
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`get_transactions_by_category`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum GetTransactionsByCategoryError {
66    Status404(models::ErrorResponse),
67    DefaultResponse(models::ErrorResponse),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`get_transactions_by_month`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum GetTransactionsByMonthError {
75    Status404(models::ErrorResponse),
76    DefaultResponse(models::ErrorResponse),
77    UnknownValue(serde_json::Value),
78}
79
80/// struct for typed errors of method [`get_transactions_by_payee`]
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(untagged)]
83pub enum GetTransactionsByPayeeError {
84    Status404(models::ErrorResponse),
85    DefaultResponse(models::ErrorResponse),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`import_transactions`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum ImportTransactionsError {
93    Status400(models::ErrorResponse),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`update_transaction`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum UpdateTransactionError {
101    Status400(models::ErrorResponse),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`update_transactions`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum UpdateTransactionsError {
109    Status400(models::ErrorResponse),
110    UnknownValue(serde_json::Value),
111}
112
113
114/// Creates a single transaction or multiple transactions.  If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created.  Scheduled transactions (transactions with a future date) cannot be created on this endpoint.
115pub async fn create_transaction(configuration: &configuration::Configuration, budget_id: &str, data: models::PostTransactionsWrapper) -> Result<models::SaveTransactionsResponse, Error<CreateTransactionError>> {
116    let local_var_configuration = configuration;
117
118    let local_var_client = &local_var_configuration.client;
119
120    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id));
121    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
122
123    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
124        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
125    }
126    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
127        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
128    };
129    local_var_req_builder = local_var_req_builder.json(&data);
130
131    let local_var_req = local_var_req_builder.build()?;
132    let local_var_resp = local_var_client.execute(local_var_req).await?;
133
134    let local_var_status = local_var_resp.status();
135    let local_var_content = local_var_resp.text().await?;
136
137    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
138        serde_json::from_str(&local_var_content).map_err(Error::from)
139    } else {
140        let local_var_entity: Option<CreateTransactionError> = serde_json::from_str(&local_var_content).ok();
141        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
142        Err(Error::ResponseError(local_var_error))
143    }
144}
145
146/// Deletes a transaction
147pub async fn delete_transaction(configuration: &configuration::Configuration, budget_id: &str, transaction_id: &str) -> Result<models::TransactionResponse, Error<DeleteTransactionError>> {
148    let local_var_configuration = configuration;
149
150    let local_var_client = &local_var_configuration.client;
151
152    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions/{transaction_id}", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), transaction_id=crate::apis::urlencode(transaction_id));
153    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
154
155    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
156        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
157    }
158    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
159        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
160    };
161
162    let local_var_req = local_var_req_builder.build()?;
163    let local_var_resp = local_var_client.execute(local_var_req).await?;
164
165    let local_var_status = local_var_resp.status();
166    let local_var_content = local_var_resp.text().await?;
167
168    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
169        serde_json::from_str(&local_var_content).map_err(Error::from)
170    } else {
171        let local_var_entity: Option<DeleteTransactionError> = serde_json::from_str(&local_var_content).ok();
172        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
173        Err(Error::ResponseError(local_var_error))
174    }
175}
176
177/// Returns a single transaction
178pub async fn get_transaction_by_id(configuration: &configuration::Configuration, budget_id: &str, transaction_id: &str) -> Result<models::TransactionResponse, Error<GetTransactionByIdError>> {
179    let local_var_configuration = configuration;
180
181    let local_var_client = &local_var_configuration.client;
182
183    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions/{transaction_id}", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), transaction_id=crate::apis::urlencode(transaction_id));
184    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
185
186    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
187        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
188    }
189    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
190        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
191    };
192
193    let local_var_req = local_var_req_builder.build()?;
194    let local_var_resp = local_var_client.execute(local_var_req).await?;
195
196    let local_var_status = local_var_resp.status();
197    let local_var_content = local_var_resp.text().await?;
198
199    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
200        serde_json::from_str(&local_var_content).map_err(Error::from)
201    } else {
202        let local_var_entity: Option<GetTransactionByIdError> = serde_json::from_str(&local_var_content).ok();
203        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
204        Err(Error::ResponseError(local_var_error))
205    }
206}
207
208/// Returns budget transactions, excluding any pending transactions
209pub async fn get_transactions(configuration: &configuration::Configuration, budget_id: &str, since_date: Option<String>, r#type: Option<&str>, last_knowledge_of_server: Option<i64>) -> Result<models::TransactionsResponse, Error<GetTransactionsError>> {
210    let local_var_configuration = configuration;
211
212    let local_var_client = &local_var_configuration.client;
213
214    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id));
215    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
216
217    if let Some(ref local_var_str) = since_date {
218        local_var_req_builder = local_var_req_builder.query(&[("since_date", &local_var_str.to_string())]);
219    }
220    if let Some(ref local_var_str) = r#type {
221        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
222    }
223    if let Some(ref local_var_str) = last_knowledge_of_server {
224        local_var_req_builder = local_var_req_builder.query(&[("last_knowledge_of_server", &local_var_str.to_string())]);
225    }
226    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
227        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228    }
229    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
230        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
231    };
232
233    let local_var_req = local_var_req_builder.build()?;
234    let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236    let local_var_status = local_var_resp.status();
237    let local_var_content = local_var_resp.text().await?;
238
239    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240        serde_json::from_str(&local_var_content).map_err(Error::from)
241    } else {
242        let local_var_entity: Option<GetTransactionsError> = serde_json::from_str(&local_var_content).ok();
243        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244        Err(Error::ResponseError(local_var_error))
245    }
246}
247
248/// Returns all transactions for a specified account, excluding any pending transactions
249pub async fn get_transactions_by_account(configuration: &configuration::Configuration, budget_id: &str, account_id: &str, since_date: Option<String>, r#type: Option<&str>, last_knowledge_of_server: Option<i64>) -> Result<models::TransactionsResponse, Error<GetTransactionsByAccountError>> {
250    let local_var_configuration = configuration;
251
252    let local_var_client = &local_var_configuration.client;
253
254    let local_var_uri_str = format!("{}/budgets/{budget_id}/accounts/{account_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), account_id=crate::apis::urlencode(account_id));
255    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
256
257    if let Some(ref local_var_str) = since_date {
258        local_var_req_builder = local_var_req_builder.query(&[("since_date", &local_var_str.to_string())]);
259    }
260    if let Some(ref local_var_str) = r#type {
261        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
262    }
263    if let Some(ref local_var_str) = last_knowledge_of_server {
264        local_var_req_builder = local_var_req_builder.query(&[("last_knowledge_of_server", &local_var_str.to_string())]);
265    }
266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268    }
269    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
270        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
271    };
272
273    let local_var_req = local_var_req_builder.build()?;
274    let local_var_resp = local_var_client.execute(local_var_req).await?;
275
276    let local_var_status = local_var_resp.status();
277    let local_var_content = local_var_resp.text().await?;
278
279    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280        serde_json::from_str(&local_var_content).map_err(Error::from)
281    } else {
282        let local_var_entity: Option<GetTransactionsByAccountError> = serde_json::from_str(&local_var_content).ok();
283        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
284        Err(Error::ResponseError(local_var_error))
285    }
286}
287
288/// Returns all transactions for a specified category
289pub async fn get_transactions_by_category(configuration: &configuration::Configuration, budget_id: &str, category_id: &str, since_date: Option<String>, r#type: Option<&str>, last_knowledge_of_server: Option<i64>) -> Result<models::HybridTransactionsResponse, Error<GetTransactionsByCategoryError>> {
290    let local_var_configuration = configuration;
291
292    let local_var_client = &local_var_configuration.client;
293
294    let local_var_uri_str = format!("{}/budgets/{budget_id}/categories/{category_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), category_id=crate::apis::urlencode(category_id));
295    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
296
297    if let Some(ref local_var_str) = since_date {
298        local_var_req_builder = local_var_req_builder.query(&[("since_date", &local_var_str.to_string())]);
299    }
300    if let Some(ref local_var_str) = r#type {
301        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
302    }
303    if let Some(ref local_var_str) = last_knowledge_of_server {
304        local_var_req_builder = local_var_req_builder.query(&[("last_knowledge_of_server", &local_var_str.to_string())]);
305    }
306    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
307        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
308    }
309    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
310        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
311    };
312
313    let local_var_req = local_var_req_builder.build()?;
314    let local_var_resp = local_var_client.execute(local_var_req).await?;
315
316    let local_var_status = local_var_resp.status();
317    let local_var_content = local_var_resp.text().await?;
318
319    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
320        serde_json::from_str(&local_var_content).map_err(Error::from)
321    } else {
322        let local_var_entity: Option<GetTransactionsByCategoryError> = serde_json::from_str(&local_var_content).ok();
323        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
324        Err(Error::ResponseError(local_var_error))
325    }
326}
327
328/// Returns all transactions for a specified month
329pub async fn get_transactions_by_month(configuration: &configuration::Configuration, budget_id: &str, month: &str, since_date: Option<String>, r#type: Option<&str>, last_knowledge_of_server: Option<i64>) -> Result<models::HybridTransactionsResponse, Error<GetTransactionsByMonthError>> {
330    let local_var_configuration = configuration;
331
332    let local_var_client = &local_var_configuration.client;
333
334    let local_var_uri_str = format!("{}/budgets/{budget_id}/months/{month}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), month=crate::apis::urlencode(month));
335    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
336
337    if let Some(ref local_var_str) = since_date {
338        local_var_req_builder = local_var_req_builder.query(&[("since_date", &local_var_str.to_string())]);
339    }
340    if let Some(ref local_var_str) = r#type {
341        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
342    }
343    if let Some(ref local_var_str) = last_knowledge_of_server {
344        local_var_req_builder = local_var_req_builder.query(&[("last_knowledge_of_server", &local_var_str.to_string())]);
345    }
346    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
347        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
348    }
349    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
350        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
351    };
352
353    let local_var_req = local_var_req_builder.build()?;
354    let local_var_resp = local_var_client.execute(local_var_req).await?;
355
356    let local_var_status = local_var_resp.status();
357    let local_var_content = local_var_resp.text().await?;
358
359    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
360        serde_json::from_str(&local_var_content).map_err(Error::from)
361    } else {
362        let local_var_entity: Option<GetTransactionsByMonthError> = serde_json::from_str(&local_var_content).ok();
363        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
364        Err(Error::ResponseError(local_var_error))
365    }
366}
367
368/// Returns all transactions for a specified payee
369pub async fn get_transactions_by_payee(configuration: &configuration::Configuration, budget_id: &str, payee_id: &str, since_date: Option<String>, r#type: Option<&str>, last_knowledge_of_server: Option<i64>) -> Result<models::HybridTransactionsResponse, Error<GetTransactionsByPayeeError>> {
370    let local_var_configuration = configuration;
371
372    let local_var_client = &local_var_configuration.client;
373
374    let local_var_uri_str = format!("{}/budgets/{budget_id}/payees/{payee_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), payee_id=crate::apis::urlencode(payee_id));
375    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
376
377    if let Some(ref local_var_str) = since_date {
378        local_var_req_builder = local_var_req_builder.query(&[("since_date", &local_var_str.to_string())]);
379    }
380    if let Some(ref local_var_str) = r#type {
381        local_var_req_builder = local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
382    }
383    if let Some(ref local_var_str) = last_knowledge_of_server {
384        local_var_req_builder = local_var_req_builder.query(&[("last_knowledge_of_server", &local_var_str.to_string())]);
385    }
386    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
387        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
388    }
389    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
390        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
391    };
392
393    let local_var_req = local_var_req_builder.build()?;
394    let local_var_resp = local_var_client.execute(local_var_req).await?;
395
396    let local_var_status = local_var_resp.status();
397    let local_var_content = local_var_resp.text().await?;
398
399    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
400        serde_json::from_str(&local_var_content).map_err(Error::from)
401    } else {
402        let local_var_entity: Option<GetTransactionsByPayeeError> = serde_json::from_str(&local_var_content).ok();
403        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
404        Err(Error::ResponseError(local_var_error))
405    }
406}
407
408/// Imports available transactions on all linked accounts for the given budget.  Linked accounts allow transactions to be imported directly from a specified financial institution and this endpoint initiates that import.  Sending a request to this endpoint is the equivalent of clicking \"Import\" on each account in the web application or tapping the \"New Transactions\" banner in the mobile applications.  The response for this endpoint contains the transaction ids that have been imported.
409pub async fn import_transactions(configuration: &configuration::Configuration, budget_id: &str) -> Result<models::TransactionsImportResponse, Error<ImportTransactionsError>> {
410    let local_var_configuration = configuration;
411
412    let local_var_client = &local_var_configuration.client;
413
414    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions/import", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id));
415    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
416
417    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
418        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
419    }
420    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
421        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
422    };
423
424    let local_var_req = local_var_req_builder.build()?;
425    let local_var_resp = local_var_client.execute(local_var_req).await?;
426
427    let local_var_status = local_var_resp.status();
428    let local_var_content = local_var_resp.text().await?;
429
430    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
431        serde_json::from_str(&local_var_content).map_err(Error::from)
432    } else {
433        let local_var_entity: Option<ImportTransactionsError> = serde_json::from_str(&local_var_content).ok();
434        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
435        Err(Error::ResponseError(local_var_error))
436    }
437}
438
439/// Updates a single transaction
440pub async fn update_transaction(configuration: &configuration::Configuration, budget_id: &str, transaction_id: &str, data: models::PutTransactionWrapper) -> Result<models::TransactionResponse, Error<UpdateTransactionError>> {
441    let local_var_configuration = configuration;
442
443    let local_var_client = &local_var_configuration.client;
444
445    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions/{transaction_id}", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id), transaction_id=crate::apis::urlencode(transaction_id));
446    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
447
448    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
449        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
450    }
451    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
452        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
453    };
454    local_var_req_builder = local_var_req_builder.json(&data);
455
456    let local_var_req = local_var_req_builder.build()?;
457    let local_var_resp = local_var_client.execute(local_var_req).await?;
458
459    let local_var_status = local_var_resp.status();
460    let local_var_content = local_var_resp.text().await?;
461
462    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
463        serde_json::from_str(&local_var_content).map_err(Error::from)
464    } else {
465        let local_var_entity: Option<UpdateTransactionError> = serde_json::from_str(&local_var_content).ok();
466        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
467        Err(Error::ResponseError(local_var_error))
468    }
469}
470
471/// Updates multiple transactions, by `id` or `import_id`.
472pub async fn update_transactions(configuration: &configuration::Configuration, budget_id: &str, data: models::PatchTransactionsWrapper) -> Result<models::SaveTransactionsResponse, Error<UpdateTransactionsError>> {
473    let local_var_configuration = configuration;
474
475    let local_var_client = &local_var_configuration.client;
476
477    let local_var_uri_str = format!("{}/budgets/{budget_id}/transactions", local_var_configuration.base_path, budget_id=crate::apis::urlencode(budget_id));
478    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
479
480    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
481        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
482    }
483    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
484        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
485    };
486    local_var_req_builder = local_var_req_builder.json(&data);
487
488    let local_var_req = local_var_req_builder.build()?;
489    let local_var_resp = local_var_client.execute(local_var_req).await?;
490
491    let local_var_status = local_var_resp.status();
492    let local_var_content = local_var_resp.text().await?;
493
494    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
495        serde_json::from_str(&local_var_content).map_err(Error::from)
496    } else {
497        let local_var_entity: Option<UpdateTransactionsError> = serde_json::from_str(&local_var_content).ok();
498        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
499        Err(Error::ResponseError(local_var_error))
500    }
501}
502