Skip to content

Commit

Permalink
Merge pull request #483 from Mangopay/feature/name_improving_rate_limits
Browse files Browse the repository at this point in the history
Changed RateLimit ResetTime
  • Loading branch information
SoloJr authored May 5, 2021
2 parents 71cd5a3 + 0ab496c commit e62702d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions MangoPay/Libraries/RestTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ private function ReadResponseHeader($headers)
$updatedRateLimits = $this->initRateLimits();
}
$rateLimit = $this->findFirstRateLimitMatchingPredicate($updatedRateLimits, function ($rate) {
return $rate->ResetTimeMillis == null;
return $rate->ResetTimeTimestamp == null;
});
$rateLimit->ResetTimeMillis = (int)trim(str_replace('x-ratelimit-reset:', '', $lowercaseHeader));
$rateLimit->ResetTimeTimestamp = (int)trim(str_replace('x-ratelimit-reset:', '', $lowercaseHeader));
}
}

Expand Down
4 changes: 2 additions & 2 deletions MangoPay/RateLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class RateLimit
public $CallsRemaining;

/**
* @var integer the time in millis when the number of allowed calls in this time interval will be reset.
* @var integer the time in unix timestamp when the number of allowed calls in this time interval will be reset.
*/
public $ResetTimeMillis;
public $ResetTimeTimestamp;

/**
* RateLimit constructor.
Expand Down
2 changes: 1 addition & 1 deletion MangoPay/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace MangoPay;


class Shipping
class Shipping extends Libraries\Dto
{
/**
* The First Name for Billing Address
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ So there are 4 groups of rate limits available:
4. Last 24 hours

This information is available from the MangoPayApi instance, like in the following example:

```php
<?php

Expand Down Expand Up @@ -282,10 +283,10 @@ class MangoPayService
$rateLimits = $this->mangoPayApi->RateLimits;
print "There were " . $rateLimits[0]->CallsMade . " calls made in the last 15 minutes\n";
print "You can do " . $rateLimits[0]->CallsRemaining . " more calls in the next 15 minutes\n";
print "The 15 minutes counter will reset in " . $rateLimits[0]->ResetTimeMillis . " ms\n\n";
print "The 15 minutes counter will reset in " . $rateLimits[0]->ResetTimeTimestamp . " ms\n\n";
print "There were " . $rateLimits[2]->CallsMade . " calls made in the last 60 minutes\n";
print "You can do " . $rateLimits[2]->CallsRemaining . " more calls in the next 60 minutes\n";
print "The 60 minutes counter will reset in " . $rateLimits[1]->ResetTimeMillis . " ms\n\n";
print "The 60 minutes counter will reset in " . $rateLimits[1]->ResetTimeTimestamp . " ms\n\n";
}
}

Expand Down

0 comments on commit e62702d

Please sign in to comment.