Class
PCTransactionsManager
public 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(transaction:by:parameters:targetQueue:completion:)
public static func sign(transaction: PCTransaction, by user: PCUser, parameters: PCParameters? = nil, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)
Confirms the provided transaction and attaches scoring parameters to the request
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 |
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(transaction:by:targetQueue:completion:)
public static func decline(transaction: PCTransaction, by user: PCUser, 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:)
public static func signOffline(transaction: PCTransaction, by user: PCUser) throws -> PCConfirmation
Makes PCConfirmation
object for signing 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:)
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