Class User


  • public class User
    extends java.lang.Object
    Object representing the current user.
    • Constructor Summary

      Constructors 
      Constructor Description
      User()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMetadata​(java.util.Map<java.lang.String,​java.lang.Object> metadata)
      Adds custom metadata to the user.
      static User getCurrentUser()
      Returns the object representing the current user.
      java.lang.String getEmail()
      String representing the user's email
      java.lang.String getExternalId()
      String representing the user's externalId.
      java.lang.String getFirstName()
      String representing the user's first name
      java.lang.String getLastName()
      String representing the user's last name
      java.util.Map<java.lang.String,​java.lang.Object> getMetadata()
      Map representing the user's custom metadata
      java.util.Date getSignedUpAt()
      Date representing the date the user signed up
      java.lang.String getUserId()
      The assigned userId for this user.
      boolean hasPaymentInfo()
      Boolean describing whether or not the user has payment information stored
      void setEmail​(java.lang.String email)
      The user's email, to be used to display a gravatar.
      void setFirstName​(java.lang.String firstName)
      The user's first name, to be used as part of the display name when sending messages.
      void setLastName​(java.lang.String lastName)
      The user's last name, to be used as part of the display name when sending messages.
      void setSignedUpAt​(java.util.Date signedUpAt)
      The date the user started using your service
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • User

        public User()
    • Method Detail

      • getCurrentUser

        public static User getCurrentUser()
        Returns the object representing the current user.
        Returns:
        The current user
      • setEmail

        public void setEmail​(java.lang.String email)
        The user's email, to be used to display a gravatar.
        Parameters:
        email - The email
      • setFirstName

        public void setFirstName​(java.lang.String firstName)
        The user's first name, to be used as part of the display name when sending messages.
        Parameters:
        firstName - The first name
      • setLastName

        public void setLastName​(java.lang.String lastName)
        The user's last name, to be used as part of the display name when sending messages.
        Parameters:
        lastName - The last name
      • setSignedUpAt

        public void setSignedUpAt​(java.util.Date signedUpAt)
        The date the user started using your service
        Parameters:
        signedUpAt - The sign up date
      • addMetadata

        public void addMetadata​(java.util.Map<java.lang.String,​java.lang.Object> metadata)
        Adds custom metadata to the user. This info is used to provide more context around who a user is.

        Values must be of type String, Integer, Long, Float, Double, or Date; any other type will be converted to String using the toString() method.

        Changes to user metadata are uploaded in batches at regular intervals, when the app is sent to the background, or when a message is sent. This API is additive, and subsequent calls will override values for the provided keys.

        Parameters:
        metadata - Map of metadata
      • getEmail

        public java.lang.String getEmail()
        String representing the user's email
        Returns:
        The user's email
      • getFirstName

        public java.lang.String getFirstName()
        String representing the user's first name
        Returns:
        The user's first name
      • getLastName

        public java.lang.String getLastName()
        String representing the user's last name
        Returns:
        The user's last name
      • getSignedUpAt

        public java.util.Date getSignedUpAt()
        Date representing the date the user signed up
        Returns:
        The date the user signed up
      • getMetadata

        public java.util.Map<java.lang.String,​java.lang.Object> getMetadata()
        Map representing the user's custom metadata
        Returns:
        The user's custom metadata
      • getExternalId

        public java.lang.String getExternalId()
        String representing the user's externalId. This property is set by calling Smooch.login(String, String, SmoochCallback).

        Unlike userId, this value is assigned and managed by the developer, and is used to identify a user across devices and app installations.

        Returns:
        The user's externalId
      • getUserId

        public java.lang.String getUserId()
        The assigned userId for this user.

        Unlike getExternalId(), this property is set automatically by Smooch, and is not configurable. This is analogous to appUser._id in the REST API response. A user is assigned an userId once they start a conversation or when an existing user is logged in by calling Smooch.login(String, String, SmoochCallback).

        Returns:
        The user's userId
      • hasPaymentInfo

        public boolean hasPaymentInfo()
        Boolean describing whether or not the user has payment information stored
        Returns:
        Boolean indicating whether or not the User has payment info stored