public void BuildXmlWithoutRequiredInput()
 {
     try
     {
         var vb = new VoiceBroadcast();
         var xml = vb.ToXml();
     }
     catch (FormatException)
     {
         Assert.IsTrue(true);
     }
     catch (ArgumentException)
     {
         Assert.IsTrue(true);
     }
 }
        public void BuildXmlWithRequiredInput()
        {
            var vb = new VoiceBroadcast();
            vb.SendTimeUTC = DateTime.UtcNow;
            vb.StopTimeUTC = DateTime.UtcNow.Date.AddHours(20);
            vb.RestartTimeUTC = DateTime.UtcNow.Date.AddDays(1).AddHours(8);
            vb.List = ContactList.FromText("requiredList.csv", "phone\r\n5555555555");
            vb.Documents = new List<Document>()
            {
                VoiceDocument.FromText("live01.txt", "this is a live voice call.", VoiceDocumentType.Live),
            };

            var xml = vb.ToXml();
            Assert.IsNotNull(xml);
            XDocument xDoc = XDocument.Parse(xml);
            Assert.IsNotNull(xDoc);
        }
Esempio n. 3
0
        public static void Execute()
        {
            Console.WriteLine("Alert Solutions API Client TemplateDemo\n");

            Template template = Template.FromFile("Location\\Of\\Wav\\File.wav");

            // change these values to your API login
            // change your login details in the app config file
            var user = "";
            var password = "";
            var url = "http://weblaunch.blifax.com/postapi";

            var templateClient = new ApiClient(url, user, password);

            Console.WriteLine("\nPress any key to submit template.");
            Console.ReadLine();

            TemplateResponse response = templateClient.SendTemplates(template);

            var orderClient = new ApiClient(url, user, password);

            var vb = new VoiceBroadcast();
            vb.BillCode = "APIClient Demo";
            vb.ProjectCode = "APIClient Demo";
            vb.CallerID = "5555555555";
            vb.List = ContactList.FromFile("Files\\ContactList.csv");
            vb.VoiceHeader = "phone";
            vb.ThrottleType = VoiceBroadcast.VoiceThrottleType.MaximumCalls;
            vb.ThrottleNumber = 2;
            vb.Documents = new List<Document>()
            {
                //VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Live),
                VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Message),
            };

            OrderResponse broadcastResponse = orderClient.LaunchBroadcast(vb);

            Console.WriteLine(broadcastResponse.RequestErrorMessage);
        }
Esempio n. 4
0
 public static IOrder CreateVL()
 {
     var vl = new VoiceBroadcast();
     //vt.CallScript = CallScript.FromString("");
     //vt.CallScript = CallScript.FromFile("");
     vl.BillCode = "PostAPIClient Refactor Test";
     vl.ProjectCode = "PostAPIClient Refactor Test";
     vl.CallerID = "4015555555";
     vl.List = ContactList.FromFile("TestFiles\\ContactList.csv");
     vl.VoiceHeader = "phone";
     vl.ThrottleType = VoiceBroadcast.VoiceThrottleType.MaximumCalls;
     vl.ThrottleNumber = 2;
     vl.Documents = new List<Document>()
     {
         VoiceDocument.FromFile("TestFiles\\VoiceMessage.txt", VoiceDocumentType.Live),
         VoiceDocument.FromFile("TestFiles\\VoiceMessage.txt", VoiceDocumentType.Message),
     };
     return vl;
 }
