SudoEntitlementsClient

public protocol SudoEntitlementsClient : AnyObject

Client used to interface with the Sudo Entitlements Platform service.

It is recommended to code to this interface, rather than the implementation class (DefaultSudoEntitlementsClient) as the implementation class is only meant to be used for initializing an instance of the client.

Lifecycle

  • Clear all locally cached data

    Declaration

    Swift

    func reset() throws

Queries

  • Get the current set of entitlements and their consumption for the user

    Declaration

    Swift

    func getEntitlementsConsumption() async throws -> EntitlementsConsumption

    Return Value

    • Success: The set of entitlements the user currently has and consumption information for the user and its sub-resource consumers, if any

  • getExternalId() Asynchronous

    Get the external ID as determined by the entitlements service. Useful for automated tests

    Declaration

    Swift

    func getExternalId() async throws -> String

    Return Value

    • The external ID of the authenticated user

Mutations

  • redeemEntitlements() Asynchronous

    Redeem the entitlements for the user.

    Declaration

    Swift

    func redeemEntitlements() async throws -> EntitlementsSet

    Return Value

    • The current set of entitlements the user has after the redemption has completed.

  • Record consumption of a set of boolean entitlements.

    This is to support services that want a record of usage recorded but have no service side enforcement point.

    Throws

    Throws:

    • NotSignedInException User is not signed in
    • InsufficientEntitlementsException User is not entitled to one or more of the boolean entitlements. Check entitlements and that redeemEntitlements has been called for the user.
    • InvalidArgumentException One or more of the specified entitlement names does not correspond to a boolean entitlement defined to the entitlements service
    • ServiceException An error occurred within the entitlements service that indicates an issue with the configuration or operation of the service.

    Declaration

    Swift

    func consumeBooleanEntitlements(entitlementNames: [String]) async throws

    Parameters

    entitlementNames

    Boolean entitlement names to record consumption of