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 compositionHook = CompositionHookResource.Create(friendlyName: "FriendlyName"); Console.WriteLine(compositionHook.Sid); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"friendly_name\": \"My composition hook\",\"enabled\": false,\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"2015-07-30T20:00:00Z\",\"date_updated\": null,\"sid\": \"HKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"audio_sources\": [\"user*\",\"moderator\"],\"audio_sources_excluded\": [\"admin\"],\"video_layout\": {\"custom\": {\"video_sources\": [\"user*\"],\"video_sources_excluded\": [\"moderator\"],\"reuse\": \"show_oldest\",\"x_pos\": 100,\"y_pos\": 600,\"z_pos\": 10,\"width\": 800,\"height\": 0,\"max_columns\": 0,\"max_rows\": 0,\"cells_excluded\": [2,3]}},\"trim\": true,\"format\": \"mp4\",\"resolution\": \"1280x720\",\"status_callback\": \"http://www.example.com\",\"status_callback_method\": \"POST\",\"url\": \"https://video.twilio.com/v1/CompositionHooks/HKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = CompositionHookResource.Create("friendly_name", client: twilioRestClient); Assert.NotNull(response); }
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 compositionHook = CompositionHookResource.Create( friendlyName: "friendly_name" ); Console.WriteLine(compositionHook.Sid); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Video, "/v1/CompositionHooks", "" ); request.AddPostParam("FriendlyName", Serialize("friendly_name")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CompositionHookResource.Create("friendly_name", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }