Package com.mparticle.identity
Class IdentityApi
- java.lang.Object
-
- com.mparticle.identity.IdentityApi
-
public class IdentityApi extends java.lang.Object
Helper class that is used to access Identity endpoints to manage User's Attributes and Identities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IdentityApi.MpIdChangeListener
-
Field Summary
Fields Modifier and Type Field Description static int
BAD_REQUEST
static int
SERVER_ERROR
static int
THROTTLE_ERROR
static int
UNKNOWN_ERROR
-
Constructor Summary
Constructors Modifier Constructor Description protected
IdentityApi()
IdentityApi(android.content.Context context, com.mparticle.internal.AppStateManager appStateManager, com.mparticle.internal.MessageManager messageManager, com.mparticle.internal.ConfigManager configManager, com.mparticle.internal.KitManager kitManager, MParticle.OperatingSystem operatingSystem)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIdentityStateListener(IdentityStateListener listener)
Adds a global listener which will be invoked when the MPID or "logged in" status changes for the current user.boolean
aliasUsers(AliasRequest aliasRequest)
Initiate an Alias request.MParticleUser
getCurrentUser()
return the MParticleUser with the current MPID, even if an Identity request, which might cause the MPID to change, is currently in progress.java.lang.String
getDeviceApplicationStamp()
MParticleUser
getUser(java.lang.Long mpid)
Return the MParticleUser with the specified MPID, if it exists.java.util.List<MParticleUser>
getUsers()
returns a list ofMParticleUser
s that have been seen by this device.MParticleTask<IdentityApiResult>
identify(IdentityApiRequest identifyRequest)
Calls the Identity Identify endpoint.IdentityApi.Internal
Internal()
MParticleTask<IdentityApiResult>
login()
Calls the Identity Login endpoint with an empty IdentityApiRequest.MParticleTask<IdentityApiResult>
login(IdentityApiRequest loginRequest)
Calls the Identity Login endpoint.MParticleTask<IdentityApiResult>
logout()
Calls the Identity Logout endpoint with an empty IdentityApiRequest.MParticleTask<IdentityApiResult>
logout(IdentityApiRequest logoutRequest)
BaseIdentityTask
modify(IdentityApiRequest updateRequest)
Calls the Identity Modify endpoint.void
removeIdentityStateListener(IdentityStateListener listener)
Removes an instance of a global listener by reference.
-
-
-
Constructor Detail
-
IdentityApi
protected IdentityApi()
-
IdentityApi
public IdentityApi(android.content.Context context, com.mparticle.internal.AppStateManager appStateManager, com.mparticle.internal.MessageManager messageManager, com.mparticle.internal.ConfigManager configManager, com.mparticle.internal.KitManager kitManager, MParticle.OperatingSystem operatingSystem)
-
-
Method Detail
-
getCurrentUser
@Nullable public MParticleUser getCurrentUser()
return the MParticleUser with the current MPID, even if an Identity request, which might cause the MPID to change, is currently in progress.- See Also:
IdentityStateListener
-
getUser
@Nullable public MParticleUser getUser(@NonNull java.lang.Long mpid)
Return the MParticleUser with the specified MPID, if it exists. If an MParticleUser with the specified MPID does not exist, or the specifid MPID is 0, this will return null.- Parameters:
mpid
- the desired MParticleUser's MPID
-
getUsers
@NonNull public java.util.List<MParticleUser> getUsers()
returns a list ofMParticleUser
s that have been seen by this device. The collection is ordered byMParticleUser.getLastSeenTime()
, from most to least recent- Returns:
- a collection of
MParticleUser
ordered by descendingMParticleUser.getLastSeenTime()
-
getDeviceApplicationStamp
@NonNull public java.lang.String getDeviceApplicationStamp()
-
addIdentityStateListener
public void addIdentityStateListener(@NonNull IdentityStateListener listener)
Adds a global listener which will be invoked when the MPID or "logged in" status changes for the current user.- Parameters:
listener
- callback for Identity State changes- See Also:
IdentityStateListener
-
removeIdentityStateListener
public void removeIdentityStateListener(@NonNull IdentityStateListener listener)
Removes an instance of a global listener by reference.- Parameters:
listener
- callback for Identity State changes- See Also:
IdentityStateListener
-
logout
@NonNull public MParticleTask<IdentityApiResult> logout()
Calls the Identity Logout endpoint with an empty IdentityApiRequest.- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
and
,IdentityApiResult
-
logout
@NonNull public MParticleTask<IdentityApiResult> logout(@Nullable IdentityApiRequest logoutRequest)
- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
calls the Identity Logout endpoint
,and
,IdentityApiResult
-
login
@NonNull public MParticleTask<IdentityApiResult> login()
Calls the Identity Login endpoint with an empty IdentityApiRequest.- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
and
,IdentityApiResult
-
login
@NonNull public MParticleTask<IdentityApiResult> login(@Nullable IdentityApiRequest loginRequest)
Calls the Identity Login endpoint.- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
IdentityApiRequest
,and
,IdentityApiResult
-
identify
@NonNull public MParticleTask<IdentityApiResult> identify(@Nullable IdentityApiRequest identifyRequest)
Calls the Identity Identify endpoint.- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
IdentityApiRequest
,and
,IdentityApiResult
-
modify
@NonNull public BaseIdentityTask modify(@NonNull IdentityApiRequest updateRequest)
Calls the Identity Modify endpoint. This should be used in place of the pre-version-5 MParticle.setUserAttribute() and MParticle.setUserIdentity() methods.- Returns:
- an MParticleTask
to handle the Asynchronous results - See Also:
IdentityApiRequest
,BaseIdentityTask
-
aliasUsers
public boolean aliasUsers(@NonNull AliasRequest aliasRequest)
Initiate an Alias request. Retries are handled internally, so one anAliasRequest
is submitted, it will be retried unless there are unrecoverable errors. To listen for updates submit an implementation ofSdkListener
toMParticle.addListener(Context, SdkListener)
- Parameters:
aliasRequest
-- Returns:
-
Internal
@NonNull public IdentityApi.Internal Internal()
-
-