Package com.flagsmith
Class FlagsmithClient
- java.lang.Object
-
- com.flagsmith.FlagsmithClient
-
public class FlagsmithClient extends Object
A client for Flagsmith API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFlagsmithClient.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Should be called when terminating the client to clean up any resources that need cleaning up.FlagsmithCachegetCache()Returns a FlagsmithCache cache object that encapsulates methods to manipulate the cache.FlagsgetEnvironmentFlags()Get all the default for flags for the current environment.FlagsgetIdentityFlags(String identifier)Get all the flags for the current environment for a given identity.FlagsgetIdentityFlags(String identifier, Map<String,Object> traits)Get all the flags for the current environment for a given identity.List<Segment>getIdentitySegments(String identifier)Get a list of segments that the given identity is in.List<Segment>getIdentitySegments(String identifier, Map<String,Object> traits)Get a list of segments that the given identity is in.static FlagsmithClient.BuildernewBuilder()voidupdateEnvironment()Load the environment flags in the environment variable from the API.
-
-
-
Method Detail
-
newBuilder
public static FlagsmithClient.Builder newBuilder()
-
updateEnvironment
public void updateEnvironment()
Load the environment flags in the environment variable from the API.
-
getEnvironmentFlags
public Flags getEnvironmentFlags() throws FlagsmithApiError
Get all the default for flags for the current environment.- Returns:
- Throws:
FlagsmithApiError
-
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 stringtraits- 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, uuidtraits- 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.
-
-