Skip to content

Commit a2095cc

Browse files
authored
Merge pull request #19 from QuadraEcommerce/feature/expose-rate-limiting-info
Feature/expose rate limiting info
2 parents 671f02f + 35019e9 commit a2095cc

File tree

5 files changed

+680
-211
lines changed

5 files changed

+680
-211
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,33 @@ $shipments = $shipStation->shipments->forOrderNumber($orderNumber);
150150

151151
## ShipStation API Rate Limit
152152
ShipStation only allows for 40 API calls that resets every 60 seconds (or 1 call every 1.5 seconds). By default, LaravelShipStation will protect against any calls being rate limited by pausing when we are averaging more than 1 call every 1.5 seconds.
153+
154+
Once a request has been made, information about the current rate limiting values can be accessed using the following methods:
155+
156+
Get the maximum number of requests that can be sent per window:
157+
```php
158+
// integer
159+
$shipStation->getMaxAllowedRequests()
160+
```
161+
162+
Get the remaining number of requests that can be sent in the current window:
163+
```php
164+
// integer
165+
$shipStation->getRemainingRequests()
166+
```
167+
168+
Get the number of seconds remaining until the next window begins:
169+
```php
170+
// integer
171+
$shipStation->getSecondsUntilReset()
172+
```
173+
174+
Check if requests are currently being rate limited:
175+
```php
176+
// boolean
177+
$shipStation->isRateLimited()
178+
```
179+
153180
## Tests
154181
Tests can be ran using ```phpunit```.
155182
Please note that tests will create an order, check the order, and delete the order in your production environment. By default, tests are disabled. If you would like to run the tests edit the ```phpunit.xml``` file to set the environment variable ```SHIPSTATION_TESTING``` to ```true``` and set your API Key & Secret Key.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
},
1616
"require": {
17-
"guzzlehttp/guzzle": "^6.2"
17+
"guzzlehttp/guzzle": "^6.3"
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "^5.3"

0 commit comments

Comments
 (0)