Expand description
Represents a client used to interact with the paypal api.
Fields
sandbox: bool
Whether you are or not in a sandbox enviroment.
auth: Auth
Api Auth information
Implementations
sourceimpl Client
impl Client
sourcepub fn new(client_id: String, secret: String, sandbox: bool) -> Client
pub fn new(client_id: String, secret: String, sandbox: bool) -> Client
Returns a new client, you must get_access_token afterwards to interact with the api.
Examples
use paypal_rs::Client;
#[tokio::main]
async fn main() {
let clientid = std::env::var("PAYPAL_CLIENTID").unwrap();
let secret = std::env::var("PAYPAL_SECRET").unwrap();
let mut client = Client::new(
clientid,
secret,
true,
);
client.get_access_token().await.unwrap();
}
sourcepub async fn get_access_token(&mut self) -> Result<(), ResponseError>
pub async fn get_access_token(&mut self) -> Result<(), ResponseError>
Gets a access token used in all the api calls.
sourcepub fn access_token_expired(&self) -> bool
pub fn access_token_expired(&self) -> bool
Checks if the access token expired.
sourcepub async fn execute_ext<E>(
&self,
endpoint: &E,
headers: HeaderParams
) -> Result<E::Response, ResponseError>where
E: Endpoint,
pub async fn execute_ext<E>(
&self,
endpoint: &E,
headers: HeaderParams
) -> Result<E::Response, ResponseError>where
E: Endpoint,
Executes the given endpoint with the given headers.
sourcepub async fn execute<E>(
&self,
endpoint: &E
) -> Result<E::Response, ResponseError>where
E: Endpoint,
pub async fn execute<E>(
&self,
endpoint: &E
) -> Result<E::Response, ResponseError>where
E: Endpoint,
Executes the given endpoints with the default headers.
You must remember to call Client::get_access_token first or this may fail due to not being authed.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more