ynab_api_async_fork/apis/
payee_locations_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.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::rc::Rc;
12use std::borrow::Borrow;
13#[allow(unused_imports)]
14use std::option::Option;
15
16use reqwest;
17
18use super::{Error, configuration};
19
20pub struct PayeeLocationsApiClient {
21    configuration: Rc<configuration::Configuration>,
22}
23
24impl PayeeLocationsApiClient {
25    pub fn new(configuration: Rc<configuration::Configuration>) -> PayeeLocationsApiClient {
26        PayeeLocationsApiClient {
27            configuration,
28        }
29    }
30}
31
32pub trait PayeeLocationsApi {
33    fn get_payee_location_by_id(&self, budget_id: &str, payee_location_id: &str) -> Result<crate::models::PayeeLocationResponse, Error>;
34    fn get_payee_locations(&self, budget_id: &str) -> Result<crate::models::PayeeLocationsResponse, Error>;
35    fn get_payee_locations_by_payee(&self, budget_id: &str, payee_id: &str) -> Result<crate::models::PayeeLocationsResponse, Error>;
36}
37
38impl PayeeLocationsApi for PayeeLocationsApiClient {
39    fn get_payee_location_by_id(&self, budget_id: &str, payee_location_id: &str) -> Result<crate::models::PayeeLocationResponse, Error> {
40        let configuration: &configuration::Configuration = self.configuration.borrow();
41        let client = &configuration.client;
42
43        let uri_str = format!("{}/budgets/{budget_id}/payee_locations/{payee_location_id}", configuration.base_path, budget_id=crate::apis::urlencode(budget_id), payee_location_id=crate::apis::urlencode(payee_location_id));
44        let mut req_builder = client.get(uri_str.as_str());
45
46        if let Some(ref user_agent) = configuration.user_agent {
47            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
48        }
49        if let Some(ref token) = configuration.bearer_access_token {
50            req_builder = req_builder.bearer_auth(token.to_owned());
51        };
52
53        // send request
54        let req = req_builder.build()?;
55
56        Ok(client.execute(req)?.error_for_status()?.json()?)
57    }
58
59    fn get_payee_locations(&self, budget_id: &str) -> Result<crate::models::PayeeLocationsResponse, Error> {
60        let configuration: &configuration::Configuration = self.configuration.borrow();
61        let client = &configuration.client;
62
63        let uri_str = format!("{}/budgets/{budget_id}/payee_locations", configuration.base_path, budget_id=crate::apis::urlencode(budget_id));
64        let mut req_builder = client.get(uri_str.as_str());
65
66        if let Some(ref user_agent) = configuration.user_agent {
67            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
68        }
69        if let Some(ref token) = configuration.bearer_access_token {
70            req_builder = req_builder.bearer_auth(token.to_owned());
71        };
72
73        // send request
74        let req = req_builder.build()?;
75
76        Ok(client.execute(req)?.error_for_status()?.json()?)
77    }
78
79    fn get_payee_locations_by_payee(&self, budget_id: &str, payee_id: &str) -> Result<crate::models::PayeeLocationsResponse, Error> {
80        let configuration: &configuration::Configuration = self.configuration.borrow();
81        let client = &configuration.client;
82
83        let uri_str = format!("{}/budgets/{budget_id}/payees/{payee_id}/payee_locations", configuration.base_path, budget_id=crate::apis::urlencode(budget_id), payee_id=crate::apis::urlencode(payee_id));
84        let mut req_builder = client.get(uri_str.as_str());
85
86        if let Some(ref user_agent) = configuration.user_agent {
87            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
88        }
89        if let Some(ref token) = configuration.bearer_access_token {
90            req_builder = req_builder.bearer_auth(token.to_owned());
91        };
92
93        // send request
94        let req = req_builder.build()?;
95
96        Ok(client.execute(req)?.error_for_status()?.json()?)
97    }
98
99}