/// <summary> /// Edits existing device defined in OneSignal App. /// </summary> /// <param name="id"> Id of the device </param> /// <param name="options"> Options used to modify attributes of the device. </param> /// <exception cref="Exception"></exception> public async Task EditAsync(string id, DeviceEditOptions options) { var result = await ApiUri.AppendPathSegment($"players/{id}") .WithHeader("Authorization", $"Basic {ApiKey}") .PutJsonAsync(options) .ConfigureAwait(true); }
/// <summary> /// Edits existing device defined in OneSignal App. /// </summary> /// <param name="id"> Id of the device </param> /// <param name="options"> Options used to modify attributes of the device. </param> /// <exception cref="Exception"></exception> public async Task EditAsync(string id, DeviceEditOptions options) { var restRequest = new RestRequest("players/{id}", Method.PUT); restRequest.AddHeader("Authorization", string.Format("Basic {0}", ApiKey)); restRequest.AddUrlSegment("id", id); restRequest.RequestFormat = DataFormat.Json; restRequest.JsonSerializer = new NewtonsoftJsonSerializer(); restRequest.AddBody(options); var restResponse = await RestClient.ExecuteAsync(restRequest).ConfigureAwait(true); if (restResponse.ErrorException != null) { throw restResponse.ErrorException; } }