// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Standard Library
using System;
// GameKit
using AWS.GameKit.Common.Models;
using AWS.GameKit.Editor.Core;
using AWS.GameKit.Runtime.FeatureUtils;
using AWS.GameKit.Runtime.Models;
namespace AWS.GameKit.Editor.AchievementsAdmin
{
///
/// Provides administrative methods for managing a game's Achievements (ex: creating new achievements, tweaking existing achievements, etc.).
///
public class AchievementsAdmin : GameKitFeatureBase, IAchievementsAdminProvider
{
public override FeatureType FeatureType => FeatureType.Achievements;
///
/// Call to get an instance of the GameKit AchievementsAdmin feature.
///
/// An instance of the AchievementsAdmin feature that can be used to call AchievementsAdmin related methods.
public static AchievementsAdmin Get()
{
return GameKitFeature.Get();
}
///
/// Initialize this class. This must be called before calling any of the APIs, otherwise an will be thrown.
///
public void Initialize(FeatureResourceManager featureResourceManager, CredentialsManager credentialsManager)
{
Feature.Initialize(featureResourceManager, credentialsManager);
}
///
/// Lists non-hidden achievements, and will call delegates after every page.
///
/// Secret achievements will be included, and developers will be responsible for processing those as they see fit.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - 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_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
///
/// Object containing call preferences
/// Delegate that is called while the function is executing, once for each page of achievements
/// Delegate that is called once the function has finished executing
public void ListAchievementsForGame(ListAchievementsDesc listAchievementsDesc, Action callback, Action onCompleteCallback)
{
Call(Feature.AdminListAchievements, listAchievementsDesc, callback, onCompleteCallback);
}
///
/// Add all achievements passed to the games dynamoDB achievements table.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_ACHIEVEMENTS_ICON_UPLOAD_FAILED: Was unable to take the local path given of an image and upload it to S3.
/// - GAMEKIT_ERROR_REGION_CODE_CONVERSION_FAILED: The current region isn't in our template of shorthand region codes, unknown if the region is supported.
/// - GAMEKIT_ERROR_SIGN_REQUEST_FAILED: Was unable to sign the internal http request with account credentials and info, possibly because they do not have sufficient permissions.
/// - GAMEKIT_ERROR_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
///
/// Object containing a list of achievements to add
/// Delegate that is called once the function has finished executing
public void AddAchievementsForGame(AddAchievementDesc addAchievementDesc, Action callback)
{
Call(Feature.AdminAddAchievements, addAchievementDesc, callback);
}
///
/// Deletes the set of achievements metadata from the game's DynamoDB.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_REGION_CODE_CONVERSION_FAILED: The current region isn't in our template of shorthand region codes, unknown if the region is supported.
/// - GAMEKIT_ERROR_SIGN_REQUEST_FAILED: Was unable to sign the internal http request with account credentials and info, possibly because they do not have sufficient permissions.
/// - GAMEKIT_ERROR_HTTP_REQUEST_FAILED: The backend HTTP request failed. Check the logs to see what the HTTP response code was.
/// - GAMEKIT_ERROR_PARSE_JSON_FAILED: The backend returned a malformed JSON payload. This should not happen. If it does, it indicates there is a bug in the backend code.
/// - GAMEKIT_ERROR_ACHIEVEMENTS_PAYLOAD_TOO_LARGE: The argument list is too large to pass as a query string parameter.
///
/// Object containing a list of achievement identifiers to delete
/// Delegate that is called once the function has finished executing
public void DeleteAchievementsForGame(DeleteAchievementsDesc deleteAchievementsDesc, Action callback)
{
Call(Feature.AdminDeleteAchievements, deleteAchievementsDesc, callback);
}
///
/// Changes the credentials used to sign requests and retrieve session tokens for admin requests.
///
/// No result delegate as this isn't a blocking method, only possible failure is an invalid region code which will be logged.
///
/// Object containing information about the new credentials and the account
/// Delegate that is called once the function has finished executing
public void ChangeCredentials(ChangeCredentialsDesc changeCredentialsDesc, Action callback)
{
Call(Feature.ChangeCredentials, changeCredentialsDesc, callback);
}
///
/// Checks whether the passed in ID has invalid characters or length.
///
/// No result delegate as this isn't a blocking method.
///
/// achievement identifier to validate
/// Delegate that is called once the function has finished executing
public void IsAchievementIdValid(string achievementId, Action callback)
{
Call(Feature.IsAchievementIdValid, achievementId, callback);
}
///
/// Gets the AWS CloudFront url which all achievement icons for this game/environment can be accessed from.
///
/// Result status codes returned in the callback function (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
///
/// Delegate that is called once the function has finished executing
public void GetAchievementIconBaseUrl(Action callback)
{
Call(Feature.GetAchievementIconsBaseUrl, callback);
}
}
}