public CrayonApiClient(HttpClient httpClient) { _httpClient = httpClient; _jsonSerializerSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Include, DefaultValueHandling = DefaultValueHandling.Include, Formatting = Formatting.Indented }; _assemblyVersion = typeof(CrayonApiClient).GetTypeInfo().Assembly.GetName().Version.ToString(); Addresses = new AddressResource(this); AgreementProducts = new AgreementProductResource(this); Agreements = new AgreementResource(this); BillingStatements = new BillingStatementResource(this); BlogItems = new BlogItemResource(this); Clients = new ClientResource(this); CustomerTenants = new CustomerTenantResource(this); InvoiceProfiles = new InvoiceProfileResource(this); Me = new MeResource(this); OrganizationAccess = new OrganizationAccessResource(this); Organizations = new OrganizationResource(this); Publishers = new PublisherResource(this); Programs = new ProgramResource(this); Regions = new RegionResource(this); Secrets = new SecretResource(this); Subscriptions = new SubscriptionResource(this); Tokens = new TokenResource(this); UsageRecords = new UsageRecordResource(this); Users = new UserResource(this); }
public void TestReadDaySimFilterResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"usage_records\": [{\"period\": {\"start_time\": \"2019-05-01T00:00:00Z\",\"end_time\": \"2019-05-03T00:00:00Z\"},\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"data_upload\": 1000,\"data_download\": 1000,\"data_total\": 2000,\"sim_sid\": \"HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},{\"period\": {\"start_time\": \"2019-05-03T00:00:00Z\",\"end_time\": \"2019-05-04T00:00:00Z\"},\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"data_upload\": 1000,\"data_download\": 1000,\"data_total\": 2000,\"sim_sid\": \"HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"meta\": {\"first_page_url\": \"https://supersim.twilio.com/v1/UsageRecords?Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Granularity=day&PageSize=50&Page=0\",\"key\": \"usage_records\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://supersim.twilio.com/v1/UsageRecords?Sim=HSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&Granularity=day&PageSize=50&Page=0\"}}" )); var response = UsageRecordResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"usage_records\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"commands\": {\"billing_units\": \"USD\",\"billed\": 0,\"total\": 3,\"from_sim\": 1,\"to_sim\": 2,\"home\": {\"billing_units\": \"USD\",\"billed\": 0,\"total\": 3,\"from_sim\": 1,\"to_sim\": 2},\"national_roaming\": {\"billing_units\": \"USD\",\"billed\": 0,\"total\": 0,\"from_sim\": 0,\"to_sim\": 0},\"international_roaming\": []},\"data\": {\"billing_units\": \"USD\",\"billed\": 0.35,\"total\": 3494609,\"upload\": 731560,\"download\": 2763049,\"units\": \"bytes\",\"home\": {\"billing_units\": \"USD\",\"billed\": 0.35,\"total\": 3494609,\"upload\": 731560,\"download\": 2763049,\"units\": \"bytes\"},\"national_roaming\": {\"billing_units\": \"USD\",\"billed\": 0,\"total\": 0,\"upload\": 0,\"download\": 0,\"units\": \"bytes\"},\"international_roaming\": []},\"sim_sid\": \"DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"period\": {\"start\": \"2015-07-30T20:00:00Z\",\"end\": \"2015-07-30T20:00:00Z\"}},{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"commands\": {},\"data\": {},\"sim_sid\": \"DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"period\": {}}],\"meta\": {\"first_page_url\": \"https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?Start=2015-07-30T20%3A00%3A00Z&End=2015-07-30T20%3A00%3A00Z&PageSize=50&Page=0\",\"key\": \"usage_records\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?Start=2015-07-30T20%3A00%3A00Z&End=2015-07-30T20%3A00%3A00Z&PageSize=50&Page=0\"}}" )); var response = UsageRecordResource.Read("DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"usage_records\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"commands\": {},\"data\": {},\"sim_sid\": \"DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"period\": {}},{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"commands\": {},\"data\": {},\"sim_sid\": \"DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"period\": {}}],\"meta\": {\"first_page_url\": \"https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?PageSize=50&Page=0\",\"key\": \"usage_records\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://wireless.twilio.com/v1/Sims/DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UsageRecords?PageSize=50&Page=0\"}}" )); var response = UsageRecordResource.Read("DEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 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 usageRecords = UsageRecordResource.Read("DEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); foreach (var usageRecord in usageRecords) { Console.WriteLine(usageRecord.Commands); } }
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 usageRecords = UsageRecordResource.Read("DEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); foreach (var usageRecord in usageRecords) { Console.WriteLine(usageRecord.Commands); } }
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 usageRecords = UsageRecordResource.Read( pathSimSid: "DEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); foreach (var record in usageRecords) { Console.WriteLine(record.SimSid); } }
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 usageRecords = UsageRecordResource.Read( pathSimSid: "DEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", limit: 20 ); foreach (var record in usageRecords) { Console.WriteLine(record.SimSid); } }
public void TestReadRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Supersim, "/v1/UsageRecords", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { UsageRecordResource.Read(client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }