PHP code example of melvin-hamilton-digital / peoplevox-api

1. Go to this page and download the library: Download melvin-hamilton-digital/peoplevox-api 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/ */

    

melvin-hamilton-digital / peoplevox-api example snippets


use MHD\Peoplevox\Api\Client;
use MHD\Peoplevox\Api\SessionProvider;
use MHD\Peoplevox\Data\Credentials;
use MHD\Peoplevox\Data\SearchClause;

$wsdl = "https://{your-WMS-Web-Address}/resources/integrationservicev4.asmx?wsdl";
$soapClient = new SoapClient($wsdl);
$credentials = new Credentials('clientId', 'username', 'password');

$sessionProvider = new SessionProvider($soapClient, $credentials);
$peoplevoxClient = new Client($soapClient, $sessionProvider);

# get sales orders
$salesOrders = $peoplevoxClient->getData('Sales orders');
# ...

# get sales orders using search clause
$salesOrders = $peoplevoxClient->getData(
    'Sales orders',
    1,
    10,
    SearchClause::fieldValueIn("Customer", ["John Doe", "Jane Doe"])
);
# ...

use MHD\Peoplevox\Utils\SaveTemplateGenerator;
use Nette\PhpGenerator\PsrPrinter;

# generate template
$saveTemplateGenerator = new SaveTemplateGenerator(
    $peoplevoxClient,
    new PsrPrinter()
);
$generatedTemplate = $saveTemplateGenerator->generateTemplate(
    'Sales orders',
    'Generated'
);
file_put_contents(
    './Generated/SaveSalesOrdersTemplate.php',
    $generatedTemplate
);

# use generated template

use MHD\Peoplevox\Api\Client;

$subscriptionId = $peoplevoxClient->subscribePostEvent(
    Client::EVENT_TYPE_AVAILABILITY_CHANGES,
    'https://example.org/ProcessAvailabilityChanges',
    'item={ItemCode}&amp;available={Available}'
);
# save event type and subscription ID