pub struct ApiBuilder {
    pub id: String,
    pub secret: String,
    pub private_key: Option<SecretKey>,
    pub endpoint: Cow<'static, str>,
}
Expand description

A convenient way to set up the API object.

Examples

Simple API

use threema_gateway::{ApiBuilder, SimpleApi};

let gateway_id = "*3MAGWID";
let gateway_secret = "hihghrg98h00ghrg";

let api: SimpleApi = ApiBuilder::new(gateway_id, gateway_secret).into_simple();

E2E API

use threema_gateway::{ApiBuilder, E2eApi};

let gateway_id = "*3MAGWID";
let gateway_secret = "hihghrg98h00ghrg";
let private_key = "998730fbcac1c57dbb181139de41d12835b3fae6af6acdf6ce91670262e88453";

let api: E2eApi = ApiBuilder::new(gateway_id, gateway_secret)
                             .with_private_key_str(private_key)
                             .and_then(|builder| builder.into_e2e())
                             .unwrap();

Fields

id: Stringsecret: Stringprivate_key: Option<SecretKey>endpoint: Cow<'static, str>

Implementations

Initialize the ApiBuilder with the Gateway ID and the Gateway Secret.

Set a custom API endpoint.

The API endpoint should be a HTTPS URL without trailing slash.

Return a SimpleAPI instance.

Set the private key. Only needed for E2e mode.

Set the private key from a byte slice. Only needed for E2e mode.

Set the private key from a hex-encoded string reference. Only needed for E2e mode.

Return a E2eAPI instance.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.