public void TestElementWithParams() { var elem = new Dial( "number", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, true, 1, "caller_id", Dial.RecordEnum.DoNotRecord, Dial.TrimEnum.TrimSilence, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Dial.RecordingEventEnum.InProgress), true, Dial.RingToneEnum.At, Dial.RecordingTrackEnum.Both ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Dial action=\"https://example.com\" method=\"GET\" timeout=\"1\" hangupOnStar=\"true\" timeLimit=\"1\" callerId=\"caller_id\" record=\"do-not-record\" trim=\"trim-silence\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"in-progress\" answerOnBridge=\"true\" ringTone=\"at\" recordingTrack=\"both\">number</Dial>", elem.ToString() ); }
static void Main(string[] args) { string path = String.Format("{0}{1}{2}{3}{4}", "Log_", DateTime.Now.Month.ToString() , DateTime.Now.Day.ToString() , DateTime.Now.Year.ToString(), ".log"); // ChangeFilePath("MyRollingFileAppender", path); //XmlConfigurator.Configure(); // log.Debug("Debug message"); //log.Info("Info message"); // log.Warn("Warning message"); // log.Error("Error message"); // log.Fatal("Fatal message"); var mobileNo = "whatsapp:+Number"; var url = new Uri("URL"); var body = "Hello There! Please find your receipt."; MessageResource result; try { //throw new Exception(); result = SendWhatsAppMessagerAsync(mobileNo, body, Promoter.ListOfOne(url)).GetAwaiter().GetResult(); log.Info(JsonConvert.SerializeObject(result)); } catch (Exception ex) { log.Error(ex); } }
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 apn = new Dictionary <string, Object>() { { "aps", new Dictionary <string, Object>() { { "alert", new Dictionary <string, Object>() { { "title", "Bob alert" }, { "body", "Bob, you just received a badge" } } }, { "badge", 1 } } } }; var notification = NotificationResource.Create( apn: apn, identity: Promoter.ListOfOne("00000001"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { var uris = new List <Uri>(); uris.Add(new Uri("URL")); // Find your Account Sid and Token at twilio.com/console const string accountSid = ""; const string authToken = ""; TwilioClient.Init(accountSid, authToken); var message = MessageResource.Create( body: "Hello there! Please find your receipt", from: new Twilio.Types.PhoneNumber("whatsapp:+Number"), to: new Twilio.Types.PhoneNumber("whatsapp:+Number"), mediaUrl: Promoter.ListOfOne(new Uri("URL")) ); Console.WriteLine(message); Console.WriteLine(message.Sid); Console.ReadKey(); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Preview, "/HostedNumbers/AuthorizationDocuments", "" ); request.AddPostParam("HostedNumberOrderSids", Serialize("HostedNumberOrderSids")); request.AddPostParam("AddressSid", Serialize("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")); request.AddPostParam("Email", Serialize("Email")); request.AddPostParam("ContactTitle", Serialize("ContactTitle")); request.AddPostParam("ContactPhoneNumber", Serialize("ContactPhoneNumber")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { AuthorizationDocumentResource.Create(Promoter.ListOfOne("HostedNumberOrderSids"), "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "Email", "ContactTitle", "ContactPhoneNumber", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
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 toBinding = new List <string> { JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "binding_type", "sms" }, { "address", "+1651000000000" } }, Formatting.Indented) }; var notification = NotificationResource.Create( body: "Knok-Knok! This is your first Notify SMS", toBinding: toBinding, identity: Promoter.ListOfOne("Identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
public void TestElementWithParams() { var elem = new Pay( Pay.InputEnum.Dtmf, new Uri("https://example.com"), new Uri("https://example.com"), Pay.StatusCallbackMethodEnum.Get, 1, 1, true, "postal_code", "payment_connector", Pay.TokenTypeEnum.OneTime, "charge_amount", Pay.CurrencyEnum.Usd, "description", Promoter.ListOfOne(Pay.ValidCardTypesEnum.Visa), Pay.LanguageEnum.DeDe ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Pay input=\"dtmf\" action=\"https://example.com\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\" timeout=\"1\" maxAttempts=\"1\" securityCode=\"true\" postalCode=\"postal_code\" paymentConnector=\"payment_connector\" tokenType=\"one-time\" chargeAmount=\"charge_amount\" currency=\"usd\" description=\"description\" validCardTypes=\"visa\" language=\"de-DE\"></Pay>", elem.ToString() ); }
public void TestElementWithParams() { var elem = new Gather( Promoter.ListOfOne(Gather.InputEnum.Dtmf), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, "speech_timeout", 1, true, "finish_on_key", 1, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Gather.LanguageEnum.AfZa, "hints", true, true, true, Gather.SpeechModelEnum.Default, true ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Gather input=\"dtmf\" action=\"https://example.com\" method=\"GET\" timeout=\"1\" speechTimeout=\"speech_timeout\" maxSpeechTime=\"1\" profanityFilter=\"true\" finishOnKey=\"finish_on_key\" numDigits=\"1\" partialResultCallback=\"https://example.com\" partialResultCallbackMethod=\"GET\" language=\"af-ZA\" hints=\"hints\" bargeIn=\"true\" debug=\"true\" actionOnEmptyResult=\"true\" speechModel=\"default\" enhanced=\"true\"></Gather>", elem.ToString() ); }
public void TestElementWithParams() { var elem = new Conference( "name", true, Conference.BeepEnum.True, true, true, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, 1, Conference.RecordEnum.DoNotRecord, Conference.RegionEnum.Us1, "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", Conference.TrimEnum.TrimSilence, Promoter.ListOfOne(Conference.EventEnum.Start), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Conference.RecordingEventEnum.Started), new Uri("https://example.com") ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Conference muted=\"true\" beep=\"true\" startConferenceOnEnter=\"true\" endConferenceOnExit=\"true\" waitUrl=\"https://example.com\" waitMethod=\"GET\" maxParticipants=\"1\" record=\"do-not-record\" region=\"us1\" whisper=\"CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" trim=\"trim-silence\" statusCallbackEvent=\"start\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\" recordingStatusCallback=\"https://example.com\" recordingStatusCallbackMethod=\"GET\" recordingStatusCallbackEvent=\"started\" eventCallbackUrl=\"https://example.com\">name</Conference>", elem.ToString() ); }
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 phoneNumber = PhoneNumberResource.Fetch( type: Promoter.ListOfOne("carrier"), pathPhoneNumber: new Twilio.Types.PhoneNumber("+15108675310") ); Console.WriteLine(phoneNumber.CallerName); }
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 authorizationDocument = AuthorizationDocumentResource.Update( hostedNumberOrderSids: Promoter.ListOfOne("HostedNumberOrderSids"), pathSid: "PXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(authorizationDocument.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 phoneNumber = PhoneNumberResource.Fetch( addOns: Promoter.ListOfOne("whitepages_pro_caller_id"), pathPhoneNumber: new Twilio.Types.PhoneNumber("+16502530000") ); Console.WriteLine(phoneNumber.CallerName); }
public void TestElementWithParams() { var elem = new Prompt( Prompt.ForEnum.PaymentCardNumber, Promoter.ListOfOne(Prompt.ErrorTypeEnum.Timeout), Promoter.ListOfOne(Prompt.CardTypeEnum.Visa), Promoter.ListOfOne(1) ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Prompt for=\"payment-card-number\" errorType=\"timeout\" cardType=\"visa\" attempt=\"1\"></Prompt>", elem.ToString() ); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"address_sid\": \"ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"cc_emails\": [\"[email protected]\",\"[email protected]\"],\"date_created\": \"2017-03-28T20:06:39Z\",\"date_updated\": \"2017-03-28T20:06:39Z\",\"email\": \"[email protected]\",\"links\": {\"dependent_hosted_number_orders\": \"https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentHostedNumberOrders\"},\"sid\": \"PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"status\": \"signing\",\"url\": \"https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = AuthorizationDocumentResource.Create(Promoter.ListOfOne("HostedNumberOrderSids"), "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "Email", "ContactTitle", "ContactPhoneNumber", 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 notification = NotificationResource.Create( identity: Promoter.ListOfOne("Identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
public void TestUpdateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"chat_service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"friendly_name\": \"Conversation Role\",\"type\": \"conversation\",\"permissions\": [\"sendMessage\",\"leaveConversation\",\"editOwnMessage\",\"deleteOwnMessage\"],\"date_created\": \"2016-03-03T19:47:15Z\",\"date_updated\": \"2016-03-03T19:47:15Z\",\"url\": \"https://conversations.twilio.com/v1/Roles/RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = RoleResource.Update("RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", Promoter.ListOfOne("permission"), 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 feedback = FeedbackResource.Update( issue: Promoter.ListOfOne(FeedbackResource.IssuesEnum.AudioLatency), qualityScore: 1, pathCallSid: "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(feedback.DateCreated); }
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 user = UserResource.Create( segment: Promoter.ListOfOne("premium"), identity: "User0001", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(user.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 role = RoleResource.Update( permission: Promoter.ListOfOne("Permission"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathSid: "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(role.FriendlyName); }
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 notification = NotificationResource.Create( apn: "{\"aps\" : { \"alert\": {\"title\":\"Bob alert\",\"body\" :\"Bob, you just received a badge\"}, \"badge\" : 1 }}", identity: Promoter.ListOfOne("00000001"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.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 room = RoomResource.Create( statusCallback: new Uri("http://example.org"), type: RoomResource.RoomTypeEnum.Group, uniqueName: "DailyStandupWithH264Codec", videoCodecs: Promoter.ListOfOne(RoomResource.VideoCodecEnum.H264) ); Console.WriteLine(room.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 apn = new Dictionary <string, Object>() { { "aps", new Dictionary <string, Object>() { { "alert", new Dictionary <string, Object>() { { "title", "Short title for Watch." } } } } } }; var data = new Dictionary <string, Object>() { { "custom_key1", "custom value 1" }, { "custom_key2", "custom value 2" } }; var fcm = new Dictionary <string, Object>() { { "notification", new Dictionary <string, Object>() { { "title", "New alert" }, { "body", "Hello Bob!" } } } }; var notification = NotificationResource.Create( apn: apn, body: "This is the body for all Bindings", data: data, fcm: fcm, identity: Promoter.ListOfOne("00000001"), title: "Generic loooooooong title for all Bindings", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.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 role = RoleResource.Create( friendlyName: "new_role", permission: Promoter.ListOfOne("createChannel"), type: RoleResource.RoleTypeEnum.Deployment, pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(role.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 message = MessageResource.Create( body: "Hello there!", from: new Twilio.Types.PhoneNumber("+15555555555"), mediaUrl: Promoter.ListOfOne(new Uri("https://demo.twilio.com/owl.png")), to: new Twilio.Types.PhoneNumber("+12316851234") ); Console.WriteLine(message.Sid); }
public void TestElementWithParams() { var elem = new Client( "name", new Uri("https://example.com"), Twilio.Http.HttpMethod.Get, Promoter.ListOfOne(Client.EventEnum.Initiated), new Uri("https://example.com"), Twilio.Http.HttpMethod.Get ); Assert.AreEqual( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Client url=\"https://example.com\" method=\"GET\" statusCallbackEvent=\"initiated\" statusCallback=\"https://example.com\" statusCallbackMethod=\"GET\">name</Client>", elem.ToString() ); }
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 recordings = RecordingResource.Read( groupingSid: Promoter.ListOfOne("ParticipantSid") ); foreach (var record in recordings) { Console.WriteLine(record.Sid); } }
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 compositions = CompositionResource.Read( roomSid: Promoter.ListOfOne("RMXXXX") ); foreach (var record in compositions) { 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 notification = NotificationResource.Create( body: "Hello New Users", segment: Promoter.ListOfOne("new_user"), tag: Promoter.ListOfOne("preferred_device"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.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 message = MessageResource.Create( body: "This is the ship that made the Kessel Run in fourteen parsecs?", from: new Twilio.Types.PhoneNumber("+15017122661"), mediaUrl: Promoter.ListOfOne(new Uri("https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg")), to: new Twilio.Types.PhoneNumber("+15558675310") ); Console.WriteLine(message.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 notification = NotificationResource.Create( body: "Hello Bob", toBinding: Promoter.ListOfOne("{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}"), identity: Promoter.ListOfOne("Identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }