Skip to content

Commit

Permalink
Merge pull request #19 from QuadraEcommerce/feature/expose-rate-limit…
Browse files Browse the repository at this point in the history
…ing-info

Feature/expose rate limiting info
  • Loading branch information
joecampo authored May 19, 2020
2 parents 671f02f + 35019e9 commit a2095cc
Show file tree
Hide file tree
Showing 5 changed files with 680 additions and 211 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@ $shipments = $shipStation->shipments->forOrderNumber($orderNumber);

## ShipStation API Rate Limit
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.

Once a request has been made, information about the current rate limiting values can be accessed using the following methods:

Get the maximum number of requests that can be sent per window:
```php
// integer
$shipStation->getMaxAllowedRequests()
```

Get the remaining number of requests that can be sent in the current window:
```php
// integer
$shipStation->getRemainingRequests()
```

Get the number of seconds remaining until the next window begins:
```php
// integer
$shipStation->getSecondsUntilReset()
```

Check if requests are currently being rate limited:
```php
// boolean
$shipStation->isRateLimited()
```

## Tests
Tests can be ran using ```phpunit```.
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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"require": {
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^5.3"
Expand Down
Loading

0 comments on commit a2095cc

Please sign in to comment.