Imgur.API.Endpoints.Impl.AccountEndpoint.GetNotificationsAsync C# (CSharp) Method

GetNotificationsAsync() public method

Returns all of the reply notifications for the user. OAuth authentication required.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetNotificationsAsync ( bool newNotifications = true ) : Task
newNotifications bool false for all notifications, true for only non-viewed notification. Default is true.
return Task
        public async Task<INotifications> GetNotificationsAsync(bool newNotifications = true)
        {
            if (ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var newNotificationsValue = $"{newNotifications}".ToLower();
            var url = $"account/me/notifications?new={newNotificationsValue}";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var notifications = await SendRequestAsync<Notifications>(request).ConfigureAwait(false);
                return notifications;
            }
        }
    }

Usage Example

コード例 #1
0
        public async Task GetNotificationsAsync_IsNotNull()
        {
            var client = new ImgurClient(ClientId, ClientSecret, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var notifications = await endpoint.GetNotificationsAsync(false);

            Assert.IsNotNull(notifications);
            Assert.IsTrue(notifications.Messages.Any());
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.AccountEndpoint::GetNotificationsAsync