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.

  • reset() Asynchronous

    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() async throws
  • createKeysIfAbsent() Asynchronous

    Create 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

Mutations

  • Setup a funding source.

    Throws

    • InsufficientEntitlements.
    • VelocityExceeded.

    Declaration

    Swift

    func setupFundingSource(withInput input: SetupFundingSourceInput) async throws -> ProvisionalFundingSource

    Parameters

    input

    Funding Source input information.

    Return Value

    The provisional Funding Source.

  • Complete a provisional funding source.

    Throws

    • DuplicateFundingSource.
    • FundingSourceCompletionDataInvalid.
    • IdentityNotVerified.
    • ProvisionalFundingSourceNotFound.
    • UnacceptableFundingSource.

    Declaration

    Swift

    func completeFundingSource(withInput input: CompleteFundingSourceInput) async throws -> FundingSource

    Parameters

    input

    Parameters used to complete the funding source.

    Return Value

    The provisioned Funding Source.

  • Provision a virtual card.

    Throws

    • SudoPlatformError.
    • SudoVirtualCardsError.

    Declaration

    Swift

    func provisionVirtualCard(withInput input: ProvisionVirtualCardInput) async throws -> VirtualCard

    Parameters

    input

    Parameters used to provision a Virtual Card.

    Return Value

    The newly provisioned Virtual Card.

  • Cancel a funding source.

    Throws

    Throws:

    • SudoPlatformError.
    • SudoVirtualCardsError.

    Declaration

    Swift

    func cancelFundingSource(withId id: String) async throws -> FundingSource

    Parameters

    id

    ID of the funding source to be cancelled.

    Return Value

    Funding source that was cancelled.

  • Cancel a provisional funding source.

    Throws

    Throws:

    • SudoPlatformError.
    • SudoVirtualCardsError.

    Declaration

    Swift

    func cancelProvisionalFundingSource(withId id: String) async throws -> ProvisionalFundingSource

    Parameters

    id

    ID of the provisional funding source to be cancelled.

    Return Value

    Provisional funding source that was cancelled and is in a failed state.

  • Update a virtual card.

    It is important to note that when updating a card, all fields are updated, therefore, any fields that should remain the same must include their original data.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func updateVirtualCard(withInput input: UpdateVirtualCardInput) async throws -> SingleAPIResult<VirtualCard, PartialVirtualCard>

    Return Value

    • Success: The Virtual Card that was updated.
    • Partial: Partial record of updated Virtual Card.

  • 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

    • Success: Record of Virtual Card that was canceled.
    • Partial: Partial record of cancelled Virtual Card
  • Imports cryptographic keys from a key archive.

    Declaration

    Swift

    func importKeys(archiveData: Data) throws

    Parameters

    archiveData

    Key archive data to import the keys from.

Queries

  • Get a provisional card using the id parameter. If the card cannot be found, nil will be returned.

    Throws

    Throws
    • SudoPlatformError.

    Declaration

    Swift

    func getProvisionalCard(withId id: String) async throws -> ProvisionalCard?

    Parameters

    id

    ID of the card to be retrieved.

    Return Value

    Card associated with id, or nil if the card cannot be found.

  • Get a list of provisional cards. If no cards can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listProvisionalCards(
        withLimit limit: Int?,
        nextToken: String?
    ) 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 generated nextToken.

    Return Value

    • Success: Cards associated with user, or empty array if no card can be found.
    • Partial: Mix of success and partial cards associated with user.

  • Get a card using the id parameter. If the card cannot be found, nil will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func getVirtualCard(withId id: String) async throws -> VirtualCard?

    Parameters

    id

    ID of the card to be retrieved.

    Return Value

    Card associated with id, or nil if the card cannot be found.

  • Get the current VirtualCardsConfig.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func getVirtualCardsConfig() async throws -> VirtualCardsConfig

    Return Value

    Virtual card config associated with account.

  • Get a list of cards. If no cards can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listVirtualCards(
        withFilter filter: VirtualCardFilterInput?,
        sortOrder: SortOrderInput?,
        withLimit limit: Int?,
        nextToken: String?
    ) async throws -> ListAPIResult<VirtualCard, PartialVirtualCard>

    Parameters

    filter

    The filter to be applied to the list of virtual cards to return.

    limit

    Number of cards to return. If nil, the limit is 10.

    sortOrder

    Order in which records are returned (based on date/time at which the funding source was updated). The default order is descending, ie, most recently updated first.

    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 generated nextToken.

    Return Value

    • Success: Cards associated with user, or empty array if no card can be found.
    • Partial: Mix of success and partial cards associated with user.

  • Get a funding source using the id parameter. If the funding source cannot be found, nil will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func getFundingSource(withId id: String) async throws -> FundingSource?

    Parameters

    id

    ID of the funding source to be retrieved.

    Return Value

    FundingSource associated with id, or nil if the funding source cannot be found.

  • Get a list of funding sources. If no funding sources can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listFundingSources(
        withFilter filter: FundingSourceFilterInput?,
        sortOrder: SortOrderInput?,
        withLimit limit: Int?,
        nextToken: String?
    ) async throws -> ListOutput<FundingSource>

    Parameters

    filter

    The filter to be applied to the list of funding sources to return.

    sortOrder

    Order in which records are returned (based on date/time at which the funding source was updated). The default order is descending, ie, most recently updated first.

    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 generated nextToken.

    Return Value

    FundingSources or empty array if no funding source can be found.

  • Get a list of provisional funding sources. If no provisional funding sources can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listProvisionalFundingSources(
        withFilter filter: ProvisionalFundingSourceFilterInput?,
        sortOrder: SortOrderInput?,
        limit: Int?,
        nextToken: String?
    ) async throws -> ListOutput<ProvisionalFundingSource>

    Parameters

    filter

    The filter to be applied to the list of provisional funding sources to return.

    sortOrder

    Order in which records are returned (based on date/time at which the funding source was updated). The default order is descending, ie, most recently updated first.

    limit

    Number of funding sources to return. If nil, the limit is 10.

    nextToken

    Generated token by previous calls to getProvisionalFundingSources. 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 generated nextToken.

    Return Value

    FundingSources matching filter, or empty array if no funding source can be found.

  • Export the cryptographic keys to a key archive.

    Declaration

    Swift

    func exportKeys() throws -> Data

    Return Value

    Key archive data.

