neoson/easystore-api

easystore api library

1.0.1 2020-09-10 08:37 UTC

This package is auto-updated.

Last update: 2024-11-19 11:01:58 UTC


README

Latest Stable Version Build Status StyleCI License Total Downloads

A simple php wrapper for Easystore Api

Installation

composer require neoson/easystore-api

Usage

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();

Client Method

Get

$client->get($endpoint, $parameter = [])

Post

$client->post($endpoint, $body)

Put

$client->put($endpoint, $body)

Delete

$client->delete($endpoint, $body = [])

Arguments

Access Token

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

Contributing

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.

License

This library is released under the MIT License