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"; const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a"; const string friendlyName = "My company"; TwilioClient.Init(accountSid, authToken); var alphaSender = AlphaSenderResource.Create(pathServiceSid, friendlyName); Console.WriteLine(alphaSender.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, "{\"sid\": \"AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"2015-07-30T20:12:31Z\",\"date_updated\": \"2015-07-30T20:12:33Z\",\"alpha_sender\": \"Twilio\",\"capabilities\": [\"SMS\"],\"url\": \"https://messaging.twilio.com/v1/Services/MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AlphaSenders/AIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = AlphaSenderResource.Create("MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "alpha_sender", 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 alphaSender = AlphaSenderResource.Create( alphaSender: "AlphaSender", pathServiceSid: "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(alphaSender.Sid); }
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"); const string pathServiceSid = "MG2172dd2db502e20dd981ef0d67850e1a"; const string friendlyName = "My company"; TwilioClient.Init(accountSid, authToken); var alphaSender = AlphaSenderResource.Create(pathServiceSid, friendlyName); Console.WriteLine(alphaSender.Sid); }
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 alphaSender = AlphaSenderResource.Create( alphaSender: "My company", pathServiceSid: "MG2172dd2db502e20dd981ef0d67850e1a" ); Console.WriteLine(alphaSender.Sid); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Messaging, "/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders", "" ); request.AddPostParam("AlphaSender", Serialize("alpha_sender")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { AlphaSenderResource.Create("MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "alpha_sender", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }