PHP code example of repat / plentymarkets-rest-client

1. Go to this page and download the library: Download repat/plentymarkets-rest-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

repat / plentymarkets-rest-client example snippets


use repat\PlentymarketsRestClient\PlentymarketsRestClient;

// path to store the configuration in
$configFilePath = ".plentymarkets-rest-client.config.php";
// $config only has to be set once like this
$config = [
    "username" => "PM_USERNAME",
    "password" => "PM_PASSWORD",
    "url" => "https://www.plentymarkets-system.tld",
];

// Handle (Guzzle) Exceptions yourself - optional 3rd parameter
$handleExceptions = PlentymarketsRestClient::HANDLE_EXCEPTIONS; // true
$handleExceptions = PlentymarketsRestClient::DONT_HANDLE_EXCEPTIONS; // false (default)

// Init
$client = new PlentymarketsRestClient($configFilePath, $config, $handleExceptions);

// After that just use it like so
$client = new PlentymarketsRestClient($configFilePath);

$client->get($path, $parameterArray);
$client->post($path, $parameterArray);
$client->put($path, $parameterArray);
$client->delete($path, $parameterArray);

// $parameterArray has to be a PHP array. It will be transformed into JSON automatically in case
// of POST, PUT and DELETE or into query parameters in case of GET.
// You don't _have_ to specify it, it will then just be empty
$parameterArray = [
    "createdAtFrom" => "2016-10-24T13:33:23+02:00"
];

// $path is the path you find in the Plentymarkets documentation
$path = "rest/orders/";

$client->singleCall("GET", $guzzleParameterArray);

$client->setJsonDecodeEnabled(PlentymarketsRestClient::JSON_DECODE_DISABLED);