summaryrefslogtreecommitdiff
path: root/src/kraken/mod.rs
diff options
context:
space:
mode:
authorDavid Blajda <blajda@hotmail.com>2018-12-27 22:03:23 +0000
committerDavid Blajda <blajda@hotmail.com>2018-12-27 22:03:23 +0000
commit678e3d3f28cb8594204dc5e2b7597ae66a4582c7 (patch)
tree55b563cfdc09dab8f18c1f4d688ebf0c2187985c /src/kraken/mod.rs
parentcb1b144e48ee357a76f551433d4886f092d259c8 (diff)
Use Id types for endpoints and implement kraken headers
Diffstat (limited to 'src/kraken/mod.rs')
-rw-r--r--src/kraken/mod.rs46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/kraken/mod.rs b/src/kraken/mod.rs
index 59d00c0..0201295 100644
--- a/src/kraken/mod.rs
+++ b/src/kraken/mod.rs
@@ -1,53 +1,19 @@
-use reqwest::header;
-use std::sync::Arc;
-use reqwest::r#async::RequestBuilder;
-use reqwest::r#async::Client as ReqwestClient;
+use crate::client::Client as GenericClient;
+use crate::client::Version;
pub use super::types;
-mod endpoints;
-mod models;
-
-
-const ACCEPT: &str = "application/vnd.twitchtv.v5+json";
-pub const API_DOMAIN: &str = "api.twitch.tv";
+mod namespaces;
+pub mod models;
#[derive(Clone)]
pub struct Client {
- inner: Arc<ClientRef>,
-}
-
-struct ClientRef {
- id: String,
- client: ReqwestClient
+ inner: GenericClient
}
impl Client {
pub fn new(id: &str) -> Client {
Client {
- inner: Arc::new(ClientRef {
- id: id.to_owned(),
- client: ReqwestClient::new(),
- })
+ inner: GenericClient::new(id, Version::Kraken)
}
}
-
- pub fn new_with_client(id: &str, client: ReqwestClient) -> Client {
- Client {
- inner: Arc::new(ClientRef {
- id: id.to_owned(),
- client: client,
- })
- }
- }
-
- fn apply_standard_headers(&self, request: RequestBuilder)
- -> RequestBuilder
- {
- let client_header = header::HeaderValue::from_str(&self.inner.id).unwrap();
- let accept_header = header::HeaderValue::from_str(ACCEPT).unwrap();
-
- request
- .header("Accept", accept_header)
- .header("Client-ID", client_header)
- }
}