Struct threema_gateway::ApiBuilder
[−]
[src]
pub struct ApiBuilder { pub id: String, pub secret: String, pub private_key: Option<SecretKey>, }
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: String
secret: String
private_key: Option<SecretKey>
Methods
impl ApiBuilder
[src]
fn new<I: Into<String>, S: Into<String>>(id: I, secret: S) -> Self
Initialize the ApiBuilder with the Gateway ID and the Gateway Secret.
fn into_simple(self) -> SimpleApi
Return a SimpleAPI
instance.
fn with_private_key(self, private_key: SecretKey) -> Self
Set the private key. Only needed for E2e mode.
fn with_private_key_bytes(
self,
private_key: &[u8]
) -> Result<Self, ApiBuilderError>
self,
private_key: &[u8]
) -> Result<Self, ApiBuilderError>
Set the private key from a byte slice. Only needed for E2e mode.
fn with_private_key_str(
self,
private_key: &str
) -> Result<Self, ApiBuilderError>
self,
private_key: &str
) -> Result<Self, ApiBuilderError>
Set the private key from a hex-encoded string reference. Only needed for E2e mode.
fn into_e2e(self) -> Result<E2eApi, ApiBuilderError>
Return a E2eAPI
instance.