summaryrefslogtreecommitdiff
path: root/src/kraken/mod.rs
blob: 2015781ddd81230ec43514eafb4c86a276e0f5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use reqwest::header;
use reqwest::r#async::{Chunk, Decoder, Request, Response};
use reqwest::r#async::Client as ReqwestClient;

mod endpoints;
mod models;

const ACCEPT: &str = "application/vnd.twitchtv.v5+json";
pub const API_DOMAIN: &str = "api.twitch.tv";

pub struct Client {
    id: String,
}

impl Client {
    pub fn new(id: &str) -> Client {
        Client {
            id: id.to_owned(),
        }
    }

   fn create_reqwest_client(&self) -> ReqwestClient {
        let mut headers = header::HeaderMap::new();
        let auth_key = &self.id;
        let client_header = header::HeaderValue::from_str(auth_key).unwrap();
        let accept_header = header::HeaderValue::from_str(ACCEPT).unwrap();
        headers.insert("Client-ID", client_header);
        headers.insert("Accept", accept_header);

        let client = ReqwestClient::builder().default_headers(headers).build().unwrap();
        client
    }
}