pub struct SquareClient { /* private fields */ }
Expand description
The SquareClient contains many useful methods allowing for convenient use of the Square API.
Implementations§
Source§impl SquareClient
impl SquareClient
Sourcepub fn new(access_token: &str) -> Self
pub fn new(access_token: &str) -> Self
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);
Sourcepub fn production(self) -> Self
pub fn production(self) -> Self
Sourcepub async fn request<T>(
&self,
endpoint: SquareEndpoint,
json: &T,
) -> Result<SquareResponse, SquareError>
pub async fn request<T>( &self, endpoint: SquareEndpoint, json: &T, ) -> Result<SquareResponse, SquareError>
Sends a request to a given SquareEndpoint
§Arguments
endpoint
- The SquareEndpoint to send the request tobody
- 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
Source§impl SquareClient
impl SquareClient
pub fn endpoint(&self, end_point: SquareEndpoint) -> String
Source§impl SquareClient
impl SquareClient
Sourcepub async fn create_payment(
&self,
payment: Payment,
) -> Result<SquareResponse, SquareError>
pub async fn create_payment( &self, payment: Payment, ) -> Result<SquareResponse, SquareError>
Create a payment with the given Payment to the Square API and get the response back
§Arguments
payment
- A Payment created from the PaymentBuilder
Trait Implementations§
Source§impl Clone for SquareClient
impl Clone for SquareClient
Source§fn clone(&self) -> SquareClient
fn clone(&self) -> SquareClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for SquareClient
impl RefUnwindSafe for SquareClient
impl Send for SquareClient
impl Sync for SquareClient
impl Unpin for SquareClient
impl UnwindSafe for SquareClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more