shoplo/multi-channel-client

There is no license information available for the latest version (dev-master) of this package.

dev-master 2018-06-04 13:35 UTC

This package is not auto-updated.

Last update: 2024-05-02 13:09:19 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.

  1. Install Composer.
curl -sS https://getcomposer.org/installer | php
  1. Install the SDK.
php composer.phar require shoplo/shoplo-multi-client
  1. Add doctrine annotations to autoload file or front controller.
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
  1. 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();