Package net.amcintosh.freshbooks
Class FreshBooksClient.FreshBooksClientBuilder
java.lang.Object
net.amcintosh.freshbooks.FreshBooksClient.FreshBooksClientBuilder
- Enclosing class:
- FreshBooksClient
Builder for FreshBooksClient.
-
Constructor Summary
ConstructorDescriptionFreshBooksClientBuilder
(String clientId) Builder for FreshBooksClient.FreshBooksClientBuilder
(String clientId, String clientSecret, String redirectUri) Builder for FreshBooksClient. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the FreshBooksClient.withAccessToken
(String accessToken) Initialize the client with an access token.withAuthorizationToken
(AuthorizationToken authorizationToken) Initialize the client with a authorization token object containing an valid access token, refresh token, and expiration details.withConnectTimeout
(int timeout) Set the timeout in milliseconds to establish a connection (0 for infinite).Disables automatic retries on a 429 or 5xx response code.withReadTimeout
(int timeout) Set the timeout in milliseconds to read data from a connection (0 for infinite).withUserAgent
(String userAgent) Override the default user-agent header.withWriteTimeout
(int timeout) Set the timeout in milliseconds to send POST/PUT data (0 for infinite).
-
Constructor Details
-
FreshBooksClientBuilder
Builder for FreshBooksClient. Requires aclientId
, which will then allow you to provide anaccessToken
by appending the call towithAccessToken()
.- Parameters:
clientId
- Your FreshBooks application client Id
-
FreshBooksClientBuilder
Builder for FreshBooksClient. Requires aclientId
,clientSecret
, andredirectUri
which will allow you to follow the authentication flow to get anaccessToken
.- Parameters:
clientId
- Your FreshBooks application client IdclientSecret
- Your FreshBooks application client secretredirectUri
- Where the user should be redirected to after authentication
-
-
Method Details
-
withAccessToken
Initialize the client with an access token.- Parameters:
accessToken
- A existing valid OAuth2 access token- Returns:
- The builder instance
-
withAuthorizationToken
public FreshBooksClient.FreshBooksClientBuilder withAuthorizationToken(AuthorizationToken authorizationToken) Initialize the client with a authorization token object containing an valid access token, refresh token, and expiration details.- Parameters:
authorizationToken
- An AuthorizationToken with existing valid OAuth2 tokens- Returns:
- The builder instance
-
withUserAgent
Override the default user-agent header.- Parameters:
userAgent
- String to pass for the user-agent header in requests.- Returns:
- The builder instance
-
withConnectTimeout
Set the timeout in milliseconds to establish a connection (0 for infinite). Defaults to 20000.- Parameters:
timeout
- Connect timeout in milliseconds- Returns:
- The builder instance
-
withReadTimeout
Set the timeout in milliseconds to read data from a connection (0 for infinite). Defaults to 20000.- Parameters:
timeout
- Read timeout in milliseconds- Returns:
- The builder instance
-
withoutRetries
Disables automatic retries on a 429 or 5xx response code.- Returns:
- The builder instance
-
withWriteTimeout
Set the timeout in milliseconds to send POST/PUT data (0 for infinite). Defaults to 60000.- Parameters:
timeout
- Write timeout in milliseconds- Returns:
- The builder instance
-
build
Build the FreshBooksClient.- Returns:
- A FreshBooksClient instance
-