Example #1
0
        public async Task <Response> SendAsync(Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var requestContent = FormatMessage.GetRequestContent(message);

            return(await SendAsync(requestContent));
        }
Example #2
0
        private async Task <Response> SendAsync(HttpContent content)
        {
            var response = await _httpClient.PostAsync(EndpointUrl, content);

            Response result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                result = await FormatMessage.GetResponseContentAsync(response);
            }
            else
            {
                result = new Response(response.StatusCode, response.ReasonPhrase);
            }
            return(result);
        }
Example #3
0
        public async Task <Response> SendAsync(string json)
        {
            if (!isValidJsonSyntax(json))
            {
                throw new ArgumentException("nameof(json) must be a valid JSON");
            }

            if (string.IsNullOrWhiteSpace(json))
            {
                throw new ArgumentNullException(nameof(json));
            }

            var requestContent = FormatMessage.GetRequestContent(json);

            return(await SendAsync(requestContent));
        }