Methods: Transactions

  • Get a transaction using the id parameter. If the transaction cannot be found, nil will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func getTransaction(withId id: String) async throws -> Transaction?

    Parameters

    id

    ID of the transaction to be retrieved.

    Return Value

    Transaction associated with id, or nil if the transaction cannot be found.

  • Get a list of transactions by card id. If no transactions can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listTransactions(
        withCardId cardId: String,
        limit: Int?,
        nextToken: String?,
        dateRange: DateRangeInput?,
        sortOrder: SortOrderInput?
    ) async throws -> ListAPIResult<Transaction, PartialTransaction>

    Parameters

    cardId

    Identifier of the card for which associated transactions will be returned.

    limit

    Number of transactions to return. If nil, the limit is up to 1MB of data returned from the service.

    nextToken

    Generated token by previous calls to listTransactions. 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).

    Return Value

    • Success: Transactions associated with the virtual card, or empty array if no transaction can be found.
    • Partial: Mix of complete and partial Transactions associated with the virtual card.

  • Get a list of transactions by card id and transaction type. If no transactions can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listTransactions(
        withCardId cardId: String,
        withTransactionType transactionType: TransactionType,
        limit: Int?,
        nextToken: String?
    ) async throws -> ListAPIResult<Transaction, PartialTransaction>

    Parameters

    cardId

    Identifier of the card for which associated transactions will be returned.

    transactionType

    The type of transactions to retrieve.

    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 listTransactions. This is used for pagination. This value should be pre-generated from a previous pagination call, otherwise it will throw an error.

    Return Value

    • Success: Transactions of specific type associated with the virtual card, or empty array if no transaction can be found.
    • Partial: Mix of complete and partial Transactions associated with the virtual card.

  • Get a list of transactions. If no transactions can be found, an empty list will be returned.

    Throws

    • SudoPlatformError.

    Declaration

    Swift

    func listTransactions(
        withLimit limit: Int?,
        nextToken: String?,
        dateRange: DateRangeInput?,
        sortOrder: SortOrderInput?
    ) 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 listTransactions. 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).

    Return Value

    • Success: Transactions associated with user, or empty array if no transaction can be found.
    • Partial: Mix of complete and partial Transactions associated with user.

Sign-In Delegate

  • setSignInDelegate(_:) Asynchronous

    Sets an optional delegate to handle sign-in when operations are attempted while not signed in.

    When set, all operations (except subscriptions and initialization) will check sign-in status and invoke the delegate’s signIn() method if the user is not signed in. The delegate should handle the sign-in process and throw an error if sign-in fails or is cancelled. If the delegate throws an error, that error will be propagated to the caller and the original operation will not be executed.

    Declaration

    Swift

    func setSignInDelegate(_ delegate: SudoPlatformSignInDelegate?) async

    Parameters

    delegate

    A delegate conforming to SudoPlatformSignInDelegate. Pass nil to disable sign-in checking.

Subscriptions

  • Subscribes to be notified of changes to distributed vaults and members.

    Declaration

    Swift

    func subscribe(id: String, notificationType: SubscriptionNotificationType, subscriber: Subscriber) async throws

    Parameters

    id

    Unique ID to be associated with the subscriber.

    notificationType

    Notification type to subscribe to.

    subscriber

    Subscriber to notify.

  • unsubscribe(id:) Asynchronous

    Unsubscribes the specified subscriber so that it no longer receives change notifications.

    Declaration

    Swift

    func unsubscribe(id: String) async

    Parameters

    id

    Unique ID associated with the subscriber to unsubscribe.

  • unsubscribeAll() Asynchronous

    Unsubscribe all subscribers from receiving notifications about changes to distributed vaults and members.

    Declaration

    Swift

    func unsubscribeAll() async