Struct square_rs::client::SquareClient[][src]

pub struct SquareClient { /* fields omitted */ }
Expand description

The SquareClient contains many useful methods allowing for convenient use of the Square API.

Implementations

impl SquareClient[src]

pub fn new(access_token: &str) -> Self[src]

Create a new SquareClient

Arguments

  • access_token - The access token for the Square App you want to use the client with is required.

Example: Create a new client

let client = SquareClient::new(ACCESS_TOKEN);

pub fn production(self) -> Self[src]

Set the client to Production Mode

Arguments

This method takes no arguments, as by default the client will use SandBox Mode.

Example

let client = SquareClient::new(ACCESS_TOKEN).production();

pub async fn request<T: ?Sized>(
    &self,
    endpoint: SquareEndpoint,
    json: &T
) -> Result<SquareResponse, SquareError> where
    T: Serialize
[src]

Sends a request to a given SquareEndpoint

Arguments

  • endpoint - The SquareEndpoint to send the request to
  • body - The json that will be included in the request. All types that meet the conditions to be deserialized to JSON are accepted.

Example:

self.request(SquareEndpoint::Payments, &payment).await

impl SquareClient[src]

pub fn endpoint(&self, end_point: SquareEndpoint) -> String[src]

impl SquareClient[src]

pub async fn create_payment(
    &self,
    payment: Payment
) -> Result<SquareResponse, SquareError>
[src]

Create a payment with the given Payment to the Square API and get the response back

Arguments

Trait Implementations

impl Clone for SquareClient[src]

fn clone(&self) -> SquareClient[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.