A simple php wrapper for Easystore Api
composer require neoson/easystore-api
Setup Options
\EasyStore\Options::setOptions([
'shop' => 'YOUR SHOP NAME', // required option
'access_token' => 'YOUR ACCESS TOKEN', // required option for protected endpoint
'version' => '1.0', // default value
'timeout' => 15, // default value
]);
Create a \EasyStore\Client
object
$client = new \EasyStore\Client();
Get
$client->get($endpoint, $parameter = [])
Post
$client->post($endpoint, $body)
Put
$client->put($endpoint, $body)
Delete
$client->delete($endpoint, $body = [])
Arguments
Params | Type | Description |
---|---|---|
endpoint |
string |
Easystore API endpoint, refer Easytore Docs |
body |
array |
body will be converted to JSON |
parameter |
array |
parameter will be converted to query string |
Create an OAuth Request
// setup required options
\EasyStore\Options::setOptions([
'shop' => 'YOUR SHOP NAME',
'client_id' => 'YOUR CLIENT ID',
'scopes' => 'YOUR SCOPES',
'redirect_uri' => 'YOUR REDIRECT URL',
]);
$requestUrl = $client->buildAuthUrl();
// if you are using laravel
return response()->redirect($requestUrl);
Exchange for permanent access token after oauth completed
// setup required options
\EasyStore\Options::setOptions([
'shop' => 'YOUR SHOP NAME',
'client_id' => 'YOUR CLIENT ID',
'client_secret' => 'YOUR CLIENT SECRET',
]);
$accessToken = $client->getAccessToken();
//store this access token somewhere
If you want to contribute to a project and make it better, your help is very welcome. Just send a pr and you are all set.
This library is released under the MIT License