示例#1
0
        public void SendTextsUsingRequest()
        {
            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"
            };

            var request = new SendTextsRequest
            {
                Recipients = new List <TextRecipient> {
                    r1, r2
                },
                CampaignId     = 100,
                Fields         = FIELDS,
                DefaultMessage = "defaultMessage"
            };

            IList <CallfireApiClient.Api.CallsTexts.Model.Text> texts = Client.TextsApi.Send(request);

            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));
            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")));
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("defaultMessage") && p.Value.Equals("defaultMessage")));
        }
        public void SendText()
        {
            var recipient1 = new TextRecipient {
                Message = "msg", PhoneNumber = "12132212384"
            };
            var recipient2 = new TextRecipient {
                Message = "msg", PhoneNumber = "12132212384", FromNumber = "12132041238"
            };
            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)",
                StrictValidation = true
            };

            texts = Client.TextsApi.Send(request);
            CallfireApiClient.Api.CallsTexts.Model.Text text = Client.TextsApi.Get((long)texts[0].Id);
            Assert.AreEqual(text.Message, "DefaultLiveMessage");
        }
示例#3
0
 public static void Main(string[] args)
 {
     var client     = new CallfireClient("api_login", "api_password");
     var recipient1 = new TextRecipient
     {
         Message     = "Hello World!",
         PhoneNumber = "12135551122"
     };
     var recipient2 = new TextRecipient
     {
         ContactId = 122460000043
     };
     var recipient3 = new TextRecipient
     {
         PhoneNumber = "12135558090",
         Attributes  = new Dictionary <string, string>
         {
             { "custom_external_id", "30005044" },
             { "custom_name", "Alice" }
         },
         Message = "Hello, ${custom_name}!"
     };
     var recipients = new List <TextRecipient> {
         recipient1, recipient2, recipient3
     };
     var request = new SendTextsRequest
     {
         Recipients     = recipients,
         CampaignId     = 4050600003,
         DefaultMessage = "Hello!"
     };
     IList <Text> texts = client.TextsApi.Send(request);
 }
 public static void Main(string[] args)
 {
     var client     = new CallfireClient("api_login", "api_password");
     var recipient1 = new TextRecipient
     {
         Message     = "Hey there",
         PhoneNumber = "12135551100",
         // set custom recipient attributes, they are available only to a single Call/Text
         //  action, do not confuse them with contact fields which are stored with contact
         //  and are available to each Call/Text where contact is attached to
         Attributes = new Dictionary <string, string>
         {
             { "external_user_id", "45450007002" }
         }
     };
     IList <Text> texts = client.TextsApi.Send(new List <TextRecipient> {
         recipient1
     });
 }
 public static void Main(string[] args)
 {
     var client     = new CallfireClient("api_login", "api_password");
     var recipient1 = new TextRecipient
     {
         Message = "Hello ${contact_name}, you have an appointment with Dr. Andrew "
                   + "tomorrow at 3:00 PM, if you need to reschedule please call (855)-555-4477",
         PhoneNumber = "12135551100",
         // set custom recipient attributes, they are available only to a single Call/Text
         //  action, do not confuse them with contact fields which are stored with contact
         //  and are available to each Call/Text where contact is attached to
         Attributes = new Dictionary <string, string>
         {
             { "contact_name", "Alice" },
             { "external_user_id", "45450007002" }
         }
     };
     IList <Text> texts = client.TextsApi.Send(new List <TextRecipient> {
         recipient1
     });
 }