SudoVirtualCardsClient
public protocol SudoVirtualCardsClient : AnyObject
Client used to interface with the Sudo Payment Platform service.
It is recommended to code to this interface, rather than the implementation class (DefaultSudoVirtualCardsClient
) as
the implementation class is only meant to be used for initializing an instance of the client.
-
Removes all keys associated with this client, resets any cached data, cleans up subscriptions, and purges any pending operations.
It is important to note that this will clear ALL cached data related to all sudo services.
Declaration
Swift
func reset() throws
-
createKeysIfAbsent()
AsynchronousCreate key pair and secret key for use by the Virtual Cards Client if they have not already been created.
The key pair is used to register a public key with the service for the encryption of virtual card and transaction details.
The secret key is used for client side encryption of user specific card metadata.
Declaration
Swift
func createKeysIfAbsent() async throws -> CreateKeysIfAbsentResult
-
setupFundingSource(withInput:
Asynchronous) Setup a funding source.
Declaration
Swift
func setupFundingSource(withInput input: SetupFundingSourceInput) async throws -> ProvisionalFundingSource
Parameters
input
Funding Source input information.
Return Value
- Success: The provisional Funding Source.
- Failure:
- InsufficientEntitlements.
- VelocityExceeded.
-
completeFundingSource(withInput:
Asynchronous) Complete a provisional funding source.
Declaration
Swift
func completeFundingSource(withInput input: CompleteFundingSourceInput) async throws -> FundingSource
Parameters
input
Parameters used to complete the funding source.
Return Value
- Success: The provisioned Funding Source.
- Failure:
- DuplicateFundingSource.
- FundingSourceCompletionDataInvalid.
- IdentityNotVerified.
- ProvisionalFundingSourceNotFound.
- UnacceptableFundingSource.
-
provisionVirtualCard(withInput:
Asynchronousobserver: ) Provision a virtual card.
Declaration
Swift
func provisionVirtualCard(withInput input: ProvisionVirtualCardInput, observer: ProvisionVirtualCardObservable?) async throws -> ProvisionalCardState
Return Value
- Success: A newly provisioned card information is returned.
- Failure:
- SudoPlatformError.
- SudoVirtualCardsError.
-
cancelFundingSource(withId:
Asynchronous) Cancel a funding source.
Declaration
Swift
func cancelFundingSource(withId id: String) async throws -> FundingSource
Parameters
id
ID of the funding source to be deleted.
Return Value
- Success: Funding source that was cancelled.
- Failure:
- SudoPlatformError.
- SudoVirtualCardsError.
-
updateVirtualCard(withInput:
Asynchronous) Update a virtual card.
It is important to note that when updating a card, all fields that should remain the same should include their original data.
Declaration
Swift
func updateVirtualCard(withInput input: UpdateVirtualCardInput) async throws -> SingleAPIResult<VirtualCard, PartialVirtualCard>
Parameters
input
Input fields for the card update.
Return Value
- Success: Updated card.
- Failure:
- SudoPlatformError.
-
cancelVirtualCard(withId:
Asynchronous) Cancel a virtual card.
Declaration
Swift
func cancelVirtualCard(withId id: String) async throws -> SingleAPIResult<VirtualCard, PartialVirtualCard>
Parameters
id
ID of the card to cancel.
Return Value
Record of Virtual Card that was canceled.
-
getFundingSourceClientConfiguration()
AsynchronousGet the funding source client configuration. Returns: The configuration of the client funding source data.
Declaration
Swift
func getFundingSourceClientConfiguration() async throws -> [FundingSourceClientConfiguration]
-
getProvisionalCard(withId:
AsynchronouscachePolicy: ) Get a provisional card using the
id
parameter. If the card cannot be found,nil
will be returned.Parameters
- id: ID of the card to be retrieved.
- cachePolicy: Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.
Declaration
Swift
func getProvisionalCard(withId id: String, cachePolicy: CachePolicy) async throws -> ProvisionalCard?
Return Value
- Success: Card associated with
id
, ornil
if the card cannot be found. - Failure:
- SudoPlatformError.
-
Get a list of provisional cards. If no cards can be found, an empty list will be returned.
Declaration
Swift
func listProvisionalCards( withLimit limit: Int?, nextToken: String?, cachePolicy: CachePolicy ) async throws -> ListAPIResult<ProvisionalCard, PartialProvisionalCard>
Parameters
limit
Number of cards to return. If nil, the limit is 10.
nextToken
Generated token by previous calls to
listProvisionalCards
. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error. It is important to note that the same structured API call should be used if using a previously generatednextToken
.cachePolicy
Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.Return Value
- Success: Cards associated with user, or empty array if no card can be found.
- Failure:
- SudoPlatformError.
-
getVirtualCard(withId:
AsynchronouscachePolicy: ) Get a card using the
id
parameter. If the card cannot be found,nil
will be returned.Parameters
- id: ID of the card to be retrieved.
- cachePolicy: Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.
Declaration
Swift
func getVirtualCard( withId id: String, cachePolicy: CachePolicy ) async throws -> VirtualCard?
Return Value
- Success: Card associated with
id
, ornil
if the card cannot be found. - Failure:
- SudoPlatformError.
-
getVirtualCardsConfig(cachePolicy:
Asynchronous) Get the current
VirtualCardsConfig
. If the config cannot be found,nil
will be returned.Parameters
- cachePolicy: Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.
- cachePolicy: Determines how the data is fetched. When using
Declaration
Swift
func getVirtualCardsConfig( cachePolicy: CachePolicy ) async throws -> VirtualCardsConfig?
Return Value
- Success: Virtual card config associated with account, or
nil
if the coinfig cannot be found. - Failure:
- SudoPlatformError.
-
listVirtualCards(withLimit:
AsynchronousnextToken: cachePolicy: ) Get a list of cards. If no cards can be found, an empty list will be returned.
Declaration
Swift
func listVirtualCards( withLimit limit: Int?, nextToken: String?, cachePolicy: CachePolicy ) async throws -> ListAPIResult<VirtualCard, PartialVirtualCard>
Parameters
limit
Number of cards to return. If nil, the limit is 10.
nextToken
Generated token by previous calls to
getCards
. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error. It is important to note that the same structured API call should be used if using a previously generatednextToken
.cachePolicy
Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.Return Value
- Success: Cards associated with user, or empty array if no card can be found.
- Failure:
- SudoPlatformError.
-
getFundingSource(withId:
AsynchronouscachePolicy: ) Get a funding source using the
id
parameter. If the funding source cannot be found,nil
will be returned.Declaration
Swift
func getFundingSource( withId id: String, cachePolicy: CachePolicy ) async throws -> FundingSource?
Parameters
id
ID of the funding source to be retrieved.
cachePolicy
Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.Return Value
- Success:
FundingSource
associated withid
, ornil
if the funding source cannot be found. - Failure:
- SudoPlatformError.
- Success:
-
listFundingSources(withLimit:
AsynchronousnextToken: cachePolicy: ) Get a list of funding sources. If no funding sources can be found, an empty list will be returned.
Declaration
Swift
func listFundingSources( withLimit limit: Int?, nextToken: String?, cachePolicy: CachePolicy ) async throws -> ListOutput<FundingSource>
Parameters
limit
Number of funding sources to return. If
nil
, the limit is 10.nextToken
Generated token by previous calls to
getFundingSources
. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error. It is important to note that the same structured API call should be used if using a previously generatednextToken
.cachePolicy
Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.Return Value
- Success:
FundingSource
associated withid
, or empty array if no card can be found. - Failure:
- SudoPlatformError.
- Success:
-
getTransaction(withId:
AsynchronouscachePolicy: ) Get a transaction using the
id
parameter. If the transaction cannot be found,nil
will be returned.Declaration
Swift
func getTransaction( withId id: String, cachePolicy: CachePolicy ) async throws -> Transaction?
Parameters
id
ID of the transaction to be retrieved.
cachePolicy
Determines how the data is fetched. When using
cacheOnly
, please be aware that this will only return cached results of similar exact API calls.Return Value
- Success: Transaction associated with
id
, ornil
if the card cannot be found. - Failure:
- SudoPlatformError.
- Success: Transaction associated with
-
Get a list of transactions by card id. If no transactions can be found, an empty list will be returned.
Declaration
Swift
func listTransactions( withCardId cardId: String, limit: Int?, nextToken: String?, dateRange: DateRangeInput?, sortOrder: SortOrderInput?, cachePolicy: CachePolicy ) async throws -> ListAPIResult<Transaction, PartialTransaction>
Parameters
cardId
Identifier of the card to search associated transactions for.
limit
Number of transaction to return. If nil, the limit is up to 1MB of data returned from the service.
nextToken
Generated token by previous calls to
getTransactions
. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error.dateRange
Range of upper and lower date limits for records.
sortOrder
Order in which records are returned (based on date).
cachePolicy
Determines how the data is fetched.
Return Value
- Success: Transactions associated with user, or empty array if no transaction can be found.
- Failure:
- SudoPlatformError.
-
Get a list of transactions. If no transactions can be found, an empty list will be returned.
Declaration
Swift
func listTransactions( withLimit limit: Int?, nextToken: String?, dateRange: DateRangeInput?, sortOrder: SortOrderInput?, cachePolicy: CachePolicy ) async throws -> ListAPIResult<Transaction, PartialTransaction>
Parameters
limit
Number of transaction to return. If nil, the limit is 10.
nextToken
Generated token by previous calls to
getTransactions
. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error.dateRange
Range of upper and lower date limits for records.
sortOrder
Order in which records are returned (based on date).
cachePolicy
Determines how the data is fetched.
Return Value
- Success: Transactions associated with user, or empty array if no transaction can be found.
- Failure:
- SudoPlatformError.
-
Subscribe to transaction update events. This includes creation of new transactions.
Declaration
Swift
@discardableResult func subscribeToTransactionUpdated( statusChangeHandler: SudoSubscriptionStatusChangeHandler?, resultHandler: @escaping ClientCompletion<Transaction> ) async throws -> SubscriptionToken?
Parameters
statusChangeHandler
Connection status change.
resultHandler
Updated transaction event.
Return Value
SubscriptionToken
object to cancel the subscription. -
Subscribe to transaction delete events. This includes creation of new transactions.
Declaration
Swift
@discardableResult func subscribeToTransactionDeleted( statusChangeHandler: SudoSubscriptionStatusChangeHandler?, resultHandler: @escaping ClientCompletion<Transaction> ) async throws -> SubscriptionToken?
Parameters
statusChangeHandler
Connection status change.
resultHandler
Deleted transaction event.
Return Value
SubscriptionToken
object to cancel the subscription.