user_client/
lib.rs

1use reqwest::StatusCode;
2use serde::{Deserialize, Serialize};
3
4pub mod routes;
5pub mod validate;
6
7#[derive(Clone)]
8pub struct Client {
9    host: String,
10}
11
12impl Client {
13    pub fn new(host: String) -> Client {
14        Client { host: host }
15    }
16
17    fn endpoint(&self, url: &str, values: Vec<String>) -> String {
18        let segments: Vec<&str> = url.split("{}").collect();
19
20        let mut endpoint = String::new();
21        endpoint.push_str(&self.host);
22
23        for index in 0..segments.len() {
24            if index > 0 {
25                endpoint.push_str(values.get(index - 1).expect("Not enough values provided"));
26            }
27            endpoint.push_str(segments.get(index).unwrap());
28        }
29
30        endpoint
31    }
32}
33
34fn req() -> reqwest::Client {
35    reqwest::Client::new()
36}