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); MemberResource.Delete( pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathChannelSid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathSid: "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); }
public void TestReadFullResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"members\"},\"members\": [{\"sid\": \"MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channel_sid\": \"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"jing\",\"role_sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"last_consumed_message_index\": null,\"last_consumption_timestamp\": null,\"date_created\": \"2016-03-24T21:05:50Z\",\"date_updated\": \"2016-03-24T21:05:50Z\",\"url\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}]}" )); var response = MemberResource.Read("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 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 queueSid = "QU5ef8732a3c49700934481addd5ce1659"; const string callSid = "CA386025c9bf5d6052a1d1ea42b4d16662"; TwilioClient.Init(accountSid, authToken); var queueMember = MemberResource.Fetch(queueSid, callSid); Console.WriteLine(queueMember.WaitTime); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"sid\": \"MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channel_sid\": \"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"jing\",\"role_sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"last_consumed_message_index\": null,\"last_consumption_timestamp\": null,\"date_created\": \"2016-03-24T21:05:50Z\",\"date_updated\": \"2016-03-24T21:05:50Z\",\"url\": \"https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = MemberResource.Fetch("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient); Assert.NotNull(response); }
public void TestDeleteResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.NoContent, "null" )); var response = MemberResource.Delete("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient); Assert.NotNull(response); }
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"; TwilioClient.Init(accountSid, authToken); var members = MemberResource.Read("QU5ef8732a3c49700934481addd5ce1659"); foreach (var member in members) { Console.WriteLine(member.WaitTime); } }
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\": \"MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"channel_sid\": \"CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"jing\",\"role_sid\": \"RLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"last_consumed_message_index\": null,\"last_consumption_timestamp\": null,\"date_created\": \"2016-03-24T21:05:50Z\",\"date_updated\": \"2016-03-24T21:05:50Z\",\"attributes\": \"{}\",\"url\": \"https://chat.twilio.com/v2/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}" )); var response = MemberResource.Create("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "identity", xTwilioWebhookEnabled: Serialize(MemberResource.WebhookEnabledTypeEnum.True), client: twilioRestClient); Assert.NotNull(response); }
public void TestDeleteResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.NoContent, "null" )); var response = MemberResource.Delete("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", xTwilioWebhookEnabled: Serialize(MemberResource.WebhookEnabledTypeEnum.True), client: twilioRestClient); Assert.NotNull(response); }
public void TestReadEmptyResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"meta\": {\"page\": 0,\"page_size\": 50,\"first_page_url\": \"https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0\",\"previous_page_url\": null,\"url\": \"https://ip-messaging.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members?PageSize=50&Page=0\",\"next_page_url\": null,\"key\": \"members\"},\"members\": []}" )); var response = MemberResource.Read("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 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 member = MemberResource.Create( identity: "Identity", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathChannelSid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(member.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"); TwilioClient.Init(accountSid, authToken); var members = MemberResource.Read("QU5ef8732a3c49700934481addd5ce1659"); foreach (var member in members) { Console.WriteLine(member.WaitTime); } }
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"; const string channelSid = "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string memberSid = "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); // Retrieve the member var member = MemberResource.Fetch(serviceSid, channelSid, memberSid); Console.WriteLine(member.Identity); }
public object AddMember(InputAddMember input) { var serviceSid = input.ServiceSid; var pathChannelSid = input.ChannelSid; var roleSid = input.RoleSid; var indentity = input.Identity; var member = MemberResource.Create( identity: indentity, pathServiceSid: serviceSid, pathChannelSid: pathChannelSid, roleSid: roleSid ); return(member); }
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 member = MemberResource.Fetch( pathQueueSid: "QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathCallSid: "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(member.CallSid); }
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 channelSid = "channelSid"; const string memberSid = "memberSid"; TwilioClient.Init(accountSid, authToken); // Delete a member var status = MemberResource.Delete(serviceSid, channelSid, memberSid); Console.WriteLine(status); }
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 member = MemberResource.Fetch( pathQueueSid: "QU5ef8732a3c49700934481addd5ce1659", pathCallSid: "CA386025c9bf5d6052a1d1ea42b4d16662" ); Console.WriteLine(member.CallSid); }
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 channelSid = "channelSid"; const string identity = "identity"; TwilioClient.Init(accountSid, authToken); // Add a member var member = MemberResource.Create(serviceSid, channelSid, identity); Console.WriteLine(member); }
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 channelSid = "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string identity = "identity"; TwilioClient.Init(accountSid, authToken); // Add a member var member = MemberResource.Create(serviceSid, channelSid, identity); Console.WriteLine(member); }
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 member = MemberResource.Update( url: new Uri("https://example.com"), method: Twilio.Http.HttpMethod.Get, pathQueueSid: "QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathCallSid: "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(member.CallSid); }
public void PropertiesAerBuiltCorrectly() { MethodToTest(() => service.BuildOrganisationResource(A <ShurahBasedOrganisation> .Ignored, A <Auth0User> .Ignored)); var user = new Auth0User { }; var org = new ShurahBasedOrganisation { Name = "a", Description = "B", JoiningPolicy = JoiningPolicy.NoApplicationNeeded, Members = new List <Member>(), MembershipRuleSections = new List <MembershipRuleSection>(), Terms = new List <MembershipRuleTermDefinition>(), }; var sortedTerms = new List <MembershipRuleTermDefinition>(); A.CallTo(() => service.SortTerms(org.Terms)).Returns(sortedTerms); var memberResource = new MemberResource(); A.CallTo(() => service.GetMember(user, org.Members)).Returns(memberResource); var ruleSectionResources = new List <MembershipRuleSectionResource>(); var filteredSections = new List <MembershipRuleSection>(); A.CallTo(() => dependencies.LinqService.Where(org.MembershipRuleSections, A <Func <MembershipRuleSection, bool> > .That.Matches(x => x.Invoke(new MembershipRuleSection()) && !x.Invoke(new MembershipRuleSection { ParentMembershipRuleSection = new MembershipRuleSectionRelationship() }) ))).Returns(filteredSections); A.CallTo(() => service.BuildMembershipRuleSectionResources(String.Empty, filteredSections, sortedTerms, user)) .Returns(ruleSectionResources); var result = service.BuildOrganisationResource(org, user); Assert.AreEqual(org.Name, result.Name); Assert.AreEqual(org.Description, result.Description); Assert.AreEqual(org.JoiningPolicy.ToString(), result.JoiningPolicy); Assert.AreEqual(memberResource, result.Member); Assert.AreSame(ruleSectionResources, result.RuleSections); }
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 members = MemberResource.Read( pathQueueSid: "QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); foreach (var record in members) { Console.WriteLine(record.CallSid); } }
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"; TwilioClient.Init(accountSid, authToken); const string queueSid = "QU5ef8732a3c49700934481addd5ce1659"; const string callSid = "Front"; var twimlUrl = new Uri("http://demo.twilio.com/docs/voice.xml"); MemberResource.Update(queueSid, callSid, twimlUrl, HttpMethod.Post); }
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 member = MemberResource.Update( url: new Uri("http://demo.twilio.com/docs/voice.xml"), method: Twilio.Http.HttpMethod.Post, pathQueueSid: "QU5ef8732a3c49700934481addd5ce1659", pathCallSid: "Front" ); Console.WriteLine(member.CallSid); }
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 members = MemberResource.Read( pathQueueSid: "QU5ef8732a3c49700934481addd5ce1659" ); foreach (var record in members) { Console.WriteLine(record.CallSid); } }
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"); TwilioClient.Init(accountSid, authToken); const string queueSid = "QU5ef8732a3c49700934481addd5ce1659"; const string callSid = "Front"; var twimlUrl = new Uri("http://demo.twilio.com/docs/voice.xml"); MemberResource.Update(queueSid, callSid, twimlUrl, HttpMethod.Post); }
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 channelSid = "channelSid"; TwilioClient.Init(accountSid, authToken); // List all members of a channel var members = MemberResource.Read(serviceSid, channelSid); foreach (var member in members) { Console.WriteLine(member.DateCreated); } }
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 channelSid = "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); // List all members of a channel var members = MemberResource.Read(serviceSid, channelSid); foreach (var member in members) { Console.WriteLine(member.DateCreated); } }
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 members = MemberResource.Read( pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", pathChannelSid: "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); foreach (var record in members) { Console.WriteLine(record.Sid); } }
public void MemberReturned() { MethodToTest(() => service.GetMember(A <Auth0User> .Ignored, A <IEnumerable <Member> > .Ignored)); var members = new List <Member>(); var user = new Auth0User { Id = "someid" }; var exampleMatchingMember = new Member { MemberAuth0Users = new List <MemberAuth0User> { new MemberAuth0User { Auth0UserId = user.Id } } }; var exampleNonMatchingMember = new Member { MemberAuth0Users = new List <MemberAuth0User> { new MemberAuth0User { Auth0User = new Auth0User() } } }; var member = new Member(); A.CallTo(() => dependencies.LinqService.SingleOrDefault(members, A <Func <Member, bool> > .That.Matches(x => x.Invoke(exampleMatchingMember) && !x.Invoke(exampleNonMatchingMember) ))).Returns(member); var memberResource = new MemberResource(); A.CallTo(() => service.BuildMemberResource(member)).Returns(memberResource); var result = service.GetMember(user, members); Assert.AreSame(memberResource, result); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Chat, "/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { MemberResource.Fetch("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }