public HttpResponseMessage Single(
     [ModelBinder(typeof (SingleAccountModelBinder))] SingleAccountInputModel singleAccountInput)
 {
     bool allow =
         new ThrottledRequest(_throttlingService, singleAccountInput.Cost, singleAccountInput.IntervalInSeconds,
             singleAccountInput.CreditsPerIntervalValue).Perform(singleAccountInput.Account);
     return allow
         ? Request.CreateResponse(HttpStatusCode.OK)
         : Request.CreateResponse(HttpStatusCode.PaymentRequired, "THROTTLED");
 }
 public dynamic Multi(string account, int calls, int accounts, int cost, int intervalInSeconds, long creditsPerIntervalValue)
 {
     var r = new ThrottledRequest(_throttlingService, cost, intervalInSeconds, creditsPerIntervalValue);
     var throttledCount = 0;
     var startTime = DateTime.Now;
     for (var indx = 0; indx < calls; indx++)
     {
         var randomAccount = "a" + new Random().Next(accounts);
         if (!r.Perform(randomAccount))
         {
             throttledCount++;
         }
     }
     var time = DateTime.Now - startTime;
     return new {calls, time.TotalMilliseconds, throttledCount};
 }
 public HttpResponseMessage Single(string account, int cost, int intervalInSeconds, long creditsPerIntervalValue)
 {
     bool allow = new ThrottledRequest(_throttlingService, cost, intervalInSeconds, creditsPerIntervalValue).Perform(account);
     return allow ? Request.CreateResponse(HttpStatusCode.OK) : Request.CreateResponse(HttpStatusCode.PaymentRequired, "THROTTLED");
 }