Account
Last updated
Last updated
The account module contains the necessary operations to fetch and update the user's account. An account is a representation of a person, not a device. Therefore two devices may be logged to the same account.
One person may have more than one valid credentials for accessing his/her account, but can only have one credential per authentication platform (for example, one credential by e-mail/password and one credential by twitter).
An account is represented by an AccountProfile
object, which holds the account's basic information (AccountInfo
), the list of subscriptions the account has access to, and the context linked to the account.
Contains the account's unique identifier, the identifier of the IdentityPool the account belongs to and the list of authentication platforms the owner of the account have already used to sign in.
The subscriptions under an account profile object are accessible from any device that signs in to that account. The subscription object is exactly the same as the one used on section
The account context holds all the data the application wants to store and link to that account. It consists on a dictionary accessed by namespaces (namespaces are freely defined by the application).
Operations to request the server for the most updated information over the account. To perform any fetch operation the user must be logged in, otherwise will receive INVALID_CREDENTIALS error.
There are 3 fetch operations:
Retrieves the full account profile from the server and update it locally
Retrieve and update locally only the account subscriptions
Retrieve and update locally only the account context
A FetchAccountResponse object holds a FetchAccountStatus, which may be one of the following:
UNKNOWN_ERROR: Unknown error happened while performing request to fetch account information
SUCCESS: Fetched information on account successfully
SERVER_ERROR_INVALID_TOKEN: Could not fetch account information because was not logged in or was logged with an invalid account
SERVER_ERROR_CONNECTION_FAILURE: Could not fetch account information due to connection errors with Kiwi server
SERVER_ERROR_UNEXPECTED_RESPONSE: Could not fetch account information due to an unexpected server response
SERVER_ERROR_PARSING_RESPONSE: Could not fetch account information due to an error parsing server response
Operations that retrieve account's information that had already been fetched. NOTE: If the user is not signed in, the information retrieved here will be null
There are 3 retrieve local operations. Each one of them returns a Future object containg the desired object.
This operation will link the target subscription with the current account. In order for the link to work, the current user should already have access to that subscription through kiwi's userId. NOTE: the user must be authenticated in order to perform this request, otherwise will receive INVALID_TOKEN error
The possible Link Subscription With Account Status are:
UNKNOWN_ERROR: Unknown error while trying to link subscription with account
SUCCESS: Linked subscription with account successfully
SUCCESS_SUBSCRIPTION_ALREADY_LINKED: Subscription was already linked to the current account
ERROR_INVALID_PARAMETERS: Could not link subscription due to missing subscription id
SERVER_ERROR_CONNECTION_FAILURE: Could not link subscription due to error with connection to Kiwi server
SERVER_ERROR_INVALID_TOKEN: Could not link subscription because it's not logged in or is logged in to an invalid account
SERVER_ERROR_SUBSCRIPTION_NOT_FOUND: Could not link subscription because the target subscription does not exist
SERVER_ERROR_USER_NOT_AUTHORIZED_TO_SUBSCRIPTION: Could not link subscription because the current user did not have rights over this subscription
SERVER_ERROR_SUBSCRIPTION_LINKED_TO_OTHER_ACCOUNT: Could not link subscription because the target subscription was already linked to other account
SERVER_ERROR_UNEXPECTED_RESPONSE: Could not link subscription because of an unexpected response from the server
SERVER_ERROR_PARSING_RESPONSE: Could not link subscription because of an error parsing response from the server
This operation will update the account context linked to the current account. NOTE: the user must be authenticated in order to perform this request, otherwise will receive INVALID_TOKEN error
The possible Update Account Context Status are:
UNKNOWN_ERROR: Unknown error while updating account context
SUCCESS: Updated account context successfully
SERVER_ERROR_INVALID_TOKEN: Could not update account context because was not logged in or was logged to an invalid account
SERVER_ERROR_CONNECTION_FAILURE: Could not update account due to error connecting with Kiwi server
SERVER_ERROR_UNEXPECTED_RESPONSE: Could not update account due to unexpected response from the server
SERVER_ERROR_PARSING_RESPONSE: Could not update account due to an error parsing server response
ERROR_INVALID_PARAMETERS: Could not update account due to missing account context on request