neoson/easystore-api

easystore api library

1.0.1 2020-09-10 08:37 UTC

This package is auto-updated.

Last update: 2024-04-19 09:45:29 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

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

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