public async Task <SendSmsResponse> SendSmsAsync(SendSmsRequest request) { Contract.Requires(request != null); Contract.Ensures(Contract.Result <Task <SendSmsResponse> >() != null); if (_disposed) { throw new ObjectDisposedException(nameof(MittoHttpApiWrapperAsync)); } HttpResponseMessage httpResponse = null; //if (method == HttpMethod.Get) //{ // httpResponse = await _httpClient.Value.GetAsync(new Uri($"sms.json?{request.ToQueryParameterString()}", UriKind.Relative)); //} //if (method == HttpMethod.Post) //{ var stringContent = JsonConvert.SerializeObject(request, Formatting.None, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); var strContent = new StringContent(stringContent, Encoding.Default, "application/json"); httpResponse = await _httpClient.Value.PostAsync(new Uri("sms", UriKind.Relative), strContent); //} var response = await httpResponse.Content.ReadAsStringAsync(); var sendSmsResponse = JsonConvert.DeserializeObject <SendSmsResponse>(response); return(sendSmsResponse); }
public SendSmsResponse SendSms(SendSmsRequest request) { Contract.Requires(request != null); Contract.Ensures(Contract.Result <SendSmsResponse>() != null); if (_disposed) { throw new ObjectDisposedException(nameof(MittoHttpApiWrapperSync)); } return(_asyncWrapper.Value.SendSmsAsync(request).Result); }