Class
PCUsersManager
public final class PCUsersManager
Creates and manages PCUser objects
Properties
Methods
importUser(from:)
public static func importUser(
from string: String
) throws -> PCUser
Creates the new user by importing the data from a string
Parameters
Name | Type | Description |
---|---|---|
string | String |
Should contain the user's data. Supports JSON, XML and Plain Text formats |
Returns
The new PCUser
object or nil if source is incorrect
activate(user:using:)
public static func activate(
user: PCUser,
using code: String
) throws
Activates a non-activated user using an activation code
If user is already activated nothing will happen.
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
User to be activated |
code | String |
Activation code |
Throws
PCError.invalidActivationCode
if the activation code is wrong
submit(password:for:)
public static func submit(
password: String,
for user: PCUser
) throws
Prepares the user for signing operations and changes the isReadyToSign
property to true
.
The user must be activated before submiting the password.
You can check the activation by reading the isActivated
property which must be true
.
Parameters
Name | Type | Description |
---|---|---|
password | String |
The user's password |
user | PCUser |
The user to be ready to sign |
Throws
PCError.invalidPassword
if the password is wrong
register(user:deviceToken:keysProcessor:targetQueue:completion:)
public static func register(
user: PCUser,
deviceToken: String?,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<Void, Error>) -> Void
)
Registers the user on the PayContol server
Registers public key, deviceToken for Push-notifications and the device's fingerprint
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
The user to be registered |
deviceToken | String? |
The device's token for PUSH-notifications |
keysProcessor | KeysProcessor? |
The keys processor where keypair will be generated |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after finishing registration |
result | Returns nothing when success. Otherwise, returns error |
registerExtAuthTemplate(_:user:targetQueue:completion:)
public static func registerExtAuthTemplate(
_ template: PCExtendedAuthTemplate,
user: PCUser,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<Void, Error>) -> Void)
Registers an extended authentication template for a user
Parameters
Name | Type | Description |
---|---|---|
template | PCExtendedAuthTemplate |
A template object |
user | PCUser |
The user to be registered a template for |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after finishing registration |
result | Returns nothing when success. Otherwise, returns error |
store(user:name:password:)
public static func store(
user: PCUser,
name: String? = nil,
password: String? = nil) throws
Stores the user in the storage
This method provides several possibilities:
-
Adding the new user. You must provide the imported user object, name and the password. If the
name
property is nil — the new name will be generated automatically by using thesystemName
property or by adding a suffix with a number. -
Updating the existing user's data. Provide either the new name or the new password, or both. Updating the password requires invoking
submitPassword
method before.
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
PCUser object to be stored |
name | String? |
User's name |
password | String? |
User's password |
Throws
Can throw PCError.internalError
if there are problems with CoreData or Keychain
delete(user:)
public static func delete(
user: PCUser) throws
Deletes the user in the storage
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
PCUser object to be deleted |
Throws
Can throw PCError.internalError
if there are problems with CoreData or Keychain
renew(user:keysProcessor:targetQueue:completion:)
public static func renew(
user: PCUser,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCUser, Error>) -> Void)
Renews user
Renewing the user requires invoking submitPassword
method before.
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
|
keysProcessor | KeysProcessor? |
The processor to sign renew operation |
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCUser, Error>) -> Void |
A closure to be invoked after renewing |
result | Returns instance of renewed |
getCertificateInfo(user:targetQueue:completion:)
public static func getCertificateInfo(
user: PCUser,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCCertificateInfo, Error>) -> Void)
Gets certificate info for the provided user
Parameters
Name | Type | Description |
---|---|---|
user | PCUser |
|
targetQueue | DispatchQueue |
The queue where a closure will be invoked on |
completion | @escaping (_ result: Result<PCCertificateInfo, Error>) -> Void |
A closure to be invoked after renewing |
result | Returns |