shoplo / multi-channel-client
Installs: 1 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- doctrine/annotations: 1.4.*
- guzzlehttp/oauth-subscriber: ^0.3.0
- jms/serializer: ^1.0
- shoplo/sso-auth: dev-master
This package is not auto-updated.
Last update: 2024-10-31 15:40:12 UTC
README
This sdk enables php developers to communicate with Shoplo Multi with an oauth 2 authentication.
Requirements
- guzzle
- doctrine annotations
Features
- Compatible with PHP 5.5 or greater.
- Easy to install with Composer
Installation
The SDK can be installed with Composer.
- Install Composer.
curl -sS https://getcomposer.org/installer | php
- Install the SDK.
php composer.phar require shoplo/shoplo-multi-client
- Add doctrine annotations to autoload file or front controller.
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
- Require Composer's autoloader by adding the following line to your code.
require 'vendor/autoload.php';
Example
Authentication using sso auth.
<?php session_start(); require_once __DIR__ . '/autoload.php'; ini_set('display_errors','TRUE'); error_reporting(E_ALL); define('SECRET_KEY', 'XXXX'); define('PUBLIC_KEY', 'XXXX'); define('CALLBACK_URL', 'http://127.0.0.1/multi-channel-client/example.php'); $authUrl = 'http://auth.shoplo.io'; $ssoConfig = [ 'apiBaseUrl' => $authUrl, 'publicKey' => PUBLIC_KEY, 'secretKey' => SECRET_KEY, 'callbackUrl' => CALLBACK_URL, ]; $apiUrl = 'http://api.shoplo.io'; $guzzleAdapter = new \ShoploMulti\Guzzle\GuzzleAdapter( new \GuzzleHttp\Client(['base_uri' => $apiUrl]) ); $shoploMultiClient = new \ShoploMulti\ShoploMultiClient( $guzzleAdapter, \JMS\Serializer\SerializerBuilder::create()->build(), $apiUrl ); $shoploMultiClient->initSSOAuthClient($ssoConfig); $shoploMultiClient->authorize();
Orders resource.
$orderResource = new \ShoploMulti\Resource\ShoploMultiOrderResource($shoploMultiClient); $with = [ 'with' => [ 'order.addresses', 'order.tags', 'order.items', 'order.fulfillments', 'order.customer', 'order.shipping_lines', ] ]; $orders = $orderResource->getOrders($with); $orders = $orderResource->getCount(); $orders = $orderResource->getOrder(6, $with); $fulfillments = new \ShoploMulti\Model\Order\ShoploMultiOrderFulfillments(); $fulfillments->tracking_company = 'Poczta Polska'; $trackingUrl = 'http://emonitoring.poczta-polska.pl/?numer=123123123123'; $fulfillments->tracking_urls = [$trackingUrl]; $fulfillments->tracking_numbers = ['123123123123']; $response = $orderResource->createOrderFullfilments(6, $fulfillments);
Products resource.
$productResource = new \ShoploMulti\Resource\ShoploMultiProductResource($shoploMultiClient); $with = [ 'with' => [ 'product.images', 'product.tags', 'product.variants', 'product.variants.properties', 'category.path', 'category.path_siblings', ] ]; $response = $productResource->getProducts($with); $response = $productResource->getCount();
Customers resource.
$customerResource = new \ShoploMulti\Resource\ShoploMultiCustomerResource($shoploMultiClient); $response = $customerResource->getCustomers(); $response = $customerResource->getCount();