diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 19:19:44 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 19:19:44 +0100 |
commit | f1b68ffc0f539b7782ed5cc593cbebc360fe4791 (patch) | |
tree | a94fea478c8f8fbbe64b4ebe4285d84c442ba825 /src | |
parent | cdcd645dc455a0778b91b3f7d051dbfb37c8755d (diff) | |
download | oslobike-f1b68ffc0f539b7782ed5cc593cbebc360fe4791.tar.gz oslobike-f1b68ffc0f539b7782ed5cc593cbebc360fe4791.tar.bz2 oslobike-f1b68ffc0f539b7782ed5cc593cbebc360fe4791.zip |
Add a tiny bit of documentation.
Diffstat (limited to 'src')
-rw-r--r-- | src/api.rs | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -33,11 +33,18 @@ fn url_for(endpoint: &str) -> String { [API_BASE, endpoint].join("/") } +/// The oslobike::Api struct holds the state for the Api. pub struct Api { client: reqwest::Client, } impl Api { + + /// Create an instance of the API like this: + /// + /// # let my_api_key = String::from("1234"); + /// let api = oslobike::Api::new(my_api_key).expect("An error occured"); + /// pub fn new(api_key: String) -> ApiResult<Api> { let mut hdrs = HeaderMap::new(); hdrs.insert("client-identifier", HeaderValue::from_str(&api_key)?); @@ -49,6 +56,7 @@ impl Api { Ok(Api { client }) } + /// Fetch the list of stations and their basic data from the api. pub fn stations(&self) -> ApiResult<Vec<Station>> { let response_json = self.client.get(&url_for("stations")) .send()? |