ynab_api_async_fork/apis/
user_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 UserApiClient {
21    configuration: Rc<configuration::Configuration>,
22}
23
24impl UserApiClient {
25    pub fn new(configuration: Rc<configuration::Configuration>) -> UserApiClient {
26        UserApiClient {
27            configuration,
28        }
29    }
30}
31
32pub trait UserApi {
33    fn get_user(&self, ) -> Result<crate::models::UserResponse, Error>;
34}
35
36impl UserApi for UserApiClient {
37    fn get_user(&self, ) -> Result<crate::models::UserResponse, Error> {
38        let configuration: &configuration::Configuration = self.configuration.borrow();
39        let client = &configuration.client;
40
41        let uri_str = format!("{}/user", configuration.base_path);
42        let mut req_builder = client.get(uri_str.as_str());
43
44        if let Some(ref user_agent) = configuration.user_agent {
45            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
46        }
47        if let Some(ref token) = configuration.bearer_access_token {
48            req_builder = req_builder.bearer_auth(token.to_owned());
49        };
50
51        // send request
52        let req = req_builder.build()?;
53
54        Ok(client.execute(req)?.error_for_status()?.json()?)
55    }
56
57}