Operations

The SDK allows you to work with available operations using CrypteriumOperationsStore class. Every user has its own list of operations. It depends on the restrictions applied in the application. Use this class to store and update available operations structure.

In this class, we have implemented several methods to access available opeartions:

  • The getSaved method returns the latest cached operations data.

  • The getRemote method reloads data from backend into cache and returns updated data.

See more details in the description of each method.

CrypteriumOperationsStore class

The CrypteriumOperationsStore class has been implemented for to work with available operations. To manage the process, initialize a CrypteriumOperationsStore object:

let operationsStore: CrypteriumOperationsStore = CrypteriumAPI.operationsStore()
operationsStore: ICrypteriumOperations = CrypteriumAPI.operationsStore()

Methods

getSaved

Use the getSaved method to get the latest cached operations data.

let operations: CRPTCustomerOperations? = operationsStore.getSaved()
operationsStore.getSaved(completion: (CRPTCustomerOperationsResult) -> Unit)
  
sealed class CRPTCustomerOperationsResult {
    data class success(val profile: CRPTCustomerOperations) : CRPTCustomerOperationsResult()
    data class failure(val error: CRPTError) : CRPTCustomerOperationsResult()
}

CRPTCustomerOperations

The CRPTCustomerOperations object is an array of CrypteriumOperationView (CRPTCustomerOperation Android) objects.

typealias CRPTCustomerOperations = [CrypteriumOperationView]
class CRPTCustomerOperations {
    var operations: List<CRPTCustomerOperation>? = null
}

CrypteriumOperationView

The CrypteriumOperationView (CRPTCustomerOperation Android) object is an object defining a single available operation.

struct CrypteriumOperationView {
  var name: String
  var constraint: Constraint
  var kycLevelPermissibleList: [FoundationElement<KycLevelPermissibleList>]?
}
class CRPTCustomerOperation  {
    var name: OperationName?, 
    var constraint: String?, 
    var kycLevelPermissibleList: ArrayList<KycLevel>?
}

getRemote

The getRemote method loads operations 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.

operationsStore.getRemote(completion: (CRPTCustomerOperationsResult) -> Void)

enum CRPTCustomerOperationsResult {
	case success(CRPTCustomerOperations)
	case failure(CRPTError)
}
operationsStore.getRemote(completion: (CRPTCustomerOperationsResult) -> Unit)
  
class CRPTCustomerOperations {
    var operations: List<CRPTCustomerOperation>? = null
}

CRPTCustomerOperationsResult

The CRPTCustomerOperationsResult object value is attached to success or failure case:

casecase typedescription
successCRPTCustomerOperationscustomer operations
failureCRPTErrorerror details

CRPTError

The type property of the CRPTError object may have one of the values below:

valueerror description
AUTHORIZATIONauthorization error
BACKENDbackend error