-
Notifications
You must be signed in to change notification settings - Fork 1
Home
skuio edited this page Feb 1, 2020
·
3 revisions
A PHP package to connect to sku.io User API.
Installation using composer:
composer require skuio/sku-sdk
-
You need to create or get user API credentials from this APIs User API
This APIs return
{ "key": "f6a9f775f414ecc550a....", "secret": "0a9be418866a453cb9...." }
-
Use this credentials to connect with sku.io user api (
username
,password
). -
Set the SDK configurations:
- username
- password
- environment
you can set
url
ordev_url
if you want to change your testing domains. -
the SDK handle response automatically and you code get the results using these three functions:
-
getCode()
: returns http response status of i.e (200,500 ..). -
getResponse()
: returns the JSON format response (response also return errors like validation errors ..etc). -
getCurlError()
: returns thecurl
error.
-
Here is an example of a function used to get products from sku.io:
use Skuio\Sdk\Sdk;
use Skuio\Sdk\Request;
use Skuio\Sdk\Resource\Products;
public function getProducts()
{
Sdk::config( [ 'username' => $username, 'password' => $password, 'environment' => Sdk::DEVELOPMENT ] );
$productsRequest = new Request();
$productsRequest->setConjunction( 'and' );
$productsRequest->addFilter( 'sku', '=', '5333180491623' );
$productsRequest->setLimit( 15 );
$productsRequest->setPage( 1 );
$products = new Products();
$products = $products->get( $productsRequest );
return $products->getResponse();
}
And you can use the base Sdk
class
use Skuio\Sdk\Sdk;
public function testConnection()
{
Sdk::config( [ 'username' => $username, 'password' => $password, 'environment' => Sdk::DEVELOPMENT ] );
$sdk = new Sdk();
$res = $sdk->authorizedRequest( '/vendors' );
return $res->getResponse();
}