public void SendText() { var recipient1 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; var recipient2 = new TextRecipient { Message = "msg", PhoneNumber = "12132212384" }; var recipients = new List<TextRecipient> { recipient1, recipient2 }; IList<CallfireApiClient.Api.CallsTexts.Model.Text> texts = Client.TextsApi.Send(recipients, null, "items(id,fromNumber,state)"); Console.WriteLine("Texts: " + texts); Assert.AreEqual(2, texts.Count); Assert.NotNull(texts[0].Id); Assert.IsNull(texts[0].CampaignId); Assert.IsTrue(StateType.READY == texts[0].State || StateType.FINISHED == texts[0].State); recipient1.Message = null; var request = new SendTextsRequest { Recipients = recipients, CampaignId = 7415135003, DefaultMessage = "DefaultLiveMessage", Fields = "items(id,fromNumber,state)" }; texts = Client.TextsApi.Send(request); CallfireApiClient.Api.CallsTexts.Model.Text text = Client.TextsApi.Get((long)texts[0].Id); Assert.AreEqual(text.Message, "DefaultLiveMessage"); }
public void SendTexts() { string requestJson = GetJsonPayload("/callstexts/textsApi/request/sendTexts.json"); string responseJson = GetJsonPayload("/callstexts/textsApi/response/sendTexts.json"); var restRequest = MockRestResponse(responseJson); TextRecipient r1 = new TextRecipient { PhoneNumber = "12135551100", Message = "Hello World!" }; TextRecipient r2 = new TextRecipient { PhoneNumber = "12135551101", Message = "Testing 1 2 3" }; IList<CallfireApiClient.Api.CallsTexts.Model.Text> texts = Client.TextsApi.Send(new List<TextRecipient> { r1, r2 }); Assert.That(Serializer.Serialize(new ListHolder<CallfireApiClient.Api.CallsTexts.Model.Text>(texts)), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); texts = Client.TextsApi.Send(new List<TextRecipient> { r1, r2 }, 100, FIELDS); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("campaignId") && p.Value.Equals("100"))); }