Package net.amcintosh.freshbooks
Class FreshBooksClient
java.lang.Object
net.amcintosh.freshbooks.FreshBooksClient
FreshBooks API client.
FreshBooksClient freshBooksClient = new FreshBooksClient.FreshBooksClientBuilder("your application id")
.withToken("a valid token")
.build();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for FreshBooksClient. -
Method Summary
Modifier and TypeMethodDescriptionclients()
FreshBooks clients resource with calls to get, list, create, update, delete.The identity details of the currently authenticated user.expenses()
FreshBooks expenses resource with calls to get, list, create, update, delete.getAccessToken
(String code) Makes a call to the FreshBooks token URL to get an access_token.Returns the url that a client needs to request an oauth grant from the server.getAuthRequestUri
(List<String> scopes) Returns the url that a client needs to request an oauth grant from the server.Get the freshbooks-sdk version.invoices()
FreshBooks invoices resource with calls to get, list, create, update, delete.items()
FreshBooks items resource with calls to get, list, create, update, delete.FreshBooks other income resource with calls to get, list, create, update, delete.payments()
FreshBooks payments resource with calls to get, list, create, update, delete.projects()
FreshBooks projects resource with calls to get, list, create, update, delete.Makes a call to the FreshBooks token URL to refresh an access_token.reports()
FreshBooks reports resource with calls the various reports available.com.google.api.client.http.HttpRequest
Make a request to FreshBooks.com.google.api.client.http.HttpRequest
Make a request to FreshBooks with a data payload.FreshBooks service rates resource with calls to get, list, create, update.services()
FreshBooks services resource with calls to get, list, create, update, delete.tasks()
FreshBooks tasks resource with calls to get, list, create, update, delete.taxes()
FreshBooks taxes resource with calls to get, list, create, update, delete.FreshBooks time entries resource with calls to get, list, create, update, delete.toString()
-
Method Details
-
getVersion
Get the freshbooks-sdk version.- Returns:
- the version number
-
toString
-
getAuthRequestUri
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 `redirectUri` set on the client with the access grant as a parameter. That grant can then be used to fetch an access token by calling `getAccessToken`.
If scopes are not specified, then the access token will be given the default scopes your application is registered for.
Note: The `redirectUri` must be one of the URLs your application is registered for.- Returns:
- The URL for the authorization request
- See Also:
-
getAuthRequestUri
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 `redirectUri` set on the client with the access grant as a parameter. That grant can then be used to fetch an access token by calling `getAccessToken`.
If scopes are not specified, then the access token will be given the default scopes your application is registered for.
Note: The `redirectUri` must be one of the URLs your application is registered for.- Parameters:
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
- See Also:
-
getAccessToken
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. SeegetAuthRequestUri()
.
This call sets the authorization token details on the FreshBooksClient instance and then returns those values in anAuthorizationToken
.- Parameters:
code
- access_grant code from the authorization redirect- Returns:
- Throws:
FreshBooksException
-
refreshAccessToken
Makes a call to the FreshBooks token URL to refresh an access_token.
This requires the AuthorizationToken on the client to have a valid refreshToken
This call sets the authorization token details on the FreshBooksClient instance and then returns those values in anAuthorizationToken
.- Returns:
- Throws:
FreshBooksException
-
request
public com.google.api.client.http.HttpRequest request(String requestMethod, String resourceUrl) throws IOException Make a request to FreshBooks.- Parameters:
requestMethod
- GET, POST, PUT, DELETEresourceUrl
- Relative URL (eg./accounting/account/{accountId}/users/clients
)- Returns:
- HttpRequest object
- Throws:
IOException
-
request
public com.google.api.client.http.HttpRequest request(String requestMethod, String resourceUrl, @Nullable Map<String, Object> data) throws IOExceptionMake a request to FreshBooks with a data payload.- Parameters:
requestMethod
- GET, POST, PUT, DELETEresourceUrl
- Relative URL (eg./accounting/account/{accountId}/users/clients
)data
-- Returns:
- HttpRequest object
- Throws:
IOException
-
currentUser
The identity details of the currently authenticated user.- Throws:
FreshBooksException
- See Also:
-
clients
FreshBooks clients resource with calls to get, list, create, update, delete.- Returns:
- Clients resource initialized with this FreshBooksClient
-
expenses
FreshBooks expenses resource with calls to get, list, create, update, delete.- Returns:
- Expenses resource initialized with this FreshBooksClient
-
invoices
FreshBooks invoices resource with calls to get, list, create, update, delete.- Returns:
- Invoices resource initialized with this FreshBooksClient
-
items
FreshBooks items resource with calls to get, list, create, update, delete.- Returns:
- Items resource initialized with this FreshBooksClient
-
otherIncomes
FreshBooks other income resource with calls to get, list, create, update, delete.- Returns:
- OtherIncomes resource initialized with this FreshBooksClient
-
payments
FreshBooks payments resource with calls to get, list, create, update, delete.- Returns:
- Payments resource initialized with this FreshBooksClient
-
projects
FreshBooks projects resource with calls to get, list, create, update, delete.- Returns:
- Projects resource initialized with this FreshBooksClient
-
reports
FreshBooks reports resource with calls the various reports available.
Eg.freshbooksClient.reports.profitAndLoss(accountId)
- Returns:
- Reports resource initialized with this FreshBooksClient
-
services
FreshBooks services resource with calls to get, list, create, update, delete.- Returns:
- Services resource initialized with this FreshBooksClient
-
serviceRates
FreshBooks service rates resource with calls to get, list, create, update.- Returns:
- ServiceRates resource initialized with this FreshBooksClient
-
tasks
FreshBooks tasks resource with calls to get, list, create, update, delete.- Returns:
- Tasks resource initialized with this FreshBooksClient
-
taxes
FreshBooks taxes resource with calls to get, list, create, update, delete.- Returns:
- Taxes resource initialized with this FreshBooksClient
-
timeEntries
FreshBooks time entries resource with calls to get, list, create, update, delete.- Returns:
- TimeEntries resource initialized with this FreshBooksClient
-