PHP code example of s25 / prices-client

1. Go to this page and download the library: Download s25/prices-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/ */

    

s25 / prices-client example snippets



use S25\PricesApiClient\Client;

$client = new Client('http://service.url', 'SHOP-API-KEY');

$request = $client->requestBunchBestPrices()
    ->setBrandSlug('suzuki')
    ->addRawNumber('RAWPARTNUMBER1')
    ->addRawNumber('RAWPARTNUMBER2')
    ->addRawNumber('RAWPARTNUMBER3')
    ->addCurrencyCode('CUR');



use S25\PricesApiClient\Contracts\Request;

/** @var Request\BunchBestPricesRequestContract $request */

$bestPricesResponse = $request->perform();

var_dump($bestPricesResponse);



use S25\PricesApiClient\Contracts\Request;

/** @var Request\BunchBestPricesRequestContract $request */

$request->performAsync()
    ->then(static function ($bestPricesResponse) {
        var_dump($bestPricesResponse);
    })
    ->wait();



use S25\PricesApiClient\Contracts\Request;

/** @var Request\PaginateAllRequestContract $request */

foreach ($request->iterate() as [
    'brandSlug' => $brandSlug,
    'rawNumber' => $rawNumber,
    'number' => $number,
    'name' => $name,
    'prices' => $prices,
]) {
    foreach ($prices as $supplierSlug => $supplierPrices) {
        foreach ($supplierPrices as $currencyCode => [$price, $perPack]) {
            // ... just DO IT! 
        }
    }
}