Struct geeny_api::ConnectApi [] [src]

pub struct ConnectApi(_);

Interface for Geeny Connect APIs

ConnectApi is an interface for interacting with the Geeny Connect API. The full specification of these APIs may be found in the API Specification.

Methods

impl ConnectApi
[src]

[src]

Create a new Connect API handle

Example

use geeny_api::ConnectApi;

let api = ConnectApi::new("https://connect.geeny.io".into(), 443);

[src]

Register a new account and obtain an API token

If the response was successful, Ok(AuthLoginResponse) is returned. If a network or server error occurred, or if the parameters were incorrect, an Err is returned.

Example

extern crate geeny_api;
use geeny_api::ConnectApi;
use geeny_api::models::*;

fn main() {
    let api = ConnectApi::default();

    let new_user = RegistrationRequest {
        email: "demo@email.com".into(),
        first_name: "Demo".into(),
        last_name: "User".into(),
        password: "S3cureP@ssword!".into(),
        is_developer: true,
    };

    let response = api.registration(&new_user).unwrap();
    println!("token: {}", response.token);
}

[src]

[src]

Perform a Basic Auth login and obtain an API token

If the response was successful, Ok(AuthLoginResponse) is returned. If a network or server error occurred, or if the credentials were incorrect, an Err is returned.

Example

extern crate geeny_api;
use geeny_api::ConnectApi;
use geeny_api::models::*;

fn main() {
    let api = ConnectApi::default();

    let log_req = AuthLoginRequest {
        email: "demo@email.com".into(),
        password: "S3cureP@ssword!".into(),
    };

    let response = api.login(&log_req).unwrap();
    println!("token: {}", response.token);
}

[src]

Check the validity of an API token

If the response was successful, Ok(()) is returned. If a network or server error occurred, or if the token is invalid, an Err is returned.

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(),
    };

    let response = api.login(&log_req).unwrap();

    // then, verify the token
    api.check_token(&response).unwrap();
}

[src]

Refresh an API token

If the response was successful, Ok(AuthLoginResponse) is returned. If a network or server error occurred, or if the token is not refreshable, an Err is returned.

The token returned should be used for all further API requests, and the original token should be discarded on successful refresh.

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(),
    };
    let response = api.login(&log_req).unwrap();
    println!("1st Token: {}", response.token);

    // then, refresh the token
    let new_response = api.refresh_token(&response).unwrap();
    println!("2nd Token: {}", new_response.token);
}

Trait Implementations

impl Debug for ConnectApi
[src]

[src]

Formats the value using the given formatter.

impl Clone for ConnectApi
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for ConnectApi
[src]

[src]

Create a ConnectApi handle for the Production Connect Service

Example

use geeny_api::ConnectApi;

let api = ConnectApi::default();