/// <summary> /// Updates a user setting with the provided setting key of the account bound to the provided <see cref="OAuthSession"/>. /// </summary> /// <param name="oAuthSession">The <see cref="OAuthSession"/> to use for authentication.</param> /// <param name="settingKey">The setting key of the user setting to update.</param> /// <param name="payload">The payload for the request.</param> internal static async Task UpdateUserSetting(OAuthSession oAuthSession, SettingKey settingKey, UpdateUserSetting payload) { // Get the value of our enum. We're using enums for data validation purposes and to prevent erroneous responses. var setting = settingKey.GetAttribute<ValueAttribute>().Value; // We're using a using statement so that the initialised client is disposed of when the code block is exited. using var client = new WebClient { Headers = { // This is so Epic Games' API knows what kind of data we're providing. [HttpRequestHeader.ContentType] = "application/json", // Set the Authorization header to the access token from the provided OAuthSession. [HttpRequestHeader.Authorization] = $"bearer {oAuthSession.AccessToken}" } }; // Use our request helper to make a PUT request. await client.PutDataAsync(Endpoints.Channels.Setting(oAuthSession.AccountId, setting), JsonConvert.SerializeObject(payload)).ConfigureAwait(false); }
/// <inheritdoc cref="ChannelsService.UpdateUserSetting"/> public async Task UpdateUserSetting(SettingKey settingKey, UpdateUserSetting payload) => await ChannelsService.UpdateUserSetting(this, settingKey, payload);