Exemple #1
0
        public ActionResult ConfrenceCallee(string confrenceFriendlyName)
        {
            string TwilioApiUrl     = "http://5d30045dd6b7.ngrok.io/Home/";
            var    model            = new ResponseModel();
            var    noOfParticipants = HttpContext.Request.Form["SequenceNumber"];
            int    participants     = 0;

            int.TryParse(noOfParticipants, out participants);
            if (HttpContext.Request.Form["StatusCallbackEvent"] == "participant-join" && participants > 1)
            {
                TwilioClient.Init("ACcdbc21ca5ba9fd8ef16087e57fe64cd4", "b9cbe4da5f9760e8ccfccd6c53edd45a");

                var conferences = ConferenceResource.Read(
                    friendlyName: confrenceFriendlyName,
                    status: ConferenceResource.StatusEnum.InProgress,
                    limit: 20
                    );

                string pathConferenceSid = string.Empty;
                foreach (var record in conferences)
                {
                    pathConferenceSid = record.Sid;
                }
                string joinConfrenceCallbackUrl = TwilioApiUrl + "JoinConfrenceCallback";
                var    participant = ConferenceResource.Update(
                    announceUrl: new Uri(joinConfrenceCallbackUrl),
                    pathSid: pathConferenceSid


                    );
                model.StatusCode = 200;
            }
            return(Json(model));
        }
Exemple #2
0
        // this is an endpoint when callee join the conference call in 'JoinConfrence'. I have specified statusCallback in 'JoinConfrence' but this not calling
        // Here I have copied this 'ConfrenceCallee' endpoint code inside 'JoinConfrence' endpoint for play in case 'ConferenceResource.Update' get stuck

        public ActionResult ConfrenceCallee(string confrenceFriendlyName)
        {
            var model            = new ResponseModel();
            var noOfParticipants = HttpContext.Request.Form["SequenceNumber"];
            int participants     = 0;

            int.TryParse(noOfParticipants, out participants);
            if (HttpContext.Request.Form["StatusCallbackEvent"] == "participant-join" && participants > 1)
            {
                TwilioClient.Init(_twilioSettings.TwilioAccountSid, _twilioSettings.TwilioAuthToken);

                var conferences = ConferenceResource.Read(
                    friendlyName: confrenceFriendlyName,
                    status: ConferenceResource.StatusEnum.InProgress,
                    limit: 20
                    );

                string pathConferenceSid = string.Empty;
                foreach (var record in conferences)
                {
                    pathConferenceSid = record.Sid;
                }
                string joinConfrenceCallbackUrl = _twilioSettings.TwilioApiUrl + "JoinConfrenceCallback";
                var    participant = ConferenceResource.Update(
                    announceUrl: new Uri("http://338e35e84b93.ngrok.io/TwilioCall/JoinConfrenceCallback"),
                    pathSid: pathConferenceSid


                    );
                model.StatusCode = 200;
            }
            return(Json(model));
        }
        public void TestReadDateCreatedOnOrAfterResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"conferences\": [{\"status\": \"in-progress\",\"region\": \"jp1\",\"sid\": \"CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_updated\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"date_created\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json\"},\"friendly_name\": \"friendly_name\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null},{\"status\": \"in-progress\",\"region\": \"de1\",\"sid\": \"CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"date_updated\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"date_created\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/Recordings.json\"},\"friendly_name\": \"MyRoom\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null},{\"status\": \"in-progress\",\"region\": \"br1\",\"sid\": \"CFcccccccccccccccccccccccccccccccc\",\"date_updated\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"date_created\": \"Fri, 01 Jan 2021 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc/Recordings.json\"},\"friendly_name\": \"FRIEND\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null}],\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=in-progress&DateCreated%3E=2021-01-01&PageSize=20&Page=0\",\"next_page_uri\": null,\"previous_page_uri\": null,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=in-progress&DateCreated%3E=2021-01-01&PageSize=20&Page=0\",\"page\": 0,\"page_size\": 20,\"start\": 0,\"end\": 2}"
                         ));

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

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

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"conferences\": [{\"status\": \"in-progress\",\"region\": \"jp1\",\"sid\": \"CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_updated\": \"Sat, 03 Jan 2015 11:23:45 +0000\",\"date_created\": \"Sat, 03 Jan 2015 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json\"},\"friendly_name\": \"friendly_name\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null},{\"status\": \"in-progress\",\"region\": \"unknown\",\"sid\": \"CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"date_updated\": \"Fri, 02 Jan 2015 11:23:45 +0000\",\"date_created\": \"Fri, 02 Jan 2015 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/Recordings.json\"},\"friendly_name\": \"friendly_name\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null},{\"status\": \"in-progress\",\"region\": \"us1\",\"sid\": \"CFcccccccccccccccccccccccccccccccc\",\"date_updated\": \"Thu, 01 Jan 2015 11:23:45 +0000\",\"date_created\": \"Thu, 01 Jan 2015 11:23:45 +0000\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc/Participants.json\",\"recordings\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc/Recordings.json\"},\"friendly_name\": \"friendly_name\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFcccccccccccccccccccccccccccccccc.json\",\"api_version\": \"2010-04-01\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"reason_conference_ended\": null,\"call_sid_ending_conference\": null}],\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=in-progress&DateUpdated%3E=2018-11-12&DateUpdated%3C=2018-11-11&DateCreated=2008-01-03&FriendlyName=friendly_name&DateUpdated=2018-11-13&DateCreated%3C=2008-01-01&DateCreated%3E=2008-01-02&PageSize=3&Page=0\",\"next_page_uri\": null,\"previous_page_uri\": null,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=in-progress&DateUpdated%3E=2018-11-12&DateUpdated%3C=2018-11-11&DateCreated=2008-01-03&FriendlyName=friendly_name&DateUpdated=2018-11-13&DateCreated%3C=2008-01-01&DateCreated%3E=2008-01-02&PageSize=3&Page=0&PageToken=PBCFdddddddddddddddddddddddddddddddd\",\"page\": 0,\"page_size\": 3,\"start\": 0,\"end\": 2}"
                         ));

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

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

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"conferences\": [],\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=init&DateUpdated%3E=2018-11-12&DateUpdated%3C=2018-11-11&DateCreated=2008-01-03&FriendlyName=friendly_name&DateUpdated=2018-11-13&DateCreated%3C=2008-01-01&DateCreated%3E=2008-01-02&PageSize=50&Page=0\",\"next_page_uri\": null,\"previous_page_uri\": null,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?Status=init&DateUpdated%3E=2018-11-12&DateUpdated%3C=2018-11-11&DateCreated=2008-01-03&FriendlyName=friendly_name&DateUpdated=2018-11-13&DateCreated%3C=2008-01-01&DateCreated%3E=2008-01-02&PageSize=50&Page=0\",\"page\": 0,\"page_size\": 50,\"start\": 0,\"end\": 0}"
                         ));

            var response = ConferenceResource.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 conferences = ConferenceResource.Read();

        foreach (var record in conferences)
        {
            Console.WriteLine(record.Sid);
        }
    }
