Imgur.API.Endpoints.Impl.ConversationEndpoint.GetConversationAsync C# (CSharp) Method

GetConversationAsync() public method

Get information about a specific conversation. Includes messages. 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 GetConversationAsync ( string conversationId, int page = null, int offset = null ) : Task
conversationId string The conversation id.
page int /// Page of message thread. Starting at 1 for the most recent 25 messages and counting upwards. Default: /// null ///
offset int Additional offset in current page.
return Task
        public async Task<IConversation> GetConversationAsync(string conversationId, int? page = null,
            int? offset = null)
        {
            if (string.IsNullOrWhiteSpace(conversationId))
                throw new ArgumentNullException(nameof(conversationId));

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

            var url = $"conversations/{conversationId}/{page ?? 1}/{offset ?? 0}";

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

Usage Example

コード例 #1
0
        public async Task GetConversationAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new ConversationEndpoint(client);

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