Esempio n. 5
0
        public static void Execute()
        {
            Console.WriteLine("Alert Solutions API Client FullDemo\n");

            // ===========================================
            //              BROADCASTS
            // ===========================================

            List<IBroadcast> broadcasts = new List<IBroadcast>();

            // EMAIL BROADCAST
            var eb = new EmailBroadcast();
            eb.BillCode = "APIClient Demo";
            eb.ProjectCode = "APIClient Demo";
            eb.DisplayName = "AlertSolutions";
            eb.EmailSubject = "Alert Solutions API Client Demo";
            eb.EmailFrom = "*****@*****.**";
            eb.EmailReplyTo = "*****@*****.**";
            eb.Attachments = new List<Attachment>() { Attachment.FromFile("Files\\Attachment.txt") };
            eb.List = ContactList.FromFile("Files\\ContactList.csv");
            eb.EmailHeader = "email";
            eb.Proofs = new List<string>() { "*****@*****.**" };
            // can use either Text or HTML
            eb.HtmlBody = HtmlBody.FromFile("Files\\Email.html");
            eb.TextBody = TextBody.FromFile("Files\\Email.txt");

            broadcasts.Add(eb);

            // SMS BROADCAST
            var sb = new SMSBroadcast();
            sb.BillCode = "APIClient Demo";
            sb.ProjectCode = "APIClient Demo";
            sb.ShortCode = "77811";
            sb.TextMessage = TextMessage.FromFile("Files\\TextMessage.txt");
            sb.List = ContactList.FromFile("Files\\ContactList.csv");
            sb.SMSHeader = "phone";
            sb.Proofs = new List<string>() { "5555555555" };

            broadcasts.Add(sb);

            // VOICE BROADCAST
            var vb = new VoiceBroadcast();
            vb.BillCode = "APIClient Demo";
            vb.ProjectCode = "APIClient Demo";
            vb.CallerID = "5555555555";
            vb.List = ContactList.FromFile("Files\\ContactList.csv");
            vb.VoiceHeader = "phone";
            vb.ThrottleType = VoiceBroadcast.VoiceThrottleType.MaximumCalls;
            vb.ThrottleNumber = 2;
            // can be told to load an xml file, or be given the xml as text
            //vt.CallScript = CallScript.FromString("");
            //vt.CallScript = CallScript.FromFile("");
            vb.Documents = new List<Document>()
            {
                //VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Live),
                VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Message),
            };

            broadcasts.Add(vb);

            // FAX BROADCAST
            var fb = new FaxBroadcast();
            fb.BillCode = "APIClient Demo";
            fb.ProjectCode = "APIClient Demo";
            fb.FaxFrom = "john doe";
            fb.List = ContactList.FromFile("Files\\FaxList.csv");
            fb.FaxHeader = "faxnumber";
            fb.Dedup = true;
            fb.DocumentStyle = "Letter";
            fb.Documents = new List<Document>()
            {
                Document.FromFile("Files\\FaxText.txt"),
            };

            broadcasts.Add(fb);

            // ===========================================
            //             MESSAGES
            // ===========================================

            List<IMessage> messages = new List<IMessage>();

            // EMAIL MESSAGE
            var em = new EmailMessage();
            em.EmailTo = "*****@*****.**";
            em.DisplayName = "AlertSolutions";
            em.EmailSubject = "Alert Solutions API Client Demo";
            em.EmailFrom = "*****@*****.**";
            em.EmailReplyTo = "*****@*****.**";
            em.Attachments = new List<Attachment>() { Attachment.FromFile("Files\\Attachment.txt") };
            // can use either Text or HTML
            em.TextBody = TextBody.FromFile("Files\\Email.txt");
            //em.EmailBody = HtmlBody.FromFile("Files\\Email.html");

            messages.Add(em);

            // SMS MESSAGE
            var sm = new SMSMessage();
            sm.Number = "5555555555";
            sm.ShortCode = "77811"; // shared Alert Solutions Shortcode
            sm.TextMessage = TextMessage.FromFile("Files\\TextMessage.txt");

            messages.Add(sm);

            // VOICE MESSAGE
            var vm = new VoiceMessage();
            //vt.CallScript = CallScript.FromString("");
            //vt.CallScript = CallScript.FromFile("");
            vm.Phone = "5555555555";
            vm.CallerID = "5555555555";
            vm.Documents = new List<Document>()
            {
                VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Live),
                VoiceDocument.FromFile("Files\\VoiceMessage.txt", VoiceDocumentType.Message),
            };

            messages.Add(vm);

            // FAX MESSAGE
            var fm = new FaxMessage();
            fm.FaxFrom = "john doe";
            fm.FaxNumber = "4014271405";
            fm.DocumentStyle = "Letter";
            fm.Documents = new List<Document>()
            {
                Document.FromFile("Files\\FaxText.txt"),
            };

            messages.Add(fm);

            // ===========================================
            //             LAUNCH
            // ===========================================

            // change these values to your API login
            var user = "******";
            var password = "******";
            var url = "http://weblaunch.blifax.com/postapi";

            // create the client
            var client = new ApiClient(url, user, password);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("There is a pause of about 10 seconds before getting a report.");
            Console.ForegroundColor = ConsoleColor.Gray;

            // launch the broadcasts
            foreach (var broadcast in broadcasts)
            {
                Console.Write("\n\nSending " + broadcast.TypeOfOrder + ": ");

                var response = client.LaunchBroadcast(broadcast);

                Console.Write("** " + response.RequestResult + " **");
                Console.Write(response.RequestResult != RequestResultType.Error ?
                    " OrderID: " + response.OrderID : "Error: " + response.RequestErrorMessage);

                // wait for broadcast before request report
                System.Threading.Thread.Sleep(12000);
                var report = client.GetOrderReport(response, ReportReturnType.XML);

                Console.Write("\nReport:\n" + report.ReportData);
            }

            // launch the messages
            foreach (var message in messages)
            {
                Console.Write("\n\nSending " + message.TypeOfOrder + ": ");

                var response = client.LaunchMessage(message);

                Console.Write("** " + response.RequestResult + " **");
                Console.Write(response.RequestResult != RequestResultType.Error ?
                    " OrderID: " + response.OrderID  + " TransID: " + response.Unqid : "Error: " + response.RequestErrorMessage);

                // wait for message before request report
                System.Threading.Thread.Sleep(10000);
                var report = client.GetOrderReport(response, ReportReturnType.XML);

                Console.Write("\nReport:\n" + report.ReportData);
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
 public void ConstructorTest()
 {
     var voiceBroadcast = new VoiceBroadcast();
     Assert.IsNotNull(voiceBroadcast);
 }
        public void XmlOutputAllFieldsTest()
        {
            var vb = new VoiceBroadcast();
            vb.SendTimeUTC = DateTime.UtcNow;
            vb.StopTimeUTC = DateTime.UtcNow.Date.AddHours(20);
            vb.StopTimeUTC = DateTime.UtcNow.Date.AddDays(1).AddHours(8);
            vb.BillCode = "BC";
            vb.ProjectCode = "PC";
            vb.CallerID = "4015555555";
            vb.ThrottleType = VoiceBroadcast.VoiceThrottleType.MaximumCalls;
            vb.ThrottleNumber = 2;
            vb.List = ContactList.FromText("requiredList.csv", "phone\r\n5555555555");
            vb.VoiceHeader = "phone";
            vb.Documents = new List<Document>()
            {
                VoiceDocument.FromText("live01.txt", "this is a live voice call.", VoiceDocumentType.Live),
            };

            var xml = vb.ToXml();
            Assert.IsNotNull(xml);
            XDocument xDoc = XDocument.Parse(xml);
            Assert.IsNotNull(xDoc);

            // make sure the necessary voice fields are there (as per postAPI documentation)
            VerifyFieldsExist(xDoc);

            // make sure the necessary VALUES exist in those fields (as per postAPI documentation)
            var orderTag = xDoc.Root.Elements("Order").FirstOrDefault();
            Assert.IsTrue(orderTag.FirstAttribute.Value == "VL");
            Assert.IsTrue(orderTag.Element("Project").Value == "PC");
            Assert.IsTrue(orderTag.Element("BillCode").Value == "BC");
            Assert.IsTrue(orderTag.Element("AutoLaunch").Value == "Yes");
            Assert.IsTrue(DateTime.Parse(orderTag.Element("Date").Value) == DateTime.UtcNow.Date);
            Assert.IsTrue(DateTime.Parse(orderTag.Element("Time").Value).Minute == DateTime.UtcNow.Minute);
            // 3 1 0-4 Documentation says StopTime, but I think the name changed since then.
            Assert.IsNotNull(DateTime.Parse(orderTag.Element("StopDateTime").Value));
            Assert.IsNotNull(DateTime.Parse(orderTag.Element("RestartTime").Value));
            Assert.IsTrue(orderTag.Element("Restart").Value == "No");
            Assert.IsTrue(Enumerable.Range(0, 5).Contains(int.Parse(orderTag.Element("NumberOfRedials").Value)));
            Assert.IsTrue(Enumerable.Range(0, 3).Contains(int.Parse(orderTag.Element("NumberOfResends").Value)));
            Assert.IsNotNull(orderTag.Element("CallerID").Value);
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotOne").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotTwo").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotThree").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotFour").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotFive").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotSix").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotSeven").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotEight").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotNine").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotPound").Value));
            Assert.IsTrue(string.IsNullOrEmpty(orderTag.Element("HotStar").Value));
            Assert.IsNotNull(string.IsNullOrEmpty(orderTag.Element("ThrType").Value));
            Assert.IsNotNull(string.IsNullOrEmpty(orderTag.Element("ThrNum").Value));

            // TODO : make tests for these conditional values and their output
            // conditionals
            Assert.IsNotNull(orderTag.Element("ListID"));
            Assert.IsNotNull(orderTag.Element("ListName"));
            Assert.IsNotNull(orderTag.Element("ListBinary"));
            Assert.IsNotNull(orderTag.Element("VoiceHeader"));

            // documents
            Assert.IsNotNull(orderTag.Element("Documents"));
            Assert.IsTrue(orderTag.Element("Documents").Elements().Count() == 1);
        }