Struct threema_gateway::ApiBuilder [−][src]
A convenient way to set up the API object.
Examples
Simple API
use threema_gateway::{ApiBuilder, SimpleApi}; let gateway_id = "*3MAGWID"; let api_secret = "hihghrg98h00ghrg"; let api: SimpleApi = ApiBuilder::new(gateway_id, api_secret).into_simple();
E2E API
use threema_gateway::{ApiBuilder, E2eApi}; let gateway_id = "*3MAGWID"; let api_secret = "hihghrg98h00ghrg"; let private_key = "998730fbcac1c57dbb181139de41d12835b3fae6af6acdf6ce91670262e88453"; let api: E2eApi = ApiBuilder::new(gateway_id, api_secret) .with_private_key_str(private_key) .and_then(|builder| builder.into_e2e()) .unwrap();
Fields
id: String
secret: String
private_key: Option<SecretKey>
endpoint: Cow<'static, str>
client: Option<Client>
Implementations
impl ApiBuilder
[src]
pub fn new<I: Into<String>, S: Into<String>>(id: I, secret: S) -> Self
[src]
Initialize the ApiBuilder with the Gateway ID and the Gateway Secret.
pub fn with_custom_endpoint<E: Into<Cow<'static, str>>>(
self,
endpoint: E
) -> Self
[src]
self,
endpoint: E
) -> Self
Set a custom API endpoint.
The API endpoint should be a HTTPS URL without trailing slash.
pub fn with_client(self, client: Client) -> Self
[src]
Set a custom reqwest Client
that will be re-used
for all connections.
pub fn into_simple(self) -> SimpleApi
[src]
Return a SimpleAPI
instance.
pub fn with_private_key(self, private_key: SecretKey) -> Self
[src]
Set the private key. Only needed for E2e mode.
pub fn with_private_key_bytes(
self,
private_key: &[u8]
) -> Result<Self, ApiBuilderError>
[src]
self,
private_key: &[u8]
) -> Result<Self, ApiBuilderError>
Set the private key from a byte slice. Only needed for E2e mode.
pub fn with_private_key_str(
self,
private_key: &str
) -> Result<Self, ApiBuilderError>
[src]
self,
private_key: &str
) -> Result<Self, ApiBuilderError>
Set the private key from a hex-encoded string reference. Only needed for E2e mode.
pub fn into_e2e(self) -> Result<E2eApi, ApiBuilderError>
[src]
Return a E2eAPI
instance.
This will fail if no private key was set.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ApiBuilder
impl Send for ApiBuilder
impl Sync for ApiBuilder
impl Unpin for ApiBuilder
impl !UnwindSafe for ApiBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,