Exemple #7
0
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

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

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

            Assert.NotNull(response);
        }
Exemple #8
0
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"conferences\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2010-04-01\",\"date_created\": \"Mon, 22 Aug 2011 20:58:45 +0000\",\"date_updated\": \"Mon, 22 Aug 2011 20:58:46 +0000\",\"friendly_name\": null,\"region\": \"us1\",\"sid\": \"CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"in-progress\",\"subresource_uris\": {\"participants\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants.json\"},\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences/CFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}],\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1&Page=0\",\"next_page_uri\": null,\"page\": 0,\"page_size\": 1,\"previous_page_uri\": null,\"start\": 0,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conferences.json?PageSize=1\"}"
                         ));

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

            Assert.NotNull(response);
        }
Exemple #9
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 conferences = ConferenceResource.Read(limit: 20);

        foreach (var record in conferences)
        {
            Console.WriteLine(record.Sid);
        }
    }
Exemple #10
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 conferences = ConferenceResource.Read();

        foreach (var conference in conferences)
        {
            Console.WriteLine(conference.Status);
        }
    }
Exemple #11
0
    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 conferences = ConferenceResource.Read(
            status: ConferenceResource.StatusEnum.InProgress,
            friendlyName: "MyRoom");

        foreach (var conference in conferences)
        {
            Console.WriteLine(conference.Status);
        }
    }
    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 conferences = ConferenceResource.Read(
            status: ConferenceResource.StatusEnum.InProgress,
            dateCreatedAfter: new DateTime(2009, 07, 06));

        foreach (var conference in conferences)
        {
            Console.WriteLine(conference.Sid);
        }
    }
Exemple #13
0
    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 conferences = ConferenceResource.Read(
            dateCreatedAfter: MarshalConverter.DateTimeFromString("2009-07-06"),
            status: ConferenceResource.StatusEnum.InProgress
            );

        foreach (var record in conferences)
        {
            Console.WriteLine(record.Sid);
        }
    }
Exemple #14
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 conferences = ConferenceResource.Read(
            dateCreated: MarshalConverter.DateTimeFromString("2009-07-06"),
            status: ConferenceResource.StatusEnum.Completed
            );

        foreach (var record in conferences)
        {
            Console.WriteLine(record.Sid);
        }
    }
        public void TestReadRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Api,
                "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Conferences.json",
                ""
                );

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

            try
            {
                ConferenceResource.Read(client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }