/// <summary> /// Updates the account settings for a given user. OAuth authentication required. /// </summary> /// <param name="bio">The biography of the user, is displayed in the gallery profile page.</param> /// <param name="publicImages">Set the users images to private or public by default.</param> /// <param name="messagingEnabled">Allows the user to enable / disable private messages.</param> /// <param name="albumPrivacy">Sets the default privacy level of albums the users creates.</param> /// <param name="acceptedGalleryTerms">The user agreement to the Imgur Gallery terms.</param> /// <param name="username">A valid Imgur username (between 4 and 63 alphanumeric characters).</param> /// <param name="showMature">Toggle display of mature images in gallery list endpoints.</param> /// <param name="newsletterSubscribed">Toggle subscription to email newsletter.</param> /// <exception cref="ArgumentNullException"> /// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// </exception> /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception> /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception> /// <returns></returns> public Basic <bool> UpdateAccountSettings( string bio = null, bool?publicImages = null, bool?messagingEnabled = null, AlbumPrivacy?albumPrivacy = null, bool?acceptedGalleryTerms = null, string username = null, bool?showMature = null, bool?newsletterSubscribed = null) { if (ApiClient.OAuth2Token == null) { throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage); } const string url = "account/me/settings"; using ( var request = AccountRequestBuilder.UpdateAccountSettingsRequest(url, bio, publicImages, messagingEnabled, albumPrivacy, acceptedGalleryTerms, username, showMature, newsletterSubscribed)) { var httpResponse = HttpClient.SendAsync(request).Result; var jsonString = httpResponse.Content.ReadAsStringAsync().Result; var output = Newtonsoft.Json.JsonConvert.DeserializeObject <Basic <bool> >(httpResponse.Content.ReadAsStringAsync().Result.ToString()); return(output); } }
/// <summary> /// Updates the account settings for a given user. OAuth authentication required. /// </summary> /// <param name="bio">The biography of the user, is displayed in the gallery profile page.</param> /// <param name="publicImages">Set the users images to private or public by default.</param> /// <param name="messagingEnabled">Allows the user to enable / disable private messages.</param> /// <param name="albumPrivacy">Sets the default privacy level of albums the users creates.</param> /// <param name="acceptedGalleryTerms">The user agreement to the Imgur Gallery terms.</param> /// <param name="username">A valid Imgur username (between 4 and 63 alphanumeric characters).</param> /// <param name="showMature">Toggle display of mature images in gallery list endpoints.</param> /// <param name="newsletterSubscribed">Toggle subscription to email newsletter.</param> /// <exception cref="ArgumentNullException"> /// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// </exception> /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception> /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception> /// <returns></returns> public async Task <bool> UpdateAccountSettingsAsync( string bio = null, bool?publicImages = null, bool?messagingEnabled = null, AlbumPrivacy?albumPrivacy = null, bool?acceptedGalleryTerms = null, string username = null, bool?showMature = null, bool?newsletterSubscribed = null) { if (ApiClient.OAuth2Token == null) { throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage); } const string url = "account/me/settings"; using ( var request = AccountRequestBuilder.UpdateAccountSettingsRequest(url, bio, publicImages, messagingEnabled, albumPrivacy, acceptedGalleryTerms, username, showMature, newsletterSubscribed)) { var updated = await SendRequestAsync <bool>(request).ConfigureAwait(false); return(updated); } }
public void UpdateAccountSettingsRequest_WithUrlNull_ThrowsArgumentNullException() { var requestBuilder = new AccountRequestBuilder(); var exception = Record.Exception(() => AccountRequestBuilder.UpdateAccountSettingsRequest(null)); Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); var argNullException = (ArgumentNullException)exception; Assert.Equal(argNullException.ParamName, "url"); }
public async Task UpdateAccountSettingsRequest_AreEqual() { var client = new ImgurClient("123", "1234"); var requestBuilder = new AccountRequestBuilder(); var url = $"{client.EndpointUrl}account/me/settings"; var request = requestBuilder.UpdateAccountSettingsRequest( url, "BioTest", true, true, AlbumPrivacy.Public, true, "Bob2", true, true); Assert.IsNotNull(request); var expected = "public_images=true&messaging_enabled=true&album_privacy=public&accepted_gallery_terms=true&show_mature=true&newsletter_subscribed=true&username=Bob2&bio=BioTest"; Assert.AreEqual(expected, await request.Content.ReadAsStringAsync()); Assert.AreEqual("https://api.imgur.com/3/account/me/settings", request.RequestUri.ToString()); Assert.AreEqual(HttpMethod.Post, request.Method); }
public void UpdateAccountSettingsRequest_WithUrlNull_ThrowsArgumentNullException() { var requestBuilder = new AccountRequestBuilder(); requestBuilder.UpdateAccountSettingsRequest(null); }