Class Configuration.Builder

java.lang.Object
net.commuty.parking.Configuration.Builder
Enclosing class:
Configuration

public static class Configuration.Builder extends Object
Build a configuration object that will be used ton instantiate a Rest client.

To use this, call Configuration.Builder.create() then chain one or more builder methods.

The only required method is withCredentials(String, String).

  • Method Details

    • create

      public static Configuration.Builder create()
    • withCredentials

      public Configuration.Builder withCredentials(String username, String password)
      Set a username and password to authenticate against the API

      This was provided to you by Commuty.

      Parameters:
      username - The username Commuty provided to you.
      password - The password Commuty provided to you.
      Returns:
      this builder instance.
    • withHost

      public Configuration.Builder withHost(String host)

      Allow you to define a hostname that the client will use.

      If you do not call this method, the client will use the default production parking api of Commuty.

      Unless the Commuty Team tells you otherwise, you don't need to use this method.

      Parameters:
      host - a valid URL
      Returns:
      this builder instance.
    • withProxy

      public Configuration.Builder withProxy(Proxy proxy)

      Allow you to define a proxy (if it is required by your organisation).

      Pass a proxy instance to the method, i.e: new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8080));

      Parameters:
      proxy - a valid Proxy object.
      Returns:
      this builder instance.
    • withRetryStrategy

      public Configuration.Builder withRetryStrategy(int numberOfRetries, int intervalInMs)
      Set a retry strategy to make every call resilient of unexpected issues.
      Parameters:
      numberOfRetries - The number of calls that must be attempted every time the API is contacted. Must be positive.
      intervalInMs - The time to wait (in milliseconds) between each attempt. Must be positive.
      Returns:
      this builder instance.
    • withTimeout

      public Configuration.Builder withTimeout(int connectionTimeoutInMs, int requestTimeoutInMs)
      Set timeout values
      Parameters:
      connectionTimeoutInMs - The duration in milliseconds the client will wait during the connection phase of an HTTP Call to the API. Must be positive.
      requestTimeoutInMs - The maximum duration in milliseconds the client will wait for a response of a GET HTTP Call to the API. Must be positive.
      Returns:
      this builder instance.
    • build

      public Configuration build()
      Creates a Configuration instance.
      Returns:
      a new Configuration that will allow you to create a Rest client.
    • buildDefault

      public static Configuration buildDefault(String username, String password)

      Creates a new configuration instance using default values (default host and no proxy).

      In most cases, you will need only this method to create a Configuration object.

      Parameters:
      username - The username Commuty provided to you.
      password - The password Commuty provided to you.
      Returns:
      a new Configuration that will allow you to create a Rest client.