// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Standard Library using System; // GameKit using AWS.GameKit.Runtime.Models; namespace AWS.GameKit.Runtime.Features.GameKitUserGameplayData { /// /// Interface for the AWS GameKit User Gameplay Data feature. /// public interface IUserGameplayDataProvider { /// /// Creates a new bundle or updates BundleItems within a specific bundle for the calling user.

/// /// /// AddBundle should only be called the first time bundle items are created called to prevent excessive server use. ///

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name of userGameplayDataBundle is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_ITEM_KEY: At least one of the bundle keys of userGameplayData are malformed. If this error is received, Check the output log for more details on which item keys are not valid.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Object containing a map of game play data to add /// Delegate that is called once the function has finished executing public void AddBundle(AddUserGameplayDataDesc addUserGameplayDataDesc, Action callback); /// /// Applies the settings to the User Gameplay Data Client. Should be called immediately after the instance has been created and before any other API calls. /// /// Object containing client settings /// Delegate that is called once the function has finished executing public void SetClientSettings(UserGameplayDataClientSettings userGameplayDataClientSettings, Action callback); /// /// Lists the bundle name of every bundle that the calling user owns.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The response body from the backend could not be parsed successfully
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Delegate that is called once the function has finished executing public void ListBundles(Action callback); /// /// Gets all items that are associated with a certain bundle for the calling user.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name of UserGameplayDataBundleName is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The response body from the backend could not be parsed successfully
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Name of the data bundle items to fetch /// Delegate that is called once the function has finished executing public void GetBundle(string bundleName, Action callback); /// /// Gets a single item that is associated with a certain bundle for a user.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name in userGameplayDataBundleItem is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_ITEM_KEY: The bundle key in userGameplayDataBundleItem is malformed. If this error is received, Check the output log for more details on which item keys are not valid.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Object containing needed inforamtion for fetching the bundle item /// Delegate that is called once the function has finished executing public void GetBundleItem(UserGameplayDataBundleItem userGameplayDataBundleItem, Action callback); /// /// Updates the value of an existing item inside a bundle with new item data.

/// /// /// To prevent excessive server use, UpdateItem should be used intermittently on data that is being stored locally. Ex. Calling UpdateItem for a players coins after the level ends instead of each time they collect a coin. ///

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name in userGameplayDataBundleItem is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_ITEM_KEY: The bundle key in userGameplayDataBundleItem is malformed. If this error is received, Check the output log for more details on which item keys are not valid.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Object containing information for the bundle item update and what to update it with /// Delegate that is called once the function has finished executing public void UpdateItem(UserGameplayDataBundleItemValue userGameplayDataBundleItemValue, Action callback); /// /// Permanently deletes all bundles associated with a user.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Delegate that is called once the function has finished executing public void DeleteAllData(Action callback); /// /// Permanently deletes an entire bundle, along with all corresponding items, associated with a user.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name in UserGameplayDataBundleName is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// name of the bundle to delete /// Delegate that is called once the function has finished executing public void DeleteBundle(string bundleName, Action callback); /// /// Permanently deletes a list of items inside of a bundle associated with a user.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_SETTINGS_FILE_READ_FAILED: The session manager does not have settings loaded in for the User Gameplay data feature.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_NAME: The bundle name in userGameplayDataBundleItemsDeleteRequest is malformed. If this error is received, Check the output log for more details on requirements.
/// - GAMEKIT_ERROR_MALFORMED_BUNDLE_ITEM_KEY: The bundle key in userGameplayDataBundleItemsDeleteRequest is malformed. If this error is received, Check the output log for more details on which item keys are not valid.
/// - GAMEKIT_ERROR_NO_ID_TOKEN: The player is not logged in. You must login the player through the Identity and Authentication feature (AwsGameKitIdentity) before calling this method.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_FAILED: The call made to the backend service has failed.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_API_CALL_DROPPED: The call made to the backend service has been dropped.
/// - GAMEKIT_WARNING_USER_GAMEPLAY_DATA_API_CALL_ENQUEUED: The call made to the backend service has been enqueued as connection may be unhealthy and will automatically be retried.
/// - GAMEKIT_ERROR_GENERAL: The request has failed unknown reason.
///
/// Object containing the bundle and list of items to delete /// Delegate that is called once the function has finished executing public void DeleteBundleItems(DeleteUserGameplayDataBundleItemsDesc deleteUserGameplayDataBundleItemsDesc, Action callback); /// /// Enables automatic offline mode, including persisting all failed calls in the retry thread to a cache file at the end of program.

