/// <summary>
        /// Updates an existing experiment for a title.
        /// </summary>
        public async Task <PlayFabResult <EmptyResponse> > UpdateExperimentAsync(UpdateExperimentRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            await new PlayFabUtil.SynchronizationContextRemover();

            var requestContext  = request?.AuthenticationContext ?? authenticationContext;
            var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (requestContext.EntityToken == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Experimentation/UpdateExperiment", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <EmptyResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <EmptyResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <EmptyResponse> {
                Result = result, CustomData = customData
            });
        }
예제 #2
0
        /// <summary>
        /// Updates an existing experiment for a title.
        /// </summary>
        public void UpdateExperiment(UpdateExperimentRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (!context.IsEntityLoggedIn())
            {
                throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method");
            }
            PlayFabHttp.MakeApiCall("/Experimentation/UpdateExperiment", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
예제 #3
0
 /// <summary>Snippet for UpdateExperiment</summary>
 public void UpdateExperimentRequestObject()
 {
     // Snippet: UpdateExperiment(UpdateExperimentRequest, CallSettings)
     // Create client
     ExperimentsClient experimentsClient = ExperimentsClient.Create();
     // Initialize request argument(s)
     UpdateExperimentRequest request = new UpdateExperimentRequest
     {
         Experiment = new Experiment(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Experiment response = experimentsClient.UpdateExperiment(request);
     // End snippet
 }
예제 #4
0
        /// <summary>Snippet for UpdateExperimentAsync</summary>
        public async Task UpdateExperimentRequestObjectAsync()
        {
            // Snippet: UpdateExperimentAsync(UpdateExperimentRequest, CallSettings)
            // Additional: UpdateExperimentAsync(UpdateExperimentRequest, CancellationToken)
            // Create client
            ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync();

            // Initialize request argument(s)
            UpdateExperimentRequest request = new UpdateExperimentRequest
            {
                Experiment = new Experiment(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Experiment response = await experimentsClient.UpdateExperimentAsync(request);

            // End snippet
        }