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
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2017 Telefónica Germany Next GmbH. See the COPYRIGHT file at
// the top-level directory of this distribution
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

//! # Geeny API Interface Library
//!
//! ## Introduction
//!
//! `geeny-api-rs` is a Rust Crate for consuming the Geeny APIs as a client. `geeny-api-rs` is based on [Reqwest](https://docs.rs/reqwest).
//!
//! ## Components
//!
//! ### Connect API
//!
//! The Geeny Connect APIs, used for authentication, are exposed via the `geeny_api::ConnectApi` structure and related methods.
//!
//! #### Example
//!
//! ```rust,no_run
//! extern crate geeny_api;
//! use geeny_api::ConnectApi;
//! use geeny_api::models::*;
//!
//! fn main() {
//!     let api = ConnectApi::default();
//!
//!     // first, obtain a token
//!     let log_req = AuthLoginRequest {
//!         email: "demo@email.com".into(),
//!         password: "S3cureP@ssword!".into(),
//!     };
//!
//!     // Login
//!     let response = api.login(&log_req).unwrap();
//!
//!     println!("Your token is: {}", response.token);
//!
//!     // Check token validity
//!     let _ = api.check_token(&response);
//!
//!     // Refresh a Token
//!     let new_response = api.refresh_token(&response).unwrap();
//! }
//! ```
//!
//! ### Things API
//!
//! The Geeny Things APIs, used for creation, deletion, and management of `Things`, `ThingType`s, and `MessageType`s, are exposed via the `geeny_api::ThingsApi` structure and related methods.
//!
//! #### Example
//!
//! ```rust,no_run
//! extern crate geeny_api;
//! use geeny_api::ThingsApi;
//! use geeny_api::models::*;
//!
//! fn main() {
//!     let api = ThingsApi::default();
//!     let token = "...".to_string(); // from ConnectApi.login()
//!
//!     // Display all thing types
//!     for tt in api.get_thing_types(&token).unwrap() {
//!         println!("thing type: {:?}", tt);
//!     }
//!
//!     // Display all message types
//!     for mt in api.get_message_types(&token).unwrap() {
//!         println!(": {:?}", mt);
//!     }
//!
//!     // Display all things
//!     for thng in api.get_things(&token).unwrap() {
//!         println!(": {:?}", thng);
//!     }
//! }
//! ```
//!
//! ## Requirements
//!
//! This crate has been tested with `rustc` versions 1.19.0 and above.
//!
//! ## Installation & Configuration
//!
//! In your `Cargo.toml`, add the following lines:
//!
//! ```toml
//! [dependencies]
//! geeny_api = "0.2"
//! ```
//!
//! In your main project file (likely `lib.rs` or `main.rs`), add the following line:
//!
//! ```rust
//! extern crate geeny_api;
//! ```
//!
//! ## License
//!
//! Copyright (C) 2017 Telefónica Germany Next GmbH, Charlottenstrasse 4, 10969 Berlin.
//!
//! This project is licensed under the terms of the [Mozilla Public License Version 2.0](LICENSE.md).
//!
//! Contact: devsupport@geeny.io

// error chain throws an obnoxious unused doc comment lint
#![allow(unused_doc_comment)]

#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;

extern crate reqwest;
extern crate serde;
extern crate uuid;

#[cfg(test)]
extern crate serde_json;

pub mod models;
pub mod errors;
mod endpoints;

pub use self::endpoints::connect::ConnectApi;
pub use self::endpoints::things::ThingsApi;