Package com.flagsmith

Class FlagsmithClient


  • public class FlagsmithClient
    extends Object
    A client for Flagsmith API.
    • Method Detail

      • updateEnvironment

        public void updateEnvironment()
        Load the environment flags in the environment variable from the API.
      • getIdentityFlags

        public Flags getIdentityFlags​(String identifier)
                               throws FlagsmithClientError
        Get all the flags for the current environment for a given identity. Will also upsert all traits to the Flagsmith API for future evaluations. Providing a trait with a value of None will remove the trait from the identity if it exists.
        Parameters:
        identifier - identifier string
        Returns:
        Throws:
        FlagsmithClientError
      • getIdentityFlags

        public Flags getIdentityFlags​(String identifier,
                                      Map<String,​Object> traits)
                               throws FlagsmithClientError
        Get all the flags for the current environment for a given identity. Will also upsert all traits to the Flagsmith API for future evaluations. Providing a trait with a value of None will remove the trait from the identity if it exists.
        Parameters:
        identifier - identifier string
        traits - list of key value traits
        Returns:
        Throws:
        FlagsmithClientError
      • getIdentitySegments

        public List<Segment> getIdentitySegments​(String identifier)
                                          throws FlagsmithClientError
        Get a list of segments that the given identity is in.
        Parameters:
        identifier - a unique identifier for the identity in the current environment, e.g. email address, username, uuid
        Returns:
        Throws:
        FlagsmithClientError
      • getIdentitySegments

        public List<Segment> getIdentitySegments​(String identifier,
                                                 Map<String,​Object> traits)
                                          throws FlagsmithClientError
        Get a list of segments that the given identity is in.
        Parameters:
        identifier - a unique identifier for the identity in the current environment, e.g. email address, username, uuid
        traits - a dictionary of traits to add / update on the identity in Flagsmith, e.g. {"num_orders": 10}
        Returns:
        Throws:
        FlagsmithClientError
      • close

        public void close()
        Should be called when terminating the client to clean up any resources that need cleaning up.
      • getCache

        public FlagsmithCache getCache()
        Returns a FlagsmithCache cache object that encapsulates methods to manipulate the cache.
        Returns:
        a FlagsmithCache if enabled, otherwise null.