jtl/fulfillment-sdk

This package is abandoned and no longer maintained. The author suggests using the jtl/fulfillment-api-sdk package instead.

JTL-Fulfillment Netzwerk SDK project.

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Type:project

1.0.13 2018-03-21 10:21 UTC

This package is auto-updated.

Last update: 2021-03-02 10:12:46 UTC


README

Requirements

  1. PHP 5.6
  2. Composer
  3. Git

Initial Setup

git clone git@gitlab.jtl-software.de:Fulfillment/sdk.git
chown -R www-data:www-data ./sdk
composer install --no-dev

Using

Rest API URL

https://fulfillment.jtl-software.de/ext/v1/

List of products

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

/** @var \Jtl\Fulfillment\Sdk\Entities\v1\ProductCollection $collection */
$collection = $client->controller(ControllerType::PRODUCT)->page(1)->perPage(20)->findAll();

Single product

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

/** @var \Jtl\Fulfillment\Sdk\Entities\v1\Product $product */
$product = $client->controller(ControllerType::PRODUCT)->find('<product_primary_key>');

Create or update product

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

$product = (new \Jtl\Fulfillment\Sdk\Entities\v1\Product())
    ->setName('Test')
    ->setSku('aaw8')
    ->setLength(1.2)
    ->setHeight(3.4)
    ->setWidth(5.0)
    ->setProductWeight(3.3)
    ->setShippingWeight(4.1)
    ->setManufacturerNumber('Test-aaw8')
    ->setVat(19.0)
    ->setCategories(['<category_primary_key>']);

/** @var \Jtl\Fulfillment\Sdk\Entities\v1\Product $product */
$product = $client->controller(ControllerType::PRODUCT)->save($product);

Add product picture

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

/** \Jtl\Fulfillment\Sdk\Entities\v1\Picture $picture */
$picture = $client->controller(ControllerType::PRODUCT)->savePicture(
    '<product_primary_key>',
    (new \Jtl\Fulfillment\Sdk\Entities\v1\Picture())
        ->setData(base64_encode(file_get_contents('<path_to_picture_file_>')))
);

Delete product picture

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

$result = $client->controller(ControllerType::PRODUCT)->deletePicture('<product_primary_key>', '<picture_primary_key>');

Delete product

use Jtl\Fulfillment\Sdk\Controller\ControllerType;

$client = new \Jtl\Fulfillment\Sdk\Client('<fulfillment_rest_api_url>', '<your_api_token>');

$result = $client->controller(ControllerType::PRODUCT)->delete('<product_primary_key>');