Skip to main content

firefly_iii/apis/
links_api.rs

1/*
2 * Firefly III API v6.4.14
3 *
4 * This is the documentation of the Firefly III API. Please report any bugs or issues. You may use the \"Authorize\" button to try the API below. <br><br> Please keep in mind that the demo site does **not** accept requests from `curl`, `colly`, `wget`, etc. You must use a browser or a tool like Insomnia to make your test requests. <br><br> To learn more about the idiosyncrasies of this API, please read about the API in the [Firefly III API documentation](https://docs.firefly-iii.org/references/firefly-iii/api/). <br><br> <small>This file was last generated on 2025-12-26 @ 15:17:41 (Europe/Amsterdam)</small>
5 *
6 * The version of the OpenAPI document: v6.4.14
7 * Contact: james@firefly-iii.org
8 * Generated by: https://openapi-generator.tech
9 */
10
11#![allow(unused_imports)]
12
13use reqwest;
14
15use super::{configuration, Error};
16use crate::apis::ResponseContent;
17use crate::models::{self, *};
18
19/// struct for typed errors of method [`delete_link_type`]
20#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum DeleteLinkTypeError {
23    Status401(models::UnauthenticatedResponse),
24    Status404(models::NotFoundResponse),
25    Status400(models::BadRequestResponse),
26    Status500(models::InternalExceptionResponse),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`delete_transaction_link`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum DeleteTransactionLinkError {
34    Status401(models::UnauthenticatedResponse),
35    Status404(models::NotFoundResponse),
36    Status400(models::BadRequestResponse),
37    Status500(models::InternalExceptionResponse),
38    UnknownValue(serde_json::Value),
39}
40
41/// struct for typed errors of method [`get_link_type`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum GetLinkTypeError {
45    Status401(models::UnauthenticatedResponse),
46    Status404(models::NotFoundResponse),
47    Status400(models::BadRequestResponse),
48    Status500(models::InternalExceptionResponse),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`get_transaction_link`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum GetTransactionLinkError {
56    Status401(models::UnauthenticatedResponse),
57    Status404(models::NotFoundResponse),
58    Status400(models::BadRequestResponse),
59    Status500(models::InternalExceptionResponse),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`list_link_type`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum ListLinkTypeError {
67    Status401(models::UnauthenticatedResponse),
68    Status404(models::NotFoundResponse),
69    Status400(models::BadRequestResponse),
70    Status500(models::InternalExceptionResponse),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`list_transaction_by_link_type`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListTransactionByLinkTypeError {
78    Status401(models::UnauthenticatedResponse),
79    Status404(models::NotFoundResponse),
80    Status400(models::BadRequestResponse),
81    Status500(models::InternalExceptionResponse),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`list_transaction_link`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum ListTransactionLinkError {
89    Status401(models::UnauthenticatedResponse),
90    Status404(models::NotFoundResponse),
91    Status400(models::BadRequestResponse),
92    Status500(models::InternalExceptionResponse),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`store_link_type`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum StoreLinkTypeError {
100    Status422(models::ValidationErrorResponse),
101    Status401(models::UnauthenticatedResponse),
102    Status404(models::NotFoundResponse),
103    Status400(models::BadRequestResponse),
104    Status500(models::InternalExceptionResponse),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`store_transaction_link`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum StoreTransactionLinkError {
112    Status422(models::ValidationErrorResponse),
113    Status401(models::UnauthenticatedResponse),
114    Status404(models::NotFoundResponse),
115    Status400(models::BadRequestResponse),
116    Status500(models::InternalExceptionResponse),
117    UnknownValue(serde_json::Value),
118}
119
120/// struct for typed errors of method [`update_link_type`]
121#[derive(Debug, Clone, Serialize, Deserialize)]
122#[serde(untagged)]
123pub enum UpdateLinkTypeError {
124    Status422(models::ValidationErrorResponse),
125    Status401(models::UnauthenticatedResponse),
126    Status404(models::NotFoundResponse),
127    Status400(models::BadRequestResponse),
128    Status500(models::InternalExceptionResponse),
129    UnknownValue(serde_json::Value),
130}
131
132/// struct for typed errors of method [`update_transaction_link`]
133#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum UpdateTransactionLinkError {
136    Status422(models::ValidationErrorResponse),
137    Status401(models::UnauthenticatedResponse),
138    Status404(models::NotFoundResponse),
139    Status400(models::BadRequestResponse),
140    Status500(models::InternalExceptionResponse),
141    UnknownValue(serde_json::Value),
142}
143
144/// Will permanently delete a link type. The links between transactions will be removed. The transactions themselves remain. You cannot delete some of the system provided link types, indicated by the editable=false flag when you list it.
145pub async fn delete_link_type(
146    configuration: &configuration::Configuration,
147    id: &str,
148    x_trace_id: Option<&str>,
149) -> Result<(), Error<DeleteLinkTypeError>> {
150    let local_var_configuration = configuration;
151
152    let local_var_client = &local_var_configuration.client;
153
154    let local_var_uri_str = format!(
155        "{}/v1/link-types/{id}",
156        local_var_configuration.base_path,
157        id = crate::apis::urlencode(id)
158    );
159    let mut local_var_req_builder =
160        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
161
162    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
163        local_var_req_builder =
164            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
165    }
166    if let Some(local_var_param_value) = x_trace_id {
167        local_var_req_builder =
168            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
169    }
170    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
171        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
172    };
173    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
174        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
175    };
176
177    let local_var_req = local_var_req_builder.build()?;
178    let local_var_resp = local_var_client.execute(local_var_req).await?;
179
180    let local_var_status = local_var_resp.status();
181    let local_var_content = local_var_resp.text().await?;
182
183    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
184        Ok(())
185    } else {
186        let local_var_entity: Option<DeleteLinkTypeError> =
187            serde_json::from_str(&local_var_content).ok();
188        let local_var_error = ResponseContent {
189            status: local_var_status,
190            content: local_var_content,
191            entity: local_var_entity,
192        };
193        Err(Error::ResponseError(local_var_error))
194    }
195}
196
197/// Will permanently delete link. Transactions remain.
198pub async fn delete_transaction_link(
199    configuration: &configuration::Configuration,
200    id: &str,
201    x_trace_id: Option<&str>,
202) -> Result<(), Error<DeleteTransactionLinkError>> {
203    let local_var_configuration = configuration;
204
205    let local_var_client = &local_var_configuration.client;
206
207    let local_var_uri_str = format!(
208        "{}/v1/transaction-links/{id}",
209        local_var_configuration.base_path,
210        id = crate::apis::urlencode(id)
211    );
212    let mut local_var_req_builder =
213        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
214
215    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
216        local_var_req_builder =
217            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
218    }
219    if let Some(local_var_param_value) = x_trace_id {
220        local_var_req_builder =
221            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
222    }
223    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
224        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
225    };
226    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
227        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
228    };
229
230    let local_var_req = local_var_req_builder.build()?;
231    let local_var_resp = local_var_client.execute(local_var_req).await?;
232
233    let local_var_status = local_var_resp.status();
234    let local_var_content = local_var_resp.text().await?;
235
236    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
237        Ok(())
238    } else {
239        let local_var_entity: Option<DeleteTransactionLinkError> =
240            serde_json::from_str(&local_var_content).ok();
241        let local_var_error = ResponseContent {
242            status: local_var_status,
243            content: local_var_content,
244            entity: local_var_entity,
245        };
246        Err(Error::ResponseError(local_var_error))
247    }
248}
249
250/// Returns a single link type by its ID.
251pub async fn get_link_type(
252    configuration: &configuration::Configuration,
253    id: &str,
254    x_trace_id: Option<&str>,
255) -> Result<models::LinkTypeSingle, Error<GetLinkTypeError>> {
256    let local_var_configuration = configuration;
257
258    let local_var_client = &local_var_configuration.client;
259
260    let local_var_uri_str = format!(
261        "{}/v1/link-types/{id}",
262        local_var_configuration.base_path,
263        id = crate::apis::urlencode(id)
264    );
265    let mut local_var_req_builder =
266        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
267
268    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
269        local_var_req_builder =
270            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
271    }
272    if let Some(local_var_param_value) = x_trace_id {
273        local_var_req_builder =
274            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
275    }
276    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
277        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
278    };
279    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
280        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
281    };
282
283    let local_var_req = local_var_req_builder.build()?;
284    let local_var_resp = local_var_client.execute(local_var_req).await?;
285
286    let local_var_status = local_var_resp.status();
287    let local_var_content = local_var_resp.text().await?;
288
289    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
290        serde_json::from_str(&local_var_content).map_err(Error::from)
291    } else {
292        let local_var_entity: Option<GetLinkTypeError> =
293            serde_json::from_str(&local_var_content).ok();
294        let local_var_error = ResponseContent {
295            status: local_var_status,
296            content: local_var_content,
297            entity: local_var_entity,
298        };
299        Err(Error::ResponseError(local_var_error))
300    }
301}
302
303/// Returns a single link by its ID.
304pub async fn get_transaction_link(
305    configuration: &configuration::Configuration,
306    id: &str,
307    x_trace_id: Option<&str>,
308) -> Result<models::TransactionLinkSingle, Error<GetTransactionLinkError>> {
309    let local_var_configuration = configuration;
310
311    let local_var_client = &local_var_configuration.client;
312
313    let local_var_uri_str = format!(
314        "{}/v1/transaction-links/{id}",
315        local_var_configuration.base_path,
316        id = crate::apis::urlencode(id)
317    );
318    let mut local_var_req_builder =
319        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
320
321    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
322        local_var_req_builder =
323            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324    }
325    if let Some(local_var_param_value) = x_trace_id {
326        local_var_req_builder =
327            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
328    }
329    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
330        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
331    };
332    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
333        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
334    };
335
336    let local_var_req = local_var_req_builder.build()?;
337    let local_var_resp = local_var_client.execute(local_var_req).await?;
338
339    let local_var_status = local_var_resp.status();
340    let local_var_content = local_var_resp.text().await?;
341
342    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
343        serde_json::from_str(&local_var_content).map_err(Error::from)
344    } else {
345        let local_var_entity: Option<GetTransactionLinkError> =
346            serde_json::from_str(&local_var_content).ok();
347        let local_var_error = ResponseContent {
348            status: local_var_status,
349            content: local_var_content,
350            entity: local_var_entity,
351        };
352        Err(Error::ResponseError(local_var_error))
353    }
354}
355
356/// List all the link types the system has. These include the default ones as well as any new ones.
357pub async fn list_link_type(
358    configuration: &configuration::Configuration,
359    x_trace_id: Option<&str>,
360    limit: Option<i32>,
361    page: Option<i32>,
362) -> Result<models::LinkTypeArray, Error<ListLinkTypeError>> {
363    let local_var_configuration = configuration;
364
365    let local_var_client = &local_var_configuration.client;
366
367    let local_var_uri_str = format!("{}/v1/link-types", local_var_configuration.base_path);
368    let mut local_var_req_builder =
369        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
370
371    if let Some(ref local_var_str) = limit {
372        local_var_req_builder =
373            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
374    }
375    if let Some(ref local_var_str) = page {
376        local_var_req_builder =
377            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
378    }
379    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
380        local_var_req_builder =
381            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
382    }
383    if let Some(local_var_param_value) = x_trace_id {
384        local_var_req_builder =
385            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
386    }
387    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
388        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
389    };
390    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
391        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
392    };
393
394    let local_var_req = local_var_req_builder.build()?;
395    let local_var_resp = local_var_client.execute(local_var_req).await?;
396
397    let local_var_status = local_var_resp.status();
398    let local_var_content = local_var_resp.text().await?;
399
400    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
401        serde_json::from_str(&local_var_content).map_err(Error::from)
402    } else {
403        let local_var_entity: Option<ListLinkTypeError> =
404            serde_json::from_str(&local_var_content).ok();
405        let local_var_error = ResponseContent {
406            status: local_var_status,
407            content: local_var_content,
408            entity: local_var_entity,
409        };
410        Err(Error::ResponseError(local_var_error))
411    }
412}
413
414/// List all transactions under this link type, both the inward and outward transactions.
415pub async fn list_transaction_by_link_type(
416    configuration: &configuration::Configuration,
417    id: &str,
418    x_trace_id: Option<&str>,
419    limit: Option<i32>,
420    page: Option<i32>,
421    start: Option<String>,
422    end: Option<String>,
423    r#type: Option<TransactionTypeFilter>,
424) -> Result<models::TransactionArray, Error<ListTransactionByLinkTypeError>> {
425    let local_var_configuration = configuration;
426
427    let local_var_client = &local_var_configuration.client;
428
429    let local_var_uri_str = format!(
430        "{}/v1/link-types/{id}/transactions",
431        local_var_configuration.base_path,
432        id = crate::apis::urlencode(id)
433    );
434    let mut local_var_req_builder =
435        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
436
437    if let Some(ref local_var_str) = limit {
438        local_var_req_builder =
439            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
440    }
441    if let Some(ref local_var_str) = page {
442        local_var_req_builder =
443            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
444    }
445    if let Some(ref local_var_str) = start {
446        local_var_req_builder =
447            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
448    }
449    if let Some(ref local_var_str) = end {
450        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
451    }
452    if let Some(ref local_var_str) = r#type {
453        local_var_req_builder =
454            local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
455    }
456    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
457        local_var_req_builder =
458            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
459    }
460    if let Some(local_var_param_value) = x_trace_id {
461        local_var_req_builder =
462            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
463    }
464    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
465        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
466    };
467    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
468        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
469    };
470
471    let local_var_req = local_var_req_builder.build()?;
472    let local_var_resp = local_var_client.execute(local_var_req).await?;
473
474    let local_var_status = local_var_resp.status();
475    let local_var_content = local_var_resp.text().await?;
476
477    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
478        serde_json::from_str(&local_var_content).map_err(Error::from)
479    } else {
480        let local_var_entity: Option<ListTransactionByLinkTypeError> =
481            serde_json::from_str(&local_var_content).ok();
482        let local_var_error = ResponseContent {
483            status: local_var_status,
484            content: local_var_content,
485            entity: local_var_entity,
486        };
487        Err(Error::ResponseError(local_var_error))
488    }
489}
490
491/// List all the transaction links.
492pub async fn list_transaction_link(
493    configuration: &configuration::Configuration,
494    x_trace_id: Option<&str>,
495    limit: Option<i32>,
496    page: Option<i32>,
497) -> Result<models::TransactionLinkArray, Error<ListTransactionLinkError>> {
498    let local_var_configuration = configuration;
499
500    let local_var_client = &local_var_configuration.client;
501
502    let local_var_uri_str = format!("{}/v1/transaction-links", local_var_configuration.base_path);
503    let mut local_var_req_builder =
504        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
505
506    if let Some(ref local_var_str) = limit {
507        local_var_req_builder =
508            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
509    }
510    if let Some(ref local_var_str) = page {
511        local_var_req_builder =
512            local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
513    }
514    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
515        local_var_req_builder =
516            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
517    }
518    if let Some(local_var_param_value) = x_trace_id {
519        local_var_req_builder =
520            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
521    }
522    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
523        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
524    };
525    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
526        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
527    };
528
529    let local_var_req = local_var_req_builder.build()?;
530    let local_var_resp = local_var_client.execute(local_var_req).await?;
531
532    let local_var_status = local_var_resp.status();
533    let local_var_content = local_var_resp.text().await?;
534
535    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
536        serde_json::from_str(&local_var_content).map_err(Error::from)
537    } else {
538        let local_var_entity: Option<ListTransactionLinkError> =
539            serde_json::from_str(&local_var_content).ok();
540        let local_var_error = ResponseContent {
541            status: local_var_status,
542            content: local_var_content,
543            entity: local_var_entity,
544        };
545        Err(Error::ResponseError(local_var_error))
546    }
547}
548
549/// Creates a new link type. The data required can be submitted as a JSON body or as a list of parameters (in key=value pairs, like a webform).
550pub async fn store_link_type(
551    configuration: &configuration::Configuration,
552    link_type: LinkType,
553    x_trace_id: Option<&str>,
554) -> Result<models::LinkTypeSingle, Error<StoreLinkTypeError>> {
555    let local_var_configuration = configuration;
556
557    let local_var_client = &local_var_configuration.client;
558
559    let local_var_uri_str = format!("{}/v1/link-types", local_var_configuration.base_path);
560    let mut local_var_req_builder =
561        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
562
563    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
564        local_var_req_builder =
565            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
566    }
567    if let Some(local_var_param_value) = x_trace_id {
568        local_var_req_builder =
569            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
570    }
571    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
572        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
573    };
574    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
575        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
576    };
577    local_var_req_builder = local_var_req_builder.json(&link_type);
578
579    let local_var_req = local_var_req_builder.build()?;
580    let local_var_resp = local_var_client.execute(local_var_req).await?;
581
582    let local_var_status = local_var_resp.status();
583    let local_var_content = local_var_resp.text().await?;
584
585    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
586        serde_json::from_str(&local_var_content).map_err(Error::from)
587    } else {
588        let local_var_entity: Option<StoreLinkTypeError> =
589            serde_json::from_str(&local_var_content).ok();
590        let local_var_error = ResponseContent {
591            status: local_var_status,
592            content: local_var_content,
593            entity: local_var_entity,
594        };
595        Err(Error::ResponseError(local_var_error))
596    }
597}
598
599/// Store a new link between two transactions. For this end point you need the journal_id from a transaction.
600pub async fn store_transaction_link(
601    configuration: &configuration::Configuration,
602    transaction_link_store: TransactionLinkStore,
603    x_trace_id: Option<&str>,
604) -> Result<models::TransactionLinkSingle, Error<StoreTransactionLinkError>> {
605    let local_var_configuration = configuration;
606
607    let local_var_client = &local_var_configuration.client;
608
609    let local_var_uri_str = format!("{}/v1/transaction-links", local_var_configuration.base_path);
610    let mut local_var_req_builder =
611        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
612
613    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
614        local_var_req_builder =
615            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
616    }
617    if let Some(local_var_param_value) = x_trace_id {
618        local_var_req_builder =
619            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
620    }
621    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
622        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
623    };
624    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
625        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
626    };
627    local_var_req_builder = local_var_req_builder.json(&transaction_link_store);
628
629    let local_var_req = local_var_req_builder.build()?;
630    let local_var_resp = local_var_client.execute(local_var_req).await?;
631
632    let local_var_status = local_var_resp.status();
633    let local_var_content = local_var_resp.text().await?;
634
635    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
636        serde_json::from_str(&local_var_content).map_err(Error::from)
637    } else {
638        let local_var_entity: Option<StoreTransactionLinkError> =
639            serde_json::from_str(&local_var_content).ok();
640        let local_var_error = ResponseContent {
641            status: local_var_status,
642            content: local_var_content,
643            entity: local_var_entity,
644        };
645        Err(Error::ResponseError(local_var_error))
646    }
647}
648
649/// Used to update a single link type. All fields that are not submitted will be cleared (set to NULL). The model will tell you which fields are mandatory. You cannot update some of the system provided link types, indicated by the editable=false flag when you list it.
650pub async fn update_link_type(
651    configuration: &configuration::Configuration,
652    id: &str,
653    link_type_update: LinkTypeUpdate,
654    x_trace_id: Option<&str>,
655) -> Result<models::LinkTypeSingle, Error<UpdateLinkTypeError>> {
656    let local_var_configuration = configuration;
657
658    let local_var_client = &local_var_configuration.client;
659
660    let local_var_uri_str = format!(
661        "{}/v1/link-types/{id}",
662        local_var_configuration.base_path,
663        id = crate::apis::urlencode(id)
664    );
665    let mut local_var_req_builder =
666        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
667
668    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
669        local_var_req_builder =
670            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
671    }
672    if let Some(local_var_param_value) = x_trace_id {
673        local_var_req_builder =
674            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
675    }
676    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
677        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
678    };
679    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
680        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
681    };
682    local_var_req_builder = local_var_req_builder.json(&link_type_update);
683
684    let local_var_req = local_var_req_builder.build()?;
685    let local_var_resp = local_var_client.execute(local_var_req).await?;
686
687    let local_var_status = local_var_resp.status();
688    let local_var_content = local_var_resp.text().await?;
689
690    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
691        serde_json::from_str(&local_var_content).map_err(Error::from)
692    } else {
693        let local_var_entity: Option<UpdateLinkTypeError> =
694            serde_json::from_str(&local_var_content).ok();
695        let local_var_error = ResponseContent {
696            status: local_var_status,
697            content: local_var_content,
698            entity: local_var_entity,
699        };
700        Err(Error::ResponseError(local_var_error))
701    }
702}
703
704/// Used to update a single existing link.
705pub async fn update_transaction_link(
706    configuration: &configuration::Configuration,
707    id: &str,
708    transaction_link_update: TransactionLinkUpdate,
709    x_trace_id: Option<&str>,
710) -> Result<models::TransactionLinkSingle, Error<UpdateTransactionLinkError>> {
711    let local_var_configuration = configuration;
712
713    let local_var_client = &local_var_configuration.client;
714
715    let local_var_uri_str = format!(
716        "{}/v1/transaction-links/{id}",
717        local_var_configuration.base_path,
718        id = crate::apis::urlencode(id)
719    );
720    let mut local_var_req_builder =
721        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
722
723    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
724        local_var_req_builder =
725            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
726    }
727    if let Some(local_var_param_value) = x_trace_id {
728        local_var_req_builder =
729            local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
730    }
731    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
732        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
733    };
734    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
735        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
736    };
737    local_var_req_builder = local_var_req_builder.json(&transaction_link_update);
738
739    let local_var_req = local_var_req_builder.build()?;
740    let local_var_resp = local_var_client.execute(local_var_req).await?;
741
742    let local_var_status = local_var_resp.status();
743    let local_var_content = local_var_resp.text().await?;
744
745    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
746        serde_json::from_str(&local_var_content).map_err(Error::from)
747    } else {
748        let local_var_entity: Option<UpdateTransactionLinkError> =
749            serde_json::from_str(&local_var_content).ok();
750        let local_var_error = ResponseContent {
751            status: local_var_status,
752            content: local_var_content,
753            entity: local_var_entity,
754        };
755        Err(Error::ResponseError(local_var_error))
756    }
757}