Ejemplo n.º 1
0
 public async Task<decimal> GetCreditAsync(SmsParameter parameter)
 {
     parameter.Operator = SmsOperatorType.Credit.Name();
     var request = new RestRequest(Method.POST);
     SetHeaders(request);
     request.AddParameter("undefined", parameter.Stringify(), ParameterType.RequestBody);
     var response = await Client.ExecuteTaskAsync(request);
     var data = JsonConvert.DeserializeObject<List<decimal>>(response.Content);
     var status = data.Count > 0 && data[0] == 0;
     return status ? data[1] : 0;
 }
Ejemplo n.º 2
0
 public async Task<long> SendSmsAsync(SmsParameter parameter)
 {
     parameter.To = parameter.To.Select(x => Regex.Replace(x, @".+(?=\d{10})", "")).Where(x => Regex.IsMatch(x, @"9\d{9}")).ToArray();
     if (!parameter.To.Any())
         return 0;
     parameter.Operator = SmsOperatorType.Send.Name();
     var request = new RestRequest(Method.POST);
     SetHeaders(request);
     request.AddParameter("undefined", parameter.Stringify(), ParameterType.RequestBody);
     var response = await Client.ExecuteTaskAsync(request);
     var data = JsonConvert.DeserializeObject<List<long>>(response.Content);
     var status = data.Count > 0 && data[0] == 0;
     return status ? data[1] : 0;
 }