TwilioRequest

Struct TwilioRequest 

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

Generic Twilio request builder.

Data is encoded as application/x-www-form-urlencode.

When performing GET should be appended to URL as query string.

When performing POST should be placed as body of HTTP Request with Content-Type equal to application/x-www-form-urlencode.

While it implements Serialize, there is no need to employ it as internally data is already encoded.

Implementations§

Source§

impl TwilioRequest

Source

pub const CONTENT_TYPE: &'static str = "application/x-www-form-urlencode"

Content type of Twilio API request.

To be used for HTTP Post requests

Source

pub const fn new() -> Self

Creates new request.

Source

pub fn into_bytes(self) -> Vec<u8>

Returns raw application/x-www-form-urlencoded data.

Source

pub fn into_string(self) -> String

Returns string application/x-www-form-urlencoded data.

Source

pub fn as_form(&self) -> &str

Returns reference as string application/x-www-form-urlencoded data.

Source

pub fn account_sid(&mut self, sid: &str) -> &mut Self

Adds AccountSid to specify owner of the resource.

Source

pub fn from(&mut self, from: &str) -> &mut Self

Adds From field, which is identifier of caller.

Type should be the same as for To

Source

pub fn to(&mut self, to: &str) -> &mut Self

Adds To field, which is identifier of callee.

Type should be the same as for To

Source

pub fn body(&mut self, body: &str) -> &mut Self

Adds Body field.

Source

pub fn media_url(&mut self, media_url: &str) -> &mut Self

Adds MediaUrl field.

Source

pub fn post_status_callback(&mut self, url: &str) -> &mut Self

Adds StatusCallback field, which is url where to perform POST request

Source

pub fn provide_feedback(&mut self, value: bool) -> &mut Self

Sets ProvideFeedback field, to specify whether message delivery should be tracked.

Source

pub fn attempt(&mut self, attempt: u32) -> &mut Self

Sets Attempt field, to indicate total number of attempts to post message.

Source

pub fn validity_period(&mut self, attempt: u16) -> &mut Self

Sets ValidityPeriod field, to indicate number of seconds allowed in waiting queue.

If message is enqueuedfor longer, it is discarded by Twilio

Source

pub fn send_at(&mut self, date: &str) -> &mut Self

Sets SendAt field, to indicate where message is to be sent.

Source

pub fn twiml(&mut self, twiml: &str) -> &mut Self

Sets Twiml field, to provide call’s content as xml string.

Source

pub fn url(&mut self, url: &str) -> &mut Self

Sets Url field, to provide call’s content via GET to the provided url

Source

pub fn url_with_method(&mut self, method: TwilioMethod, url: &str) -> &mut Self

Sets Url field, to provide call’s content via GET to the provided url.

With option of setting HTTP method to access URL.

Source

pub fn status_url(&mut self, url: &str) -> &mut Self

Sets StatusCallback field, to provide URL where to post status information.

Source

pub fn status_url_with_method( &mut self, method: TwilioMethod, url: &str, ) -> &mut Self

Sets StatusCallback field, to provide URL where to post status information.

With option of setting HTTP method to access URL.

Source

pub fn caller_id(&mut self, id: &str) -> &mut Self

Sets CallerId field, to provide caller identification.

Source

pub fn send_digits(&mut self, digits: &str) -> &mut Self

Sets SendDigits field, to provide set of keys to dial after call is established.

Source

pub fn page_size(&mut self, size: u32) -> &mut Self

Sets PageSize field, to provide number of resources max for when reading multiple resources

Source

pub fn start_date(&mut self, date: &str) -> &mut Self

Sets StartDate field, to provide starting date for when reading multiple calls

Source

pub fn end_date(&mut self, date: &str) -> &mut Self

Sets EndDate field, to provide ending date for when reading multiple calls

Source

pub fn date_sent(&mut self, date: &str) -> &mut Self

Sets DateSent field, to provide message date for when reading multiple message

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for TwilioRequest

Source§

fn deserialize<D: Deserializer<'de>>( deserializer: D, ) -> Result<TwilioRequest, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Into<TwilioRequest> for Call<'a>

Source§

fn into(self) -> TwilioRequest

Converts this type into the (usually inferred) input type.
Source§

impl<'a> Into<TwilioRequest> for Mms<'a>

Source§

fn into(self) -> TwilioRequest

Converts this type into the (usually inferred) input type.
Source§

impl<'a> Into<TwilioRequest> for Sms<'a>

Source§

fn into(self) -> TwilioRequest

Converts this type into the (usually inferred) input type.
Source§

impl Serialize for TwilioRequest

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. 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, 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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,