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\": \"USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"chat_service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"role_sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"admin\",\"friendly_name\": \"name\",\"attributes\": \"{ \\\"duty\\\": \\\"tech\\\" }\",\"is_online\": true,\"is_notifiable\": null,\"date_created\": \"2019-12-16T22:18:37Z\",\"date_updated\": \"2019-12-16T22:18:38Z\",\"url\": \"https://conversations.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = UserResource.Create("identity", xTwilioWebhookEnabled: Serialize(UserResource.WebhookEnabledTypeEnum.True), client: twilioRestClient); Assert.NotNull(response); }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"sid\": \"USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"role_sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"jing\",\"attributes\": null,\"is_online\": true,\"is_notifiable\": null,\"friendly_name\": null,\"joined_channels_count\": 0,\"date_created\": \"2016-03-24T21:05:19Z\",\"date_updated\": \"2016-03-24T21:05:19Z\",\"links\": {\"user_channels\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels\",\"user_bindings\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Bindings\"},\"url\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = UserResource.Create("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console const string accountSid = "accountSid"; const string authToken = "authToken"; const string serviceSid = "serviceSid"; const string identity = "identity"; const string roleSid = "roleSid"; TwilioClient.Init(accountSid, authToken); var user = UserResource.Create(serviceSid, identity, roleSid); Console.WriteLine(user.RoleSid); }
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( identity: "Identity", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(user.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, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"2017-02-17T07:17:02Z\",\"date_updated\": \"2017-02-17T07:17:02Z\",\"identity\": \"identity\",\"links\": {\"bindings\": \"https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/Bindings\",\"segment_memberships\": \"https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity/SegmentMemberships\"},\"segments\": [\"segment1\"],\"service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"sid\": \"USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"url\": \"https://notify.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users/identity\"}" )); var response = UserResource.Create("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "Identity", client: twilioRestClient); Assert.NotNull(response); }
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 serviceSid = Environment.GetEnvironmentVariable("TWILIO_SERVICE_SID"); const string identity = "identity"; const string roleSid = "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); var user = UserResource.Create(serviceSid, identity, roleSid); Console.WriteLine(user.RoleSid); }
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 user = UserResource.Create( identity: "IDENTITY", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(user.Sid); }
public object CreateUser(InputCreateUser input) { var serviceSid = input.ServiceSid; var identity = input.Identity; var roleSid = input.RoleSid; var attribute = input.Attributes; var friendlyName = input.FriendlyName; var user = UserResource.Create( identity: identity, pathServiceSid: serviceSid, roleSid: roleSid, attributes: attribute, friendlyName: friendlyName ); return(user); }
public 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 serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); UserResource user = UserResource.Create( serviceSid, "User0001", segment: new List <string> { "premium", "fitness-lifestyle" }); Console.WriteLine(user.Sid); }
public 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 serviceSid = Environment.GetEnvironmentVariable("TWILIO_SERVICE_SID"); TwilioClient.Init(accountSid, authToken); UserResource user = UserResource.Create( serviceSid, "User0001", segment: new List <string> { "premium", "fitness-lifestyle" }); 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 segment = new List <string> { "premium" }; var user = UserResource.Create( segment: segment, identity: "User0001", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(user.Sid); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Chat, "/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Users", "" ); request.AddPostParam("Identity", Serialize("Identity")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { UserResource.Create("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Conversations, "/v1/Users", "" ); request.AddPostParam("Identity", Serialize("identity")); request.AddHeaderParam("X-Twilio-Webhook-Enabled", Serialize(UserResource.WebhookEnabledTypeEnum.True)); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { UserResource.Create("identity", xTwilioWebhookEnabled: Serialize(UserResource.WebhookEnabledTypeEnum.True), client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }