Crates.io | geeny-api |
lib.rs | geeny-api |
version | 0.3.0 |
source | src |
created_at | 2017-09-08 15:20:29.74645 |
updated_at | 2017-10-20 11:14:36.710069 |
description | Crate for consuming the Geeny APIs as a client |
homepage | https://docs.rs/geeny-api/ |
repository | https://github.com/geeny/geeny-api-rs |
max_upload_size | |
id | 31062 |
size | 53,646 |
geeny-api-rs
is a Rust Crate for consuming the Geeny APIs as a client. geeny-api-rs
is based on Reqwest.
In your Cargo.toml
, add the following lines:
[dependencies]
geeny-api = "0.2"
In your main project file (likely lib.rs
or main.rs
), add the following line:
extern crate geeny_api;
The Geeny Connect APIs, used for authentication, are exposed via the geeny_api::ConnectApi
structure and related methods.
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();
}
The Geeny Things APIs, used for creation, deletion, and management of Things, ThingTypes, and MessageTypes, are exposed via the geeny_api::ThingsApi
structure and related methods.
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);
}
}
This crate has been tested with Stable Rust versions 1.19.0 and above.
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.
Contact: devsupport@geeny.io
This crate makes use of the following third party components with the following licenses:
License | Count | Dependencies |
---|---|---|
Apache-2.0 | 1 | openssl |
Apache-2.0/MIT | 47 | antidote, backtrace, backtrace-sys, bitflags, bitflags, cfg-if, core-foundation, core-foundation-sys, custom_derive, dtoa, error-chain, foreign-types, gcc, httparse, hyper-native-tls, idna, itoa, lazy_static, libc, log, native-tls, num-traits, num_cpus, percent-encoding, pkg-config, quote, rand, reqwest, rustc-demangle, security-framework, security-framework-sys, serde, serde_derive, serde_derive_internals, serde_json, serde_urlencoded, syn, synom, tempdir, time, traitobject, unicode-bidi, unicode-normalization, unicode-xid, url, uuid, vcpkg |
BSD-3-Clause | 3 | adler32, magenta, magenta-sys |
MIT | 20 | advapi32-sys, base64, conv, crypt32-sys, dbghelp-sys, hyper, kernel32-sys, language-tags, libflate, matches, mime, openssl-sys, redox_syscall, schannel, secur32-sys, typeable, unicase, version_check, winapi, winapi-build |
MIT/Unlicense | 1 | byteorder |