aboutsummaryrefslogtreecommitdiffstats
path: root/ynab-api/src/apis/payee_locations_api.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-08-09 02:06:22 -0400
committerJesse Luehrs <doy@tozt.net>2019-08-09 02:52:44 -0400
commitfaf9c8aa1e41df1889f8382e9c2183e2d5f85de1 (patch)
tree0e4218dd5c1d47735fd6324fb30a01c964aad781 /ynab-api/src/apis/payee_locations_api.rs
parentd54b8f01ea9c253a326a9601f58a423a64ba8b4a (diff)
downloadynab-api-faf9c8aa1e41df1889f8382e9c2183e2d5f85de1.tar.gz
ynab-api-faf9c8aa1e41df1889f8382e9c2183e2d5f85de1.zip
add openapi-generated api client
Diffstat (limited to 'ynab-api/src/apis/payee_locations_api.rs')
-rw-r--r--ynab-api/src/apis/payee_locations_api.rs112
1 files changed, 112 insertions, 0 deletions
diff --git a/ynab-api/src/apis/payee_locations_api.rs b/ynab-api/src/apis/payee_locations_api.rs
new file mode 100644
index 0000000..88f12e1
--- /dev/null
+++ b/ynab-api/src/apis/payee_locations_api.rs
@@ -0,0 +1,112 @@
+/*
+ * YNAB API Endpoints
+ *
+ * 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.youneedabudget.com
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+use std::rc::Rc;
+use std::borrow::Borrow;
+
+use reqwest;
+
+use super::{Error, configuration, urlencode};
+
+pub struct PayeeLocationsApiClient {
+ configuration: Rc<configuration::Configuration>,
+}
+
+impl PayeeLocationsApiClient {
+ pub fn new(configuration: Rc<configuration::Configuration>) -> PayeeLocationsApiClient {
+ PayeeLocationsApiClient {
+ configuration: configuration,
+ }
+ }
+}
+
+pub trait PayeeLocationsApi {
+ fn get_payee_location_by_id(&self, budget_id: &str, payee_location_id: &str) -> Result<::models::PayeeLocationResponse, Error>;
+ fn get_payee_locations(&self, budget_id: &str) -> Result<::models::PayeeLocationsResponse, Error>;
+ fn get_payee_locations_by_payee(&self, budget_id: &str, payee_id: &str) -> Result<::models::PayeeLocationsResponse, Error>;
+}
+
+impl PayeeLocationsApi for PayeeLocationsApiClient {
+ fn get_payee_location_by_id(&self, budget_id: &str, payee_location_id: &str) -> Result<::models::PayeeLocationResponse, Error> {
+ let configuration: &configuration::Configuration = self.configuration.borrow();
+ let client = &configuration.client;
+
+ let uri_str = format!("{}/budgets/{budget_id}/payee_locations/{payee_location_id}", configuration.base_path, budget_id=urlencode(budget_id), payee_location_id=urlencode(payee_location_id));
+ let mut req_builder = client.get(uri_str.as_str());
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+ if let Some(ref apikey) = configuration.api_key {
+ let key = apikey.key.clone();
+ let val = match apikey.prefix {
+ Some(ref prefix) => format!("{} {}", prefix, key),
+ None => key,
+ };
+ req_builder = req_builder.header("Authorization", val);
+ };
+
+ // send request
+ let req = req_builder.build()?;
+
+ Ok(client.execute(req)?.error_for_status()?.json()?)
+ }
+
+ fn get_payee_locations(&self, budget_id: &str) -> Result<::models::PayeeLocationsResponse, Error> {
+ let configuration: &configuration::Configuration = self.configuration.borrow();
+ let client = &configuration.client;
+
+ let uri_str = format!("{}/budgets/{budget_id}/payee_locations", configuration.base_path, budget_id=urlencode(budget_id));
+ let mut req_builder = client.get(uri_str.as_str());
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+ if let Some(ref apikey) = configuration.api_key {
+ let key = apikey.key.clone();
+ let val = match apikey.prefix {
+ Some(ref prefix) => format!("{} {}", prefix, key),
+ None => key,
+ };
+ req_builder = req_builder.header("Authorization", val);
+ };
+
+ // send request
+ let req = req_builder.build()?;
+
+ Ok(client.execute(req)?.error_for_status()?.json()?)
+ }
+
+ fn get_payee_locations_by_payee(&self, budget_id: &str, payee_id: &str) -> Result<::models::PayeeLocationsResponse, Error> {
+ let configuration: &configuration::Configuration = self.configuration.borrow();
+ let client = &configuration.client;
+
+ let uri_str = format!("{}/budgets/{budget_id}/payees/{payee_id}/payee_locations", configuration.base_path, budget_id=urlencode(budget_id), payee_id=urlencode(payee_id));
+ let mut req_builder = client.get(uri_str.as_str());
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+ if let Some(ref apikey) = configuration.api_key {
+ let key = apikey.key.clone();
+ let val = match apikey.prefix {
+ Some(ref prefix) => format!("{} {}", prefix, key),
+ None => key,
+ };
+ req_builder = req_builder.header("Authorization", val);
+ };
+
+ // send request
+ let req = req_builder.build()?;
+
+ Ok(client.execute(req)?.error_for_status()?.json()?)
+ }
+
+}