pub struct Client {
pub default_headers: HttpRequestHeaders,
pub auth_data: Arc<RwLock<AuthData>>,
/* private fields */
}
Fields§
§default_headers: HttpRequestHeaders
§auth_data: Arc<RwLock<AuthData>>
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
username: String,
client_secret: String,
environment: Environment,
) -> Result<Self, Box<PayPalError>>
pub fn new( username: String, client_secret: String, environment: Environment, ) -> Result<Self, Box<PayPalError>>
Initialize a new PayPal client. To authenticate, use the authenticate
method.
§Errors
Errors if the environment URL cannot be parsed. This should never happen, if it does, please open an issue.
Sourcepub fn compose_url(&self, request_path: &str) -> Url
pub fn compose_url(&self, request_path: &str) -> Url
Composes an URL from the base URL and the provided path.
§Arguments
request_path
- The path to append to the base URL.
Sourcepub fn compose_url_with_query(
&self,
request_path: &str,
query: &QueryParams,
) -> Result<Url, Error>
pub fn compose_url_with_query( &self, request_path: &str, query: &QueryParams, ) -> Result<Url, Error>
pub fn with_app_info(self, app_info: &AppInfo) -> Self
Sourcepub async fn get<T: Endpoint>(
&self,
endpoint: &T,
) -> Result<T::ResponseBody, PayPalError>
pub async fn get<T: Endpoint>( &self, endpoint: &T, ) -> Result<T::ResponseBody, PayPalError>
Sourcepub async fn post<T: Endpoint>(
&self,
endpoint: &T,
) -> Result<T::ResponseBody, PayPalError>
pub async fn post<T: Endpoint>( &self, endpoint: &T, ) -> Result<T::ResponseBody, PayPalError>
Sourcepub fn set_request_headers(
&self,
request_builder: RequestBuilder,
headers: &HttpRequestHeaders,
) -> RequestBuilder
pub fn set_request_headers( &self, request_builder: RequestBuilder, headers: &HttpRequestHeaders, ) -> RequestBuilder
Sourcepub async fn authenticate(&self) -> Result<(), PayPalError>
pub async fn authenticate(&self) -> Result<(), PayPalError>
Authenticates the client with PayPal. This gets called automatically when the auth strategy
is set to TokenRefresh
and the access token is about to expire.
It’s recommended to call this method manually when initializing the client.
§Errors
Errors if the request fails or the response body cannot be deserialized.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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