User profile
The SDK allows you to work with a user profile using CrypteriumProfileStore class.  
In this class, we have implemented the methods to access user profile data:
- 
The getSavedmethod returns the latest cached profile data.
- 
The getRemotemethod reloads data from backend into cache and returns updated data.
See more details in the description of each method.
CrypteriumProfileStore class
The CrypteriumProfileStore class has been implemented to work with a user profile. To manage the process, initialize a CrypteriumProfileStore object:
let profileStore: CrypteriumProfileStore = CrypteriumAPI.profileStore()
profile: ICrypteriumProfile = CrypteriumAPI.profileStore()
Methods
getSaved
Use the getSaved method to get the latest cached profile data. For Android, The method calls a completion closure and puts an object of the CRPTCustomerProfileResult type as an argument of the closure. 
let profileData: CRPTCustomerProfile? = profileStore.getSaved()
profile.getSaved(completion: (CRPTCustomerProfileResult) -> Unit)
  
sealed class CRPTCustomerProfileResult {
    data class success(val profile: CRPTCustomerProfile) : CRPTCustomerProfileResult()
    data class failure(val error: CRPTError) : CRPTCustomerProfileResult()
}
CRPTCustomerProfile (iOS)
The profileData is a constant of CRPTCustomerProfile type. It contains user's profile data. If the profileData is equal to nill, the SDK has not been authenticated. 
CRPTCustomerProfileResult (Android)
The CRPTCustomerProfileResult object value is attached to success or failure case:
| case | variable | type | description | 
|---|---|---|---|
| success | profile | CRPTCustomerProfile | customer profile | 
| failure | error | CRPTError | error details | 
CRPTError
The type property of the CRPTError object may have one of the values below:
| value | error description | 
|---|---|
| AUTHORIZATION | authorization error | 
| BACKEND | backend error | 
getRemote
The getRemote method  reloads data from backend into cache and returns an updated data. If an error occurs while fetching data, the cache will not get updated. The method calls a completion closure and puts an object of the CRPTCustomerProfileResult type as an argument of the closure.
profileStore.getRemote(completion: (CRPTCustomerProfileResult) -> Void)
enum CRPTCustomerProfileResult {
	case success(CRPTCustomerProfile)
	case failure(CRPTError)
}
profile.getRemote(completion: (CRPTCustomerProfileResult) -> Unit)
  
sealed class CRPTCustomerProfileResult {
    data class success(val profile: CRPTCustomerProfile) : CRPTCustomerProfileResult()
    data class failure(val error: CRPTError : CRPTCustomerProfileResult()
}
CRPTCustomerProfileResult
The CRPTCustomerProfileResult object value is attached to success or failure case:
| case | variable | type | description | 
|---|---|---|---|
| success | profile | CRPTCustomerProfile | customer profile | 
| failure | error | CRPTError | error details | 
CRPTError
The type property of the CRPTError object may have one of the values below:
| value | error description | 
|---|---|
| AUTHORIZATION | authorization error | 
| BACKEND | backend error | 
Updated over 3 years ago
