Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed RateLimit ResetTime #483

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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