Class ConnectionBuilder<T extends OptionsBuilder<T>>

java.lang.Object
it.auties.whatsapp.api.ConnectionBuilder<T>
Type Parameters:
T - the type of the newsletters

public final class ConnectionBuilder<T extends OptionsBuilder<T>> extends Object
A builder to specify the type of connection to use
  • Field Details

  • Constructor Details

    • ConnectionBuilder

      ConnectionBuilder(ClientType clientType)
  • Method Details

    • serializer

      public ConnectionBuilder<T> serializer(ControllerSerializer serializer)
      Uses a custom serializer
      Parameters:
      serializer - the non-null serializer to use
      Returns:
      the same instance for chaining
    • newConnection

      public T newConnection()
      Creates a new connection using a random uuid
      Returns:
      a non-null options selector
    • newConnection

      public T newConnection(UUID uuid)
      Creates a new connection using a unique identifier If a session with the given id already whatsappOldEligible, it will be retrieved. Otherwise, a new one will be created.
      Parameters:
      uuid - the nullable uuid to use to create the connection
      Returns:
      a non-null options selector
    • newConnection

      public T newConnection(long phoneNumber)
      Creates a new connection using a phone number If a session with the given phone number already whatsappOldEligible, it will be retrieved. Otherwise, a new one will be created.
      Parameters:
      phoneNumber - the nullable uuid to use to create the connection
      Returns:
      a non-null options selector
    • newConnection

      public T newConnection(String alias)
      Creates a new connection using an alias If a session with the given alias already whatsappOldEligible, it will be retrieved. Otherwise, a new one will be created.
      Parameters:
      alias - the nullable alias to use to create the connection
      Returns:
      a non-null options selector
    • newConnection

      public T newConnection(SixPartsKeys sixParts)
      Creates a new connection using a six parts key representation
      Parameters:
      sixParts - the non-null six parts to use to create the connection
      Returns:
      a non-null options selector
    • firstConnection

      public T firstConnection()
      Creates a new connection from the first connection that was serialized If no connection is available, a new one will be created
      Returns:
      a non-null options selector
    • lastConnection

      public T lastConnection()
      Creates a new connection from the last connection that was serialized If no connection is available, a new one will be created
      Returns:
      a non-null options selector
    • newOptionalConnection

      public Optional<T> newOptionalConnection(UUID uuid)
      Creates a new connection from the last connection that was serialized If no connection is available, an empty optional will be returned
      Returns:
      a non-null options selector
    • newOptionalConnection

      public Optional<T> newOptionalConnection(Long phoneNumber)
      Creates a new connection from the last connection that was serialized If no connection is available, an empty optional will be returned
      Returns:
      a non-null options selector
    • newOptionalConnection

      public Optional<T> newOptionalConnection(String alias)
      Creates a new connection using an alias If no connection is available, an empty optional will be returned
      Parameters:
      alias - the nullable alias to use to create the connection
      Returns:
      a non-null options selector
    • firstOptionalConnection

      public Optional<T> firstOptionalConnection()
      Creates a new connection from the first connection that was serialized
      Returns:
      an optional
    • lastOptionalConnection

      public Optional<T> lastOptionalConnection()
      Creates a new connection from the last connection that was serialized
      Returns:
      an optional
    • createConnection

      private T createConnection(StoreKeysPair sessionStoreAndKeys)