/// If the cache needs to be persisted before the application is closed it is recommended to use StopRetryBackgroundThread() to stop the thread and PersistToCache to save the cache manually, then EnableAutomaticOfflineModeWithCaching can be restarted.

/// /// Note: Methods such as DropAllCachedEvents, SetNetworkChangeDelegate, SetCacheProcessedDelegate and SetClientSettings are not handled by this method and should be called independently. ///
/// The location of the offline cache file. All persisted calls in the cache will automatically be loaded into the queue. Any failed calls in the queue at the end of the program will be cached in this file. public void EnableAutomaticOfflineModeWithCaching(string offlineCacheFile); /// /// Start the Retry background thread.

/// /// The DestroyFeature() method, which is automatically called when the application is closing, will handle stopping the thread.
/// However, if you need to persist the files during play it is recommended that you call StopRetryBackgroundThread() and Save/Load to Cache manually.

/// /// Note: If you are Caching your offline calls, StartRetryBackgroundThread() should be called after loading from cache. ///
public void StartRetryBackgroundThread(); /// /// Stop the Retry background thread.

/// /// Note: If you are caching your offline calls, StopRetryBackgroundThread() should be called before saving to cache. ///
public void StopRetryBackgroundThread(); /// /// Return information about the running state of the background thread. /// /// True if it is running, false otherwise public bool IsBackgroundThreadRunning(); /// /// Clear all pending events from the user's cache. /// /// Delegate that is called once the function has finished executing public void DropAllCachedEvents(Action callback); /// /// Set the callback to invoke when the network state changes. /// /// Delegate that should be called whenever there is a network change. public void SetNetworkChangeDelegate(UserGameplayData.NetworkChangedDelegate callback); /// /// Get the last known state of network connectivity. /// /// The last known state of connectivity. True means healthy, False means unhealthy public bool GetLastNetworkHealthState(); /// /// Forces an immediate retry of the calls that are in the queue. /// /// The Network state can transiton from Unhealthy to Healthy as a side effect of this. /// Callback invoked then the retry finishes. Returns success or failure. public void ForceRetry(Action resultCallback); /// /// Attempts to synchronize data in the queue with the backend and, if successful, executes another User Gameplay Data API. /// Use this when you want to be sure that the data in the backend is updated before making subsequent calls. /// /// The User Gameplay Data API to call (for example GetBundle(), GetBundleItem(), ListBundles(), or other APIs) /// Action to execute in case of error. Error can happen if the device is still offline or if the backend is experiencing problems. public void TryForceSynchronizeAndExecute(Action gameplayDataApiCall, Action onErrorAction); /// /// Set the callback to invoke when the offline cache finishes processing. /// /// Delegate that should be called whenever the cache has been successfully processed. public void SetCacheProcessedDelegate(UserGameplayData.CacheProcessedDelegate callback); /// /// Write the pending API calls to cache.

/// /// Pending API calls are requests that could not be sent due to network being offline or other failures.
/// The internal queue of pending calls is cleared. It is recommended to stop the background thread before calling this method.

/// /// This is the non-blocking version persist to cache call and should be used when saving during play, if you need to persist to cache on application close the blocking version, ImmediatePersistToCache() is recommended.
/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_CACHE_WRITE_FAILED: There was an issue writing the queue to the offline cache file.
///
/// Path to the offline cache file. /// Delegate that is called once the function has finished executing. public void PersistToCache(string offlineCacheFile, Action callback); /// /// Write the pending API calls to cache.

/// /// Pending API calls are requests that could not be sent due to network being offline or other failures.
/// The internal queue of pending calls is cleared. It is recommended to stop the background thread before calling this method.

/// /// This is the blocking version of the call and should be used on application close. PersistToCache() is recommended for saving to cache during play.
/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_CACHE_WRITE_FAILED: There was an issue writing the queue to the offline cache file.
///
/// Path to the offline cache file. /// The result code of persisting the queue to cache. public uint ImmediatePersistToCache(string offlineCacheFile); /// /// Read the pending API calls from cache.

/// /// The calls will be enqueued and retried as soon as the Retry background thread is started and network connectivity is up.
/// The contents of the cache are deleted.

/// /// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_USER_GAMEPLAY_DATA_CACHE_READ_FAILED: There was an issue loading the offline cache file to the queue.
///
/// path to the offline cache file. /// Delegate that is called once the function has finished executing. public void LoadFromCache(string offlineCacheFile, Action callback); } }