public static async Task <string> Order(this SMSClient client, string pool, string service, string country) { try { HttpResponseMessage post = await client.HttpClient.Send("order.php?api_key=" + client.Api_key + "&pool=" + pool + "&service=" + service + "&country=" + country); string results = await post.Content.ReadAsStringAsync(); if (results.Contains("Please fill in your API key.")) { return("Please fill in your API key."); } SMSOrderExtension result = JsonConvert.DeserializeObject <SMSOrderExtension>(results); if (result.Message != null) { return(result.Message); } if (result.OrderID != null) { client.Order_ID = result.OrderID; return(result.Number); } return("Failed to order number."); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public static async Task <string> Cancel(this SMSClient client, string order_id) { try { HttpResponseMessage post = await client.HttpClient.Send("check.php?api_key=" + client.Api_key + "&orderid=" + order_id + "&method=CANCEL"); string results = await post.Content.ReadAsStringAsync(); if (results.Contains("Please fill in your API key.")) { return("Please fill in your API key."); } SMSCancelExtension result = JsonConvert.DeserializeObject <SMSCancelExtension>(results); if (result.Message != null) { return(result.Message); } else { return("Failed to cancel order."); }; } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public SMSHttpClient(SMSClient smsClient) { _smsClient = smsClient; }