Struct Client

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

Entrypoint for interacting with the API client.

Implementations§

Source§

impl Client

Source

pub fn new<I, K, R, T, Q>( client_id: I, client_secret: K, redirect_uri: R, token: T, refresh_token: Q, server: impl Into<RootDefaultServers>, ) -> Self
where I: ToString, K: ToString, R: ToString, T: ToString, Q: ToString,

Create a new Client struct. Requires OAuth2 configuration values as well as an access and refresh token.

§Panics

This function will panic if the internal http client fails to create

Source

pub fn set_auto_access_token_refresh(&mut self, enabled: bool) -> &mut Self

Enables or disables the automatic refreshing of access tokens upon expiration

Source

pub async fn set_expires_at(&self, expires_at: Option<Instant>) -> &Self

Sets a specific Instant at which the access token should be considered expired. The expiration value will only be used when automatic access token refreshing is also enabled. None may be passed in if the expiration is unknown. In this case automatic refreshes will be attempted when encountering an UNAUTHENTICATED status code on a response.

Source

pub async fn expires_at(&self) -> Option<Instant>

Gets the Instant at which the access token used by this client is set to expire if one is known

Source

pub async fn set_expires_in(&self, expires_in: i64) -> &Self

Sets the number of seconds in which the current access token should be considered expired

Source

pub async fn expires_in(&self) -> Option<Duration>

Gets the number of seconds from now in which the current access token will be considered expired if one is known

Source

pub async fn is_expired(&self) -> Option<bool>

Determines if the access token currently stored in the client is expired. If the expiration can not be determined, None is returned

Source

pub fn with_host_override<H>(&mut self, host: H) -> &mut Self
where H: ToString,

Override the host for all endpoins in the client.

Source

pub fn remove_host_override(&mut self) -> &mut Self

Disables the global host override for the client.

Source

pub fn get_host_override(&self) -> Option<&str>

Source

pub fn new_from_env<T, R>( token: T, refresh_token: R, server: impl Into<RootDefaultServers>, ) -> Self
where T: ToString, R: ToString,

Create a new Client struct from environment variables. Requires an existing access and refresh token.

The following environment variables are expected to be set:

  • GUSTO_CLIENT_ID
  • GUSTO_CLIENT_SECRET
  • GUSTO_REDIRECT_URI
§Panics

This function will panic if the expected environment variables can not be found

Return a user consent url with an optional set of scopes. If no scopes are provided, they will not be passed in the url.

Source

pub async fn refresh_access_token(&self) -> Result<AccessToken, ClientError>

Refresh an access token from a refresh token. Client must have a refresh token for this to work.

Source

pub async fn get_access_token( &mut self, code: &str, state: &str, ) -> Result<AccessToken, ClientError>

Get an access token from the code returned by the URL paramter sent to the redirect URL.

Source

pub fn current_user(&self) -> CurrentUser

Return a reference to an interface that provides access to Current User operations.

Source

pub fn companies(&self) -> Companies

Return a reference to an interface that provides access to Companies operations.

Source

pub fn employees(&self) -> Employees

Return a reference to an interface that provides access to Employees operations.

Source

pub fn contractors(&self) -> Contractors

Return a reference to an interface that provides access to Contractors operations.

Source

pub fn payroll(&self) -> Payroll

Return a reference to an interface that provides access to Payroll operations.

Source

pub fn contractor_payments(&self) -> ContractorPayments

Return a reference to an interface that provides access to Contractor Payments operations.

Source

pub fn company_bank_accounts_beta(&self) -> CompanyBankAccountsBeta

Return a reference to an interface that provides access to Company Bank Accounts (Beta) operations.

Source

pub fn benefits(&self) -> Benefits

Return a reference to an interface that provides access to Benefits operations.

Source

pub fn locations(&self) -> Locations

Return a reference to an interface that provides access to Locations operations.

Source

pub fn jobs(&self) -> Jobs

Return a reference to an interface that provides access to Jobs operations.

Source

pub fn job_applicants_beta(&self) -> JobApplicantsBeta

Return a reference to an interface that provides access to Job Applicants (Beta) operations.

Source

pub fn compensations(&self) -> Compensations

Return a reference to an interface that provides access to Compensations operations.

Source

pub fn pay_schedules(&self) -> PaySchedules

Return a reference to an interface that provides access to Pay Schedules operations.

Source

pub fn garnishments(&self) -> Garnishments

Return a reference to an interface that provides access to Garnishments operations.

Source

pub fn time_off_requests(&self) -> TimeOffRequests

Return a reference to an interface that provides access to Time Off Requests operations.

Source

pub fn earning_type(&self) -> EarningType

Return a reference to an interface that provides access to Earning Type operations.

Source

pub fn terminations(&self) -> Terminations

Return a reference to an interface that provides access to Terminations operations.

Source

pub fn custom_fields(&self) -> CustomFields

Return a reference to an interface that provides access to Custom Fields operations.

Source

pub fn admins_beta(&self) -> AdminsBeta

Return a reference to an interface that provides access to Admins (Beta) operations.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T