Client
- class freshbooks.client.Client(client_id, client_secret=None, redirect_uri=None, access_token=None, refresh_token=None, user_agent=None, timeout=30, auto_retry=True)
Bases:
object
- property bill_payments: freshbooks.api.accounting.AccountingResource
FreshBooks bill_payments resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property bill_vendors: freshbooks.api.accounting.AccountingResource
FreshBooks bill_vendors resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property bills: freshbooks.api.accounting.AccountingResource
FreshBooks bills resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property callbacks: freshbooks.api.events.EventsResource
FreshBooks callbacks (webhook callbacks) resource with calls to get, list, create, update, delete, resend_verification, verify
- Return type
:py:class:
~freshbooks.api.events.EventsResource
- property clients: freshbooks.api.accounting.AccountingResource
FreshBooks clients resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property credit_notes: freshbooks.api.accounting.AccountingResource
FreshBooks credit_notes resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- current_user()
The identity details of the currently authenticated user.
See FreshBooks API - Business, Roles, and Identity
- Return type
:py:class:
~freshbooks.models.Identity
- property estimates: freshbooks.api.accounting.AccountingResource
FreshBooks estimates resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property expenses: freshbooks.api.accounting.AccountingResource
FreshBooks expenses resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property expenses_categories: freshbooks.api.accounting.AccountingResource
FreshBooks expenses categories resource with calls to get and list
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property gateways: freshbooks.api.accounting.AccountingResource
FreshBooks gateways resource with calls to list, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- get_access_token(code)
Makes a call to the FreshBooks token URL to get an access_token.
This requires the access_grant code obtained after the user is redirected by the authorization step. See
freshbooks.client.Client.get_auth_request_url
.This call sets the
access_token
,refresh_token
, andaccess_token_expires_at
attributes on the Client instance and also returns those values in an object.Args: code: access_grant code from the authorization redirect
Returns: Simple namespace containing
access_token
,refresh_token
, andaccess_token_expires_at
Raises: FreshBooksError: If the call fails to return a access token. FreshBooksClientConfigError: If client_secret and redirect_uri are not set on the client instance.
- Return type
:py:class:
~types.SimpleNamespace
- get_auth_request_url(scopes=None)
Returns the url that a client needs to request an oauth grant from the server.
To get an oauth access token, send your user to this URL. The user will be prompted to log in to FreshBooks, after which they will be redirected to the
redirect_uri
set on the client with the access grant as a parameter. That grant can then be used to fetch an access token by callingget_access_token
.Note: The
redirect_uri
must be one of the URLs your application is registered for.If scopes are not specified, then the access token will be given the default scopes your application is registered for.
Args: scopes: List of scopes if your want an access token with only a subset of your registered scopes
Returns: The URL for the authorization request
Raises: FreshBooksClientConfigError: If redirect_uri is not set on the client instance.
- Return type
:py:class:
str
- property invoice_payment_options: freshbooks.api.payments.PaymentsResource
FreshBooks default payment options resource with calls to defaults, get, create
- Return type
:py:class:
~freshbooks.api.payments.PaymentsResource
- property invoice_profiles: freshbooks.api.accounting.AccountingResource
FreshBooks invoice_profiles resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property invoices: freshbooks.api.accounting.AccountingResource
FreshBooks invoices resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property items: freshbooks.api.accounting.AccountingResource
FreshBooks items resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property other_income: freshbooks.api.accounting.AccountingResource
FreshBooks other_incomes resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property payments: freshbooks.api.accounting.AccountingResource
FreshBooks payments resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property projects: freshbooks.api.projects.ProjectsResource
FreshBooks projects resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.projects.ProjectsResource
- refresh_access_token(refresh_token=None)
Makes a call to the FreshBooks token URL to refresh an access_token.
If
refresh_token
is provided, it will call to refresh it, otherwise it will use therefresh_token
on the Client instance.This call sets the
access_token
,refresh_token
, andaccess_token_expires_at
attributes on the Client instance to the new values from the refresh call, and also returns those values in an object.Args: refresh_token: (Optional) refresh_token from initial
get_access_token
callReturns: Simple namespace containing
access_token
,refresh_token
, andaccess_token_expires_at
Raises: FreshBooksClientConfigError: If refresh_token is not set on the client instance and is not provided.
- Return type
:py:class:
~types.SimpleNamespace
- property service_rates: freshbooks.api.comments.CommentsSubResource
FreshBooks service_rates resource with calls to get, list, create, update
- Return type
:py:class:
~freshbooks.api.comments.CommentsSubResource
- property services: freshbooks.api.comments.CommentsResource
FreshBooks services resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.comments.CommentsResource
- property staff: freshbooks.api.accounting.AccountingResource
FreshBooks staff resource with calls to get, list, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property systems: freshbooks.api.accounting.AccountingResource
FreshBooks systems resource with calls to get only
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property tasks: freshbooks.api.accounting.AccountingResource
FreshBooks tasks resource with calls to get, list, create, update, delete
Note: There is a lot of overlap between Services and Tasks. In general services are used to add categories of work to projects, and tasks are used to add billable work to invoices.
Creating a task should create the corresponding service and vice versa.
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property taxes: freshbooks.api.accounting.AccountingResource
FreshBooks taxes resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.accounting.AccountingResource
- property time_entries: freshbooks.api.timetracking.TimetrackingResource
FreshBooks time_entries resource with calls to get, list, create, update, delete
- Return type
:py:class:
~freshbooks.api.timetracking.TimetrackingResource
- freshbooks.client.DEFAULT_TIMEOUT = 30
Default request timeout to FreshBooks