public void GetCreditsUsage() { var request = new DateIntervalRequest { IntervalBegin = DateTime.UtcNow.AddMonths(-2), IntervalEnd = DateTime.UtcNow }; var creditsUsage = Client.MeApi.GetCreditUsage(request); Assert.NotNull(creditsUsage.IntervalBegin); Assert.NotNull(creditsUsage.IntervalEnd); Assert.NotNull(creditsUsage.TextsSent); Assert.NotNull(creditsUsage.CallsDurationMinutes); Assert.NotNull(creditsUsage.CreditsUsed); creditsUsage = Client.MeApi.GetCreditUsage(); Assert.NotNull(creditsUsage); request = new DateIntervalRequest { IntervalEnd = DateTime.UtcNow.AddMonths(-2) }; creditsUsage = Client.MeApi.GetCreditUsage(request); Assert.NotNull(creditsUsage); }
public void GetCreditsUsage() { string expectedJson = GetJsonPayload("/account/meApi/response/getCreditsUsage.json"); var restRequest = MockRestResponse(expectedJson); var request = new DateIntervalRequest { IntervalBegin = DateTime.UtcNow.AddMonths(-2), IntervalEnd = DateTime.UtcNow }; CreditsUsage creditsUsage = Client.MeApi.GetCreditUsage(request); Assert.That(Serializer.Serialize(creditsUsage), Is.EqualTo(expectedJson)); DateTime intBeg = (DateTime) request.IntervalBegin; DateTime intEnd = (DateTime) request.IntervalEnd; long ib = (long)(intBeg.ToUniversalTime() - ClientConstants.EPOCH).TotalMilliseconds; long ie = (long)(intEnd.ToUniversalTime() - ClientConstants.EPOCH).TotalMilliseconds; Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("intervalBegin") && p.Value.Equals(ib.ToString()))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("intervalEnd") && p.Value.Equals(ie.ToString()))); }
/// <summary> /// Find credit usage for the user. Returns credits usage for time period specified or if unspecified then total for all time. /// </summary> /// <param name="request">request for date range filtering</param> /// <returns>CreditsUsage object</returns> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public CreditsUsage GetCreditUsage(DateIntervalRequest request = null) { if (request != null) return Client.Get<CreditsUsage>(ME_BILLING_CREDIT_PATH, request); else return Client.Get<CreditsUsage>(ME_BILLING_CREDIT_PATH); }