public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50\",\"last_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50\",\"next_page_uri\": null,\"num_pages\": 1,\"outgoing_caller_ids\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"Fri, 21 Aug 2009 00:11:24 +0000\",\"date_updated\": \"Fri, 21 Aug 2009 00:11:24 +0000\",\"friendly_name\": \"(415) 867-5309\",\"phone_number\": \"+141586753096\",\"sid\": \"PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}],\"page\": 0,\"page_size\": 50,\"previous_page_uri\": null,\"start\": 0,\"total\": 1,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json\"}"
                         ));

            var response = OutgoingCallerIdResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50\",\"last_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json?Page=0&PageSize=50\",\"next_page_uri\": null,\"num_pages\": 1,\"outgoing_caller_ids\": [],\"page\": 0,\"page_size\": 50,\"previous_page_uri\": null,\"start\": 0,\"total\": 1,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json\"}"
                         ));

            var response = OutgoingCallerIdResource.Read(client: twilioRestClient);

            Assert.NotNull(response);
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var outgoingCallerIds = OutgoingCallerIdResource.Read();

        foreach (var record in outgoingCallerIds)
        {
            Console.WriteLine(record.Sid);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var callerIds = OutgoingCallerIdResource.Read(
            phoneNumber: new PhoneNumber("+14158675310"));

        foreach (var callerId in callerIds)
        {
            Console.WriteLine(callerId.PhoneNumber);
        }
    }
Exemple #5
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken  = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var callerIds = OutgoingCallerIdResource.Read();

        foreach (var callerId in callerIds)
        {
            Console.WriteLine(callerId.PhoneNumber);
        }
    }
Exemple #6
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var outgoingCallerIds = OutgoingCallerIdResource.Read(limit: 20);

        foreach (var record in outgoingCallerIds)
        {
            Console.WriteLine(record.Sid);
        }
    }
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var outgoingCallerIds = OutgoingCallerIdResource.Read(
            phoneNumber: new Twilio.Types.PhoneNumber("+14158675310"),
            pathAccountSid: "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        foreach (var record in outgoingCallerIds)
        {
            Console.WriteLine(record.Sid);
        }
    }
Exemple #8
0
        public static bool GetNumber(string Number)
        {
            var twilio = TDSettings.DefaultTwilio();

            Twilio.TwilioClient.Init(twilio.ID, twilio.Key);

            var callerIds = OutgoingCallerIdResource.Read(
                phoneNumber: new PhoneNumber(twilio.OtherInformation));

            foreach (var callerId in callerIds)
            {
                if (callerId.PhoneNumber.ToString() == Number)
                {
                    return(true);
                }
            }
            return(false);
        }
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Api,
                "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OutgoingCallerIds.json",
                ""
                );

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                OutgoingCallerIdResource.Read(client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Exemple #10
0
 public void InitPhoneContact()
 {
     while (true)
     {
         bool completedPhoneInit = false;
         PrintBanner();
         var count    = 0;
         var attempts = 0;
         while (completedPhoneInit == false)
         {
             PrintBanner();
             if (attempts == 0)
             {
                 Console.WriteLine("Please enter your Phone Number to be contacted via the Hxngry Service in the following format: +1###-###-####\n");
             }
             else
             {
                 Console.WriteLine("The previous phone number entry was incorrect. Please check the formatting of the entry.");
                 Console.WriteLine("The format can be either of the following: \"+1###-###-####\" OR \"###-###-####\".\n");
             }
             var phone = Console.ReadLine();
             completedPhoneInit = this.SetPhoneContact(phone);
             try
             {
                 var outgoingCallerIds = OutgoingCallerIdResource.Read(phoneNumber: new Twilio.Types.PhoneNumber(this.user.Phone));
                 count = 0;
                 foreach (var record in outgoingCallerIds)
                 {
                     count++;
                 }
                 Console.WriteLine("COUNT: " + count);
             }
             catch (Exception e)
             {
                 attempts++;
                 continue;
             }
             attempts++;
             break;
         }
         Console.WriteLine("COUNT: " + count);
         PrintBanner();
         if (count == 0)
         {
             Console.WriteLine("We must verify your number with Hxngry in order to send SMS messages.\nPlease follow the instructions provided on screen.\n\n Press any key to continue...");
             Console.ReadKey();
             VerifyCallerID();
         }
         else
         {
             Console.WriteLine("Your number (" + this.user.Phone + ") is already verified with us, thank you for returning to Hxngry.");
         }
         Console.WriteLine("\n[Space Bar] To continue\n[R] To Resubmit Phone Number\n[Q] To Quit");
         ConsoleKeyInfo userChoice = Console.ReadKey();
         if (userChoice.KeyChar == ' ')
         {
             break;
         }
         else if (userChoice.KeyChar == 'r' || userChoice.KeyChar == 'R')
         {
             continue;
         }
         else if (userChoice.KeyChar == 'q' || userChoice.KeyChar == 'Q')
         {
             Environment.Exit(0);
         }
     }
 }
Exemple #11
0
 private static OutgoingCallerIdResource GetVoicePhoneResource()
 {
     return(OutgoingCallerIdResource.Read().FirstOrDefault());
 }