Account

final class Account

Class providing Account related actions.

  • Social login closure typealias containing account and error.

    Declaration

    Swift

    public typealias SocialLoginCompletion = (_ account: InPlayerAccount?, _ error: InPlayerError?) -> Void

    Parameters

    account

    The obtained account.

    error

    The error that might occur.

  • Get user credentials if present, else returns nil.

    Declaration

    Swift

    public static func getCredentials() -> InPlayerCredentials?

    Return Value

    User credentials or nil.

  • Removes account and user credentials

    Declaration

    Swift

    public static func removeCredentials()
  • Get account if logged in, else it returns nil

    Declaration

    Swift

    public static func getAccountInfo() -> InPlayerAccount?

    Return Value

    Account or nil

  • Check if current user has valid access token.

    Declaration

    Swift

    public static func isAuthenticated() -> Bool

    Return Value

    Bool result of the check.

  • Creates new account.

    Declaration

    Swift

    public static func signUp(fullName: String,
                              email: String,
                              password: String,
                              passwordConfirmation: String,
                              brandingID: Int? = nil,
                              metadata: [String: Any]? = nil,
                              success: @escaping (_ authorization: InPlayerAuthorization) -> Void,
                              failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    fullName

    Account’s first and last name

    email

    Account’s email address

    password

    Password containing minimum 8 characters

    passwordConfirmation

    The same password with minimum 8 characters

    metadata

    Additional information about the account that can be attached to the account object

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    authorization

    Authorization model containing info regarding token and account

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Gets the account information for a given authorization token

    Declaration

    Swift

    public static func getAccount(success: @escaping (_ account: InPlayerAccount) -> Void,
                                  failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    success

    A closure to be executed once the request has finished successfully.

    account

    Contains account info

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Authenticates account using username and password

    Declaration

    Swift

    public static func authenticate(username: String,
                                    password: String,
                                    success: @escaping (_ authorization: InPlayerAuthorization) -> Void,
                                    failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    username

    The email address of the account.

    password

    The account password

    success

    A closure to be executed once the request has finished successfully.

    authorization

    Model containing access tokens and logged in account.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Logout currently authenticated account

    Declaration

    Swift

    public static func signOut(success: @escaping () -> Void,
                               failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Updates account information.

    Declaration

    Swift

    public static func updateAccount(fullName: String,
                                     metadata: [String : Any]? = nil,
                                     success: @escaping (_ account: InPlayerAccount) -> Void,
                                     failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    fullName

    The full name of the account.

    metadata

    Additional information about the account that can be attached to the account object

    success

    A closure to be executed once the request has finished successfully.

    account

    Contains account info.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Updates account password.

    Declaration

    Swift

    public static func changePassword(oldPassword: String,
                                      newPassword: String,
                                      newPasswordConfirmation: String,
                                      brandingID: Int? = nil,
                                      success: @escaping () -> Void,
                                      failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    oldPassword

    Account’s old password.

    newPassword

    The account’s new password

    newPasswordConfirmation

    The account’s new password for confirmation.

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Deletes account and all information stored with it.

    Declaration

    Swift

    public static func deleteAccount(password: String,
                                     brandingID: Int? = nil,
                                     success: @escaping () -> Void,
                                     failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    password

    Password confirmation.

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Sets new password for account using the token from account’s email.

    Declaration

    Swift

    public static func setNewPassword(token: String,
                                      password: String,
                                      passwordConfirmation: String,
                                      brandingID: Int? = nil,
                                      success: @escaping () -> Void,
                                      failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    token

    The forgot password token sent to your email address.

    password

    The account’s new password.

    passwordConfirmation

    The password confirmation.

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Sends forgot password instructions on specified email.

    Declaration

    Swift

    public static func requestNewPassword(email: String,
                                          brandingID: Int? = nil,
                                          success: @escaping () -> Void,
                                          failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    email

    Account’s email address.

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Refreshes account access_token

    Declaration

    Swift

    public static func refreshToken(using refreshToken: String,
                                    success: @escaping (_ authorization: InPlayerAuthorization) -> Void,
                                    failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    refreshToken

    An auto-generated token that enables access when the original access token has expired without requiring re authentication

    success

    A closure to be executed once the request has finished successfully.

    authorization

    Model containing access tokens and logged in account.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Exports account data such as logins, payments, subscriptions, access to assets etc. After invoking the request the account will receive the data in a json format via e-mail.

    Declaration

    Swift

    public static func exportData(password: String,
                                  brandingID: Int? = nil,
                                  success: @escaping () -> Void,
                                  failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    password

    Password of the current logged user

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Gets register fields

    Declaration

    Swift

    public static func getRegisterFields(success: @escaping (_ registerFields: [InPlayerRegisterField]) -> Void,
                                         failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    success

    A closure to be executed once the request has finished successfully.

    registerFields

    InPlayerRegisterField struct optionally containing associated values depending on the type enum.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Get List of Social URLs

    Declaration

    Swift

    public static func getSocialUrls(redirectUri: String,
                                     success: @escaping (_ socialURLs: [InPlayerSocialUrl]) -> Void,
                                     failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    success

    A closure to be executed once the request has finished successfully.

    socialURLs

    Array of objects, each containing different social service and its url.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Validates social login redirect url

    Declaration

    Swift

    public static func validateSocialLogin(url: URL)

    Parameters

    url

    The redirect url to be processed.

  • Opens external browser with the provided url.

    Declaration

    Swift

    public static func socialLogin(withUrl url: URL, completion: @escaping SocialLoginCompletion)

    Parameters

    url

    The social url that needs to be open.

    completion

    A closure to be executed once the request has finished. It contains account if the loging was successfull or error if something went wrong.

  • Creates pin code and sends it to your email

    Declaration

    Swift

    public static func sendPinCode(brandingID: Int?,
                                   success: @escaping () -> Void,
                                   failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    brandingID

    Optional parameter - system branding theme ID

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.

  • Checks validity of pin code

    Declaration

    Swift

    public static func validatePinCode(_ pinCode: String,
                                       success: @escaping () -> Void,
                                       failure: @escaping (_ error: InPlayerError) -> Void)

    Parameters

    pinCode

    The pin code that was sent to your email

    success

    A closure to be executed once the request has finished successfully.

    failure

    A closure to be executed once the request has finished with error.

    error

    Containing information about the error that occurred.