Class FreshBooksClient.FreshBooksClientBuilder

java.lang.Object
net.amcintosh.freshbooks.FreshBooksClient.FreshBooksClientBuilder
Enclosing class:
FreshBooksClient

public static class FreshBooksClient.FreshBooksClientBuilder extends Object
Builder for FreshBooksClient.
  • Constructor Details

    • FreshBooksClientBuilder

      public FreshBooksClientBuilder(String clientId)
      Builder for FreshBooksClient. Requires a clientId, which will then allow you to provide an accessToken by appending the call to withAccessToken().
      Parameters:
      clientId - Your FreshBooks application client Id
    • FreshBooksClientBuilder

      public FreshBooksClientBuilder(String clientId, String clientSecret, String redirectUri)
      Builder for FreshBooksClient. Requires a clientId, clientSecret, and redirectUri which will allow you to follow the authentication flow to get an accessToken.
      Parameters:
      clientId - Your FreshBooks application client Id
      clientSecret - Your FreshBooks application client secret
      redirectUri - Where the user should be redirected to after authentication
  • Method Details

    • withAccessToken

      public FreshBooksClient.FreshBooksClientBuilder withAccessToken(String accessToken)
      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

      public FreshBooksClient.FreshBooksClientBuilder withUserAgent(String userAgent)
      Override the default user-agent header.
      Parameters:
      userAgent - String to pass for the user-agent header in requests.
      Returns:
      The builder instance
    • withConnectTimeout

      public FreshBooksClient.FreshBooksClientBuilder withConnectTimeout(int timeout)
      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

      public FreshBooksClient.FreshBooksClientBuilder withReadTimeout(int timeout)
      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

      public FreshBooksClient.FreshBooksClientBuilder withWriteTimeout(int timeout)
      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

      public FreshBooksClient build()
      Build the FreshBooksClient.
      Returns:
      A FreshBooksClient instance