IUserServiceProfileManager

public protocol IUserServiceProfileManager

The UserServiceProfileManager stores a cache of all users UserServiceProfile that have been fetched.

  • The maximum number of profiles that can be queued up to be fetched by the servers.

    Declaration

    Swift

    var maxUserDataFetchCount: Int
  • Initialize the User Service Profile Manager with default external service dependencies. Part of this process will initialize the UserServiceDataModel which will preform some basic validation of the ‘userService’ manifest node.

    Declaration

    Swift

    func initialize() -> Promise<Response>

    Return Value

    A Promise<Response>, response will be empty on success.

  • Initialize service with custom service dependency implementations.

    Custom service implementaitions can be provided which will be used instead of the defaults.

    Declaration

    Swift

    func initialize(manifest: Manifest, darkMatter: IDarkMatter, userService: IUserService, dataModel: UserServiceDataModel, networkManager: INetworkManager, gameService: IGameService) -> Promise<Response>

    Parameters

    manifest

    The Manifest object the UserServiceProfileManager library will use.

    darkMatter

    The IDarkMatter object the UserServiceProfileManager library will use.

    userService

    The IUserService object the UserServiceProfileManager library will use.

    dataModel

    The UserServiceDataModel object the UserServiceProfileManager library will use.

    networkManager

    The INetworkManager object the UserServiceProfileManager library will use.

    gameService

    The IGameService object the UserServiceProfileManager library will use.

    Return Value

    A Promise<Response>, response will be empty on success.

  • Add a UserServiceProfile to the manager’s profile cache.

    Declaration

    Swift

    func addUserData(userProfile: UserServiceProfile, overwrite: Bool) -> Promise<Response>

    Parameters

    userProfile

    A UserServiceProfile to load into the cache. The profile must at the least have a userid set or the add operation will fail. The operation will also fail if the user profile is invalid in some way or a profile with the userId has already been loaded.

    overwrite

    A flag that will allow the added profile to overwrite a profile if one already exists with the same userid.

    Return Value

    A Promise<Response> that resolves if the add operation was successful.

  • Get a dictionary of loaded profiles given a list of userids. This is a synchronous operation and will skip profiles that are not already loaded.

    Declaration

    Swift

    func getUserDictionary(userIds: [String]) -> [String: UserServiceProfile?]?

    Parameters

    userIds

    A [String] of userids.

    Return Value

    A [String: UserServiceProfile?]? for all the user ids that were found in the cache where the key will be the userid. Will return nil if the userIds list is invalid. Any userid that wasn’t found will be omitted from the return dictionary.

  • Fetches data for a [String] of users.

    Declaration

    Swift

    func getUserData(userIds: [String], fetchIfNotFound: Bool, stopOnFail: Bool, fetchQueueId: String) -> Promise<[String: UserServiceProfile?]>

    Parameters

    userIds

    A [String] of userids.

    fetchIfNotFound

    A flag to request that data be fetched from the remote server if the userId is not found in the local cache.

    stopOnFail

    NOT CURRENTLY USED.

    fetchQueueId

    The manifest fetch queue id to request data for. The fetch queue specifies data keys to request from the server.

    Return Value

    Resolves with a Promise<[String: UserServiceProfile?]> with all the user profiles that were fetched.

  • Fetches data for a user.

    Declaration

    Swift

    func getUserData(userId: String, fetchIfNotFound: Bool, fetchQueueId: String) -> Promise<UserServiceProfile>

    Parameters

    userId

    The userid of the user.

    fetchIfNotFound

    Should the service attempt to fetch the data from the server if the userid isn’t in the local cache.

    fetchQueueId

    The manifest fetch queue id to request data for. The fetch queue specifies data keys to request from the server.

    Return Value

    Resolves with a Promise<UserServiceProfile> of the user requested.

  • Get a [String: UserServiceProfile] of all profiles in the local cache.

    Declaration

    Swift

    func getAllUserData() -> Promise<[String: UserServiceProfile]>

    Return Value

    Resolves with a [String: UserServiceProfile] with the key being the userId.

  • Will add the provided profile to the profile cache and set the current user data to that profile

    Declaration

    Swift

    func setLocalUserData(localUserProfile: UserServiceProfile) -> Promise<Response>

    Parameters

    localUserProfile

    The UserServiceProfile to use.

    Return Value

    Resolves a Promise<Response> if the local user was successfully set to the profile. Will fail if the profile is invalid or the userId of the profile is the same as the current local user profile.

  • Resets the current user token for the local user. This also resets the Profile Manager and wipes all cached profiles. You’ll need to relogin to reinitialize the servers.

    Declaration

    Swift

    func resetUserToken() -> Void
  • Get the local user profile data.

    Declaration

    Swift

    func getLocalUserData() -> UserServiceProfile?

    Return Value

    UserServiceProfile of the local user.

  • Resets the current user profile and reset all data values to the _init value set in the manifest.

    Declaration

    Swift

    func initializeNewLocalUserProfile() -> Promise<Response>

    Return Value

    Resolves with a Promise<Response> if successful. Can fail if there are configuration issues in the manifest or there was an issue syncing the new data with the server.