pub struct Client { /* private fields */ }
Expand description
Entrypoint for interacting with the API client.
Implementations§
Source§impl Client
impl Client
Sourcepub 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
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
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
Sourcepub fn set_auto_access_token_refresh(&mut self, enabled: bool) -> &mut Self
pub fn set_auto_access_token_refresh(&mut self, enabled: bool) -> &mut Self
Enables or disables the automatic refreshing of access tokens upon expiration
Sourcepub async fn set_expires_at(&self, expires_at: Option<Instant>) -> &Self
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.
Sourcepub async fn expires_at(&self) -> Option<Instant>
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
Sourcepub async fn set_expires_in(&self, expires_in: i64) -> &Self
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
Sourcepub async fn expires_in(&self) -> Option<Duration>
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
Sourcepub async fn is_expired(&self) -> Option<bool>
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
Sourcepub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere
H: ToString,
pub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere
H: ToString,
Override the host for all endpoins in the client.
Sourcepub fn remove_host_override(&mut self) -> &mut Self
pub fn remove_host_override(&mut self) -> &mut Self
Disables the global host override for the client.
pub fn get_host_override(&self) -> Option<&str>
Sourcepub fn new_from_env<T, R>(
token: T,
refresh_token: R,
server: impl Into<RootDefaultServers>,
) -> Self
pub fn new_from_env<T, R>( token: T, refresh_token: R, server: impl Into<RootDefaultServers>, ) -> Self
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
Sourcepub fn user_consent_url(&self, scopes: &[String]) -> String
pub fn user_consent_url(&self, scopes: &[String]) -> String
Return a user consent url with an optional set of scopes. If no scopes are provided, they will not be passed in the url.
Sourcepub async fn refresh_access_token(&self) -> Result<AccessToken, ClientError>
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.
Sourcepub async fn get_access_token(
&mut self,
code: &str,
state: &str,
) -> Result<AccessToken, ClientError>
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.
Sourcepub fn current_user(&self) -> CurrentUser
pub fn current_user(&self) -> CurrentUser
Return a reference to an interface that provides access to Current User operations.
Sourcepub fn companies(&self) -> Companies
pub fn companies(&self) -> Companies
Return a reference to an interface that provides access to Companies operations.
Sourcepub fn employees(&self) -> Employees
pub fn employees(&self) -> Employees
Return a reference to an interface that provides access to Employees operations.
Sourcepub fn contractors(&self) -> Contractors
pub fn contractors(&self) -> Contractors
Return a reference to an interface that provides access to Contractors operations.
Sourcepub fn payroll(&self) -> Payroll
pub fn payroll(&self) -> Payroll
Return a reference to an interface that provides access to Payroll operations.
Sourcepub fn contractor_payments(&self) -> ContractorPayments
pub fn contractor_payments(&self) -> ContractorPayments
Return a reference to an interface that provides access to Contractor Payments operations.
Sourcepub fn company_bank_accounts_beta(&self) -> CompanyBankAccountsBeta
pub fn company_bank_accounts_beta(&self) -> CompanyBankAccountsBeta
Return a reference to an interface that provides access to Company Bank Accounts (Beta) operations.
Sourcepub fn benefits(&self) -> Benefits
pub fn benefits(&self) -> Benefits
Return a reference to an interface that provides access to Benefits operations.
Sourcepub fn locations(&self) -> Locations
pub fn locations(&self) -> Locations
Return a reference to an interface that provides access to Locations operations.
Sourcepub fn jobs(&self) -> Jobs
pub fn jobs(&self) -> Jobs
Return a reference to an interface that provides access to Jobs operations.
Sourcepub fn job_applicants_beta(&self) -> JobApplicantsBeta
pub fn job_applicants_beta(&self) -> JobApplicantsBeta
Return a reference to an interface that provides access to Job Applicants (Beta) operations.
Sourcepub fn compensations(&self) -> Compensations
pub fn compensations(&self) -> Compensations
Return a reference to an interface that provides access to Compensations operations.
Sourcepub fn pay_schedules(&self) -> PaySchedules
pub fn pay_schedules(&self) -> PaySchedules
Return a reference to an interface that provides access to Pay Schedules operations.
Sourcepub fn garnishments(&self) -> Garnishments
pub fn garnishments(&self) -> Garnishments
Return a reference to an interface that provides access to Garnishments operations.
Sourcepub fn time_off_requests(&self) -> TimeOffRequests
pub fn time_off_requests(&self) -> TimeOffRequests
Return a reference to an interface that provides access to Time Off Requests operations.
Sourcepub fn earning_type(&self) -> EarningType
pub fn earning_type(&self) -> EarningType
Return a reference to an interface that provides access to Earning Type operations.
Sourcepub fn terminations(&self) -> Terminations
pub fn terminations(&self) -> Terminations
Return a reference to an interface that provides access to Terminations operations.
Sourcepub fn custom_fields(&self) -> CustomFields
pub fn custom_fields(&self) -> CustomFields
Return a reference to an interface that provides access to Custom Fields operations.
Sourcepub fn admins_beta(&self) -> AdminsBeta
pub fn admins_beta(&self) -> AdminsBeta
Return a reference to an interface that provides access to Admins (Beta) operations.