Crate geeny_api [] [src]

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.

Components

Connect API

The Geeny Connect APIs, used for authentication, are exposed via the geeny_api::ConnectApi structure and related methods.

Example

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, ThingTypes, and MessageTypes, are exposed via the geeny_api::ThingsApi structure and related methods.

Example

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:

[dependencies]
geeny_api = "0.2"

In your main project file (likely lib.rs or main.rs), add the following line:

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.

Contact: devsupport@geeny.io

Modules

errors

Geeny API Error Types

models

API Data Models

Structs

ConnectApi

Interface for Geeny Connect APIs

ThingsApi

Interface for Geeny Things Mangager APIs