Imgur.API.Endpoints.Impl.NotificationEndpoint.GetNotificationAsync C# (CSharp) Method

GetNotificationAsync() public method

Returns the data about a specific notification. 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 GetNotificationAsync ( string notificationId ) : Task
notificationId string The notification id.
return Task
        public async Task<INotification> GetNotificationAsync(string notificationId)
        {
            if (string.IsNullOrWhiteSpace(notificationId))
                throw new ArgumentNullException(nameof(notificationId));

            if (ApiClient.OAuth2Token == null)
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);

            var url = $"notification/{notificationId}";

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

Usage Example

        public async Task GetNotificationAsync_WithIdNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new NotificationEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetNotificationAsync(null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.NotificationEndpoint::GetNotificationAsync