#if !DISABLE_PLAYFABENTITY_API && !DISABLE_PLAYFAB_STATIC_API
using System;
using System.Collections.Generic;
using PlayFab.EventsModels;
using PlayFab.Internal;
namespace PlayFab
{
///
/// Write custom PlayStream and Telemetry events for any PlayFab entity. Telemetry events can be used for analytic,
/// reporting, or debugging. PlayStream events can do all of that and also trigger custom actions in near real-time.
///
public static class PlayFabEventsAPI
{
static PlayFabEventsAPI() {}
///
/// Verify entity login.
///
public static bool IsEntityLoggedIn()
{
return PlayFabSettings.staticPlayer.IsEntityLoggedIn();
}
///
/// Clear the Client SessionToken which allows this Client to call API calls requiring login.
/// A new/fresh login will be required after calling this.
///
public static void ForgetAllCredentials()
{
PlayFabSettings.staticPlayer.ForgetAllCredentials();
}
///
/// Creates a new telemetry key for the title.
///
public static void CreateTelemetryKey(CreateTelemetryKeyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/CreateTelemetryKey", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Deletes a telemetry key configured for the title.
///
public static void DeleteTelemetryKey(DeleteTelemetryKeyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/DeleteTelemetryKey", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Gets information about a telemetry key configured for the title.
///
public static void GetTelemetryKey(GetTelemetryKeyRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/GetTelemetryKey", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Lists all telemetry keys configured for the title.
///
public static void ListTelemetryKeys(ListTelemetryKeysRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/ListTelemetryKeys", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Sets a telemetry key to the active or deactivated state.
///
public static void SetTelemetryKeyActive(SetTelemetryKeyActiveRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/SetTelemetryKeyActive", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Write batches of entity based events to PlayStream. The namespace of the Event must be 'custom' or start with 'custom.'.
///
public static void WriteEvents(WriteEventsRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Write batches of entity based events to as Telemetry events (bypass PlayStream). The namespace must be 'custom' or start
/// with 'custom.'
///
public static void WriteTelemetryEvents(WriteEventsRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteTelemetryEvents", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
///
/// Write batches of entity based events to as Telemetry events (bypass PlayStream) using a Telemetry Key. The namespace must be 'custom' or start
/// with 'custom.'
///
public static void WriteTelemetryEventsWithTelemetryKey(WriteEventsRequest request, Action resultCallback, Action errorCallback, object customData = null, Dictionary extraHeaders = null)
{
var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
var callSettings = PlayFabSettings.staticSettings;
if (!context.IsTelemetryKeyProvided()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must provide a telemetry key to call this method");
PlayFabHttp.MakeApiCall("/Event/WriteTelemetryEvents", request, AuthType.TelemetryKey, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
}
}
}
#endif