static void Main(string[] args)
    {
        // Find your API Key SID and Secret at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string apiKeySid    = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SID");
        const string apiKeySecret = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SECRET");

        TwilioClient.Init(apiKeySid, apiKeySecret);

        var rules = new[]
        {
            new Dictionary <string, object>()
            {
                { "type", "include" }, { "all", true }
            },
            new Dictionary <string, object>()
            {
                { "type", "exclude" }, { "publisher", "Supervisor" }
            }
        };

        SubscribeRulesResource.Update(
            "RMXXXX",
            "Customer",
            rules);

        Console.WriteLine("Subscribe Rules updated successfully");
    }
    static void Main(string[] args)
    {
        // Find your API Key SID and Secret at twilio.com/console
        const string apiKeySid    = "SKXXXX";
        const string apiKeySecret = "your_api_key_secret";

        TwilioClient.Init(apiKeySid, apiKeySecret);

        var rules = new[]
        {
            new Dictionary <string, object>()
            {
                { "type", "include" }, { "all", true }
            },
            new Dictionary <string, object>()
            {
                { "type", "exclude" }, { "publisher", "Supervisor" }
            }
        };

        SubscribeRulesResource.Update(
            "RMXXXX",
            "Customer",
            rules);

        Console.WriteLine("Subscribe Rules updated successfully");
    }
        public void TestUpdateFiltersResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"participant_sid\": \"PAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"room_sid\": \"RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": null,\"date_updated\": null,\"rules\": [{\"type\": \"exclude\",\"all\": true}]}"
                         ));

            var response = SubscribeRulesResource.Update("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "PAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestUpdateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Video,
                "/v1/Rooms/RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/PAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/SubscribeRules",
                ""
                );

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

            try
            {
                SubscribeRulesResource.Update("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "PAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
    static void Main(string[] args)
    {
        // Find your API Key SID and Secret at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string apiKeySid    = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SID");
        const string apiKeySecret = Environment.GetEnvironmentVariable("TWILIO_API_KEY_SECRET");

        TwilioClient.Init(apiKeySid, apiKeySecret);

        //-------------------------------------------------------------------------------
        //1. At connect time Adam wants to receive all the tracks.
        //   Done by default rule. No further actions required.


        //-------------------------------------------------------------------------------
        //2. After a while, Adam notices his bandwidth consumption is too high and
        //   decides to unsubscribe from all video tracks

        var rules = new []
        {
            new Dictionary <string, object>()
            {
                { "type", "include" }, { "kind", "audio" }
            }
        };

        SubscribeRulesResource.Update(
            "RMXXXX",
            "Adam",
            rules
            );

        Console.WriteLine("Subscribe Rules updated successfully");

        //-------------------------------------------------------------------------------
        //3. Later, a video screenshare track with SID MTXXXX is published to the room
        //   and Adam subscribes to it.

        var rules = new []
        {
            new Dictionary <string, object>()
            {
                { "type", "include" }, { "kind", "audio" }
            },
            new Dictionary <string, object>()
            {
                { "type", "include" }, { "track" = "MTXXXX" }
            }
        };

        SubscribeRulesResource.Update(
            "RMXXXX",
            "Adam",
            rules
            );

        Console.WriteLine("Subscribe Rules updated successfully");


        //-------------------------------------------------------------------------------
        //4. John, another participant, is in a noisy place and his audio track is
        //   annoying. Adam decides to unsubscribe from it.

        var rules = new []
        {
            new Dictionary <string, object> ()
            {
                { "type", "include" }, { "kind", "audio" }
            },
            new Dictionary <string, object> ()
            {
                { "type", "include" }, { "track", "MTXXXX" }
            },
            new Dictionary <string, object>()
            {
                { "type", "exclude" }, { "publisher", "John" }, { "kind", "audio" }
            }
        };

        SubscribeRulesResource.Update(
            "RMXXXX",
            "Adam",
            rules
            );

        Console.WriteLine("Subscribe Rules updated successfully");
    }