UserServiceProfile
@objc public class UserServiceProfile: NSObject
Stores all of a user’s current profile data. Can preform asynchronous requests to set / get data from the server.
-
The v5 userId associated with this profile.
Declaration
Swift
public private(set) var userId : String = "" -
NOT CURRENTLY USED.
Declaration
Swift
public private(set) var requiresSync: Bool = true -
Default constructor.
Declaration
Swift
public override init() -
Constructor with custom dependencies.
Declaration
Swift
public init(userId: String, networkManager: INetworkManager, gameService: IGameService)Parameters
userIdThe userid for the profile.
networkManagergameService -
Does this bank key exist in the manifest bankConfig configurations.
Declaration
Swift
public func isValidBankKey(key: String) -> BoolParameters
keyThe key to check.
Return Value
True if the key exists.
-
Get a `UserServiceItemBank for the provided key. The object will have all the configuration properties as well as the current users value for that bank item.
Declaration
Swift
public func getBankObject(key: String) -> UserServiceItemBank?Parameters
keyThe bank key.
Return Value
UserServiceItemBank. Will return nil if the key is invalid or not found. -
Get the value for a bank key.
Declaration
Swift
public func getBankValue(key: String) -> Int64Parameters
keyThe key to check.
Return Value
The current bank value. The return will be 0 if the key is invalid or not found.
-
Set the value for a bank key. The value will not be set if the key is invalid or not found in the bank configuration.
This modification is local only and the profile will need to be saved for these change to be sent to the server.
Declaration
Swift
public func setBankValue(key : String, quantity: Int64)Parameters
keyThe key to set.
quantityThe value to set.
-
Does this storage key exist in the manifest storageConfig configurations.
Declaration
Swift
public func isValidStorageKey(key: String) -> BoolParameters
keyThe key to check.
Return Value
True if the key exists.
-
Get a
UserServiceItemStoragefor the provided key. The object will have all the configuration properties as well as the current users data for that storage item.Declaration
Swift
public func getStorage(key: String) -> UserServiceItemStorage?Parameters
keyThe storage key.
Return Value
UserServiceItemStorage. Will return nil if the key is invalid or not found. -
Get the value for a storage key
Declaration
Swift
public func getStorageValue(key: String) -> [String: Any]Parameters
keyThe key to check
Return Value
[String: Any]with all the storage data for the key. The return will be nil if the key is invalid or not found. -
Set the storage data for a given key.
The old data will be replaced, the objects are not merged. This modification is local only and the profile will need to be saved for these change to be sent to the server.
Declaration
Swift
public func setStorage(key: String, data: [String: Any])Parameters
keyThe key to the data to be set.
dataThe
[String: Any]data. -
Fetch the users data that’s mapped to the fetchQueueId provided
Declaration
Swift
public func loadUserProfile(fetchQueueId: String, stopOnFail: Bool) -> Promise<UserServiceProfile>Parameters
fetchQueueIdThe fetch queue id to fetch for.
stopOnFailNOT CURRENTLY USED.
Return Value
Resolves with a
Promise<UserServiceProfile>when the fetch queue is complete. Will fail if the profile or the fetch queue id is invalid. -
Fetch the users data that’s mapped to a list of fetchQueueId provided.
Declaration
Swift
public func loadUserProfile(itemList: [String], stopOnFail: Bool) -> Promise<UserServiceProfile>Parameters
itemList[String]of queue ids.stopOnFailNOT CURRENTLY USED.
Return Value
Resolves with a
Promise<UserServiceProfile>when the fetch queues have completed. /// Will fail if the profile or the fetch queue ids are invalid. -
Send a request to get data for a user.
Declaration
Swift
public func load(key: String) -> Promise<Void>Parameters
keyThe data key to request.
Return Value
Resolves with a
Promise<Void>when complete. Will fail if the key is invalid or on a network error. -
Load data from a server response.
Declaration
Swift
public func loadFromData(type: ItemType, key: String, data: [String: AnyObject]?) -> BoolParameters
typeThe type to load into.
keyThe key of the data.
dataThe data to save.
Return Value
True if the load was successful. Will fail if the type is invalid or the data is null.
-
Save the data in a users profile associated with the provided fetchQueueId.
Declaration
Swift
public func saveUserProfile(fetchQueueId: String, stopOnFail: Bool) -> Promise<Response>Parameters
fetchQueueIdThe fetch queue id.
stopOnFailNOT CURRENTLY USED.
Return Value
Resolves with a
Promise<Response>on success. Will fail if the user profile or fetch queue Id is invalid, or if there is a network error during the save operations. -
Save the data in a users profile associated with the provided fetchQueueIds.
Declaration
Swift
public func saveUserProfile(itemList: [String], stopOnFail: Bool) -> Promise<Response>Parameters
itemListThe
[String]of queue ids.stopOnFailNOT CURRENTLY USED.
Return Value
Resolves with a
Promise<Response>on success. Will fail if the user profile or fetch queue Id list is invalid, or if there is a network error during the save operations. -
Send a request to set data for a user
Declaration
Swift
public func save(key: String) -> Promise<Void>Parameters
keyThe data key to send.
Return Value
Resolves with a
Promise<Void>when complete. Will fail if the key or data for the type is invalid, or on a network error during the request. -
Will set and save all profile data that has an _init value set in the manifest for that item.
Declaration
Swift
public func setToInitialValues() -> Promise<Response>Return Value
A
Promise<Response>that resolves on success.
UserServiceProfile Class Reference