HttpClient

Struct HttpClient 

Source
pub struct HttpClient { /* private fields */ }
Expand description

SMS-API HTTP interface client.

Implementations§

Source§

impl HttpClient

Source

pub fn new(config: HttpConfig, tls: &Option<TLSConfig>) -> HttpResult<Self>

Create a new HTTP client that uses the base_url.

Source

pub async fn set_friendly_name( &self, phone_number: impl Into<String>, friendly_name: Option<impl Into<String>>, ) -> HttpResult<bool>

Set/Remove the friendly name for a given phone number.

Source

pub async fn get_friendly_name( &self, phone_number: impl Into<String>, ) -> HttpResult<Option<String>>

Get the friendly name associated with a given phone number.

Source

pub async fn get_messages( &self, phone_number: impl Into<String>, pagination: Option<HttpPaginationOptions>, ) -> HttpResult<Vec<SmsStoredMessage>>

Get messages sent to and from a given phone number. Pagination options are supported.

Source

pub async fn get_latest_numbers( &self, pagination: Option<HttpPaginationOptions>, ) -> HttpResult<Vec<LatestNumberFriendlyNamePair>>

Get the latest phone numbers that have been in contact with the SMS-API. This includes both senders and receivers. Pagination options are supported.

Source

pub async fn get_delivery_reports( &self, message_id: i64, pagination: Option<HttpPaginationOptions>, ) -> HttpResult<Vec<HttpSmsDeliveryReport>>

Get received delivery reports for a given message_id (comes from send_sms etc). Pagination options are supported.

Source

pub async fn send_sms( &self, message: &HttpOutgoingSmsMessage, ) -> HttpResult<HttpSmsSendResponse>

Send an SMS message to a target phone_number. The result will contain the message reference (provided from modem) and message id (used internally). This will use the message timeout for the request if one is set.

Source

pub async fn get_network_status( &self, ) -> HttpResult<HttpModemNetworkStatusResponse>

Get the carrier network status.

Source

pub async fn get_signal_strength( &self, ) -> HttpResult<HttpModemSignalStrengthResponse>

Get the modem signal strength for the connected tower.

Source

pub async fn get_network_operator( &self, ) -> HttpResult<HttpModemNetworkOperatorResponse>

Get the underlying network operator, this is often the same across multiple service providers for a given region. Eg: vodafone.

Source

pub async fn get_service_provider(&self) -> HttpResult<String>

Get the SIM service provider, this is the brand that manages the contract. This matters less than the network operator, as they’re just resellers. Eg: ASDA Mobile.

Source

pub async fn get_battery_level( &self, ) -> HttpResult<HttpModemBatteryLevelResponse>

Get the Modem Hat’s battery level, which is used for GNSS warm starts.

Source

pub async fn get_device_info(&self) -> HttpResult<HttpSmsDeviceInfoData>

Get device info summary result. This is a more efficient way to request all device info.

Source

pub async fn get_phone_number(&self) -> HttpResult<Option<String>>

Get the configured sender SMS number. This should be used primarily for client identification. This is optional, as the API could have left this un-configured without any value set.

Source

pub async fn get_version(&self) -> HttpResult<String>

Get the modem SMS-API version string. This will be a semver format, often with feature names added as a suffix, eg: “0.0.1+sentry”.

Trait Implementations§

Source§

impl Debug for HttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,