Class
PCTransactionsManager
public final class PCTransactionsManager
Creates and manages PCTransaction objects
Methods
importTransaction(from:)
public static func importTransaction(
from string: String
) throws -> PCTransaction
Makes the new PCTransaction object from the string
Parameters
| Name | Type | Description |
|---|---|---|
| string | String |
The source string which contains the transaction's data |
Returns
The new PCTransaction object or nil if the source is invalid
getTransactionList(for:targetQueue:completion:)
public static func getTransactionList(
for user: PCUser,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<[String], Error>) -> Void
)
Fetches all transactions identifiers for the provided user from the server
Parameters
| Name | Type | Description |
|---|---|---|
| user | PCUser |
The user which transactions should be fetched for |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<[String], Error>) -> Void |
A closure to be invoked after finishing the fetching process |
| result | Transactions identifiers or error |
getTransaction(for:user:targetQueue:completion:)
public static func getTransaction(
for transactionID: String,
user: PCUser,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCTransaction, Error>) -> Void
)
Fetches the transaction's data for the provided transactionID from the server.
The downloaded transaction may have a binary data. You can check availability of a binary data
using transaction.hasBinaryData property.
If transaction has binary data it must be downloaded before signing or declining.
Otherwise, the method PCTransactionManager.sign or .decline will return an error
(PCError.binaryDataIsRequired).
Parameters
| Name | Type | Description |
|---|---|---|
| transactionID | String |
Transaction's identifier which data sould be fetched for |
| user | PCUser |
User which transaction's data should be fetched for |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<PCTransaction, Error>) -> Void |
Closure to be invoked after finishing the fetching process |
| result | Returns |
getTransactionBinaryData(for:user:targetQueue:completion:)
public static func getTransactionBinaryData(
for transaction: PCTransaction,
user: PCUser,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCTransaction, Error>) -> Void
)
Gets the transaction's binary data from the server
Check transaction.hasBinaryData parameter before using this method
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
The transaction the binary data got for |
| user | PCUser |
User which transaction's binary data should be got for |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<PCTransaction, Error>) -> Void |
Closure to be invoked after finishing the process |
| result | Returns the new instance of |
sign(transactions:by:parameters:extendedAuthTemplate:keysProcessor:targetQueue:completion:)
public static func sign(
transactions: [PCTransaction],
by user: PCUser,
parameters: PCParameters? = nil,
extendedAuthTemplate: PCExtendedAuthTemplate? = nil,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<[PCResult], Error>) -> Void
)
Confirms multiple transactions
Be sure that you downloaded the binary data for every transaction befor invoking this method.
Otherwise, error PCError.binaryDataIsRequired will be returned.
Parameters
| Name | Type | Description |
|---|---|---|
| transactions | [PCTransaction] |
The transactions to be signed |
| user | PCUser |
The user to sign |
| parameters | PCParameters? |
An additional parameters, e.g. scoring settings |
| extendedAuthTemplate | PCExtendedAuthTemplate? |
Template for extended authentication |
| keysProcessor | KeysProcessor? |
The processor to sign transactions |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<[PCResult], Error>) -> Void |
A closure to be invoked after finishing the signing process |
| result | Returns array of results when success. Otherwise, returns error |
sign(transaction:by:parameters:extendedAuthTemplate:keysProcessor:targetQueue:completion:)
public static func sign(
transaction: PCTransaction,
by user: PCUser,
parameters: PCParameters? = nil,
extendedAuthTemplate: PCExtendedAuthTemplate? = nil,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<Void, Error>) -> Void
)
Confirms the single transaction
If transaction.hasBinaryData is true be sure that you downloaded the binary data
for this transaction before signing. Otherwise, this method will return an error
(PCError.binaryDataIsRequired).
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
The transaction to be signed |
| user | PCUser |
The user to sign |
| parameters | PCParameters? |
An additional parameters, e.g. scoring settings |
| extendedAuthTemplate | PCExtendedAuthTemplate? |
Template for extended authentication |
| keysProcessor | KeysProcessor? |
The processor to sign transactions |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<Void, Error>) -> Void |
A closure to be invoked after finishing the signing process |
| result | Returns nothing when success. Otherwise, returns error |
decline(transactions:by:keysProcessor:targetQueue:completion:)
public static func decline(
transactions: [PCTransaction],
by user: PCUser,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<[PCResult], Error>) -> Void
)
Declines the provided transactions
Be sure that you downloaded the binary data for every transaction befor invoking this method.
Otherwise, error PCError.binaryDataIsRequired will be returned.
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | Transaction to be declined |
|
| user | PCUser |
The user to decline |
| keysProcessor | KeysProcessor? |
The processor to decline transactions |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<[PCResult], Error>) -> Void |
A closure to be invoked after finishing the signing process |
| result | Returns array of results when success. Otherwise, returns error |
decline(transaction:by:keysProcessor:targetQueue:completion:)
public static func decline(
transaction: PCTransaction,
by user: PCUser,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<Void, Error>) -> Void
)
Declines the provided transaction
if transaction.hasBinaryData is true be sure that you downloaded the binary data
for this transaction before declining. Otherwise, this method will return an error
(PCError.binaryDataIsRequired).
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
Transaction to be declined |
| user | PCUser |
The user to decline |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<Void, Error>) -> Void |
Closure to be invoked after finishing the declining process |
| result | Returns nothing when success. Otherwise, returns error |
signOffline(transaction:by:keysProcessor:targetQueue:completion:)
public static func signOffline(
transaction: PCTransaction,
by user: PCUser,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCConfirmation, Error>) -> Void
)
Makes PCConfirmation object to confirm transaction in offline mode
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
Transaction to be signed |
| user | PCUser |
User whose transaction should be singed by |
| keysProcessor | KeysProcessor? |
The processor to sign transactions |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<PCConfirmation, Error>) -> Void |
Closure to be invoked after creation of |
| result | Returns an instance of |
declineOffline(transaction:by:keysProcessor:targetQueue:completion:)
public static func declineOffline(
transaction: PCTransaction,
by user: PCUser,
keysProcessor: KeysProcessor? = nil,
targetQueue: DispatchQueue = .main,
completion: @escaping (_ result: Result<PCDeclination, Error>) -> Void
)
Makes PCDeclination object to decline transaction in offline mode
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
Transaction to be declined |
| user | PCUser |
User whose transaction should be declined by |
| targetQueue | DispatchQueue |
The queue where a completion will be invoked on |
| completion | @escaping (_ result: Result<PCDeclination, Error>) -> Void |
Closure to be invoked after creation of |
| result | Returns an instance of |
signOffline(transaction:by:)
@available(*, deprecated, message: """
Use async method instead:
`public static func signOffline(
transaction: PCTransaction,
by user: PCUser,
keysProcessor: KeysProcessor?,
targetQueue: DispatchQueue,
completion: @escaping (_ result: Result<PCConfirmation, Error>) -> Void
)`
""")
public static func signOffline(
transaction: PCTransaction,
by user: PCUser
) throws -> PCConfirmation
Makes PCConfirmation object for confirming transaction in offline mode
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
Transaction to be signed |
| user | PCUser |
User whose transaction should be singed by |
Returns
PCConfirmation object which contains the signing data
declineOffline(transaction:by:)
@available(*, deprecated, message: """
Use async method instead:
`public static func declineOffline(
transaction: PCTransaction,
by user: PCUser,
keysProcessor: KeysProcessor?,
targetQueue: DispatchQueue,
completion: @escaping (_ result: Result<PCDeclination, Error>) -> Void
)`
""")
public static func declineOffline(
transaction: PCTransaction,
by user: PCUser
) throws -> PCDeclination
Makes PCDeclination object for declining in offline mode
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | PCTransaction |
Transaction to be declined |
| user | PCUser |
User whose transaction should be declined by |
Returns
PCDeclination object which contains the declining data