PHP code example of baltyre / b2b-client

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

    

baltyre / b2b-client example snippets


use Baltyre\B2BClient\ApiConnector;
use Baltyre\B2BClient\CatalogLoader;
use Baltyre\B2BClient\PriceListLoader;
use Baltyre\B2BClient\StockLoader;

$apiKey = "<your-secrect-api-key>";
$baseUrl = "https://b2b.baltyre.com/api";
// for HU customers: $baseUrl = "https://b2b.baltyre.hu/api";
// for AT customers: $baseUrl = "https://b2b.osterreifen.com/api";

$connector = new ApiConnector($baseUrl, $apiKey);
$catalog = new CatalogLoader($connector);
$pricelist = new PriceListLoader($connector);
$stock = new StockLoader($connector);

$collection = $catalog->load();

class ProductData
{
    public string $code;                        // product code (PLU if present, otherwise CDB)
    public string $cdb;                         // product CDB code
    public ?string $plu;                        // product PLU code
    public string $name;                        // product name
    public ?string $ean;                        // EAN
    public ?string $manufacturer_code;          // code from manufacturer
    public ?Manufacturer $manufacturer; 
    public ?Pattern $pattern;
    public ?ParameterCollection $parameters;    // collection that containst `Parameter` objects
    public ?CategoryCollection $categories;     // collection that containst `Category` objects
    public ?Volume $volume;
    public ?Weight $weight;
}

class Manufacturer
{
    public string $code;                        // manufacturer internal code
    public string $name;                        // manufacturer public name
    public ?Picture $picture;
}

class Pattern
{
    public string $name;
    public ?string $description;
    public ?string $season;
    public ?string $purpose;
    public ?Picture $picture;
    public ?PictureCollection $pictures;        // collection that containst `Picture` objects
}

class Parameter
{
    public string $code;                        // parameter internal code
    public string $name;                        // parameter public name
    public ?string $value;                      // parameter value
}

class Category
{
    public string $code;                        // category internal code
    public string $name;                        // category public name
}

class Picture
{
    public string $uri;
}

$resizedPicture      = $picture->withFormat(1000, 1000); 
$resizedPictureInPng = $picture->withFormat(800, 800, Picture::PNG); 

$collection = $pricelist->load();

class ProductPricing
{
    public string $code;                        // product code (PLU if present, otherwise CDB)
    public string $cdb;                         // product CDB code
    public ?string $plu;                        // product PLU code
    public ?PricePolicy $price;
}

class PricePolicy
{
    public Price $sale;                         // end-customer price
    public Price $purchase;                     // your purchase (discounted) price
}

$collection = $stock->load();

class ProductStocks
{
    public string $code;                        // product code (PLU if present, otherwise CDB)
    public string $cdb;                         // product CDB code
    public ?string $plu;                        // product PLU code
    public ?ResourceCollection $stock;          // collection that containst `StockResource` objects
}

class StockResource
{
    public string $code;                        // stock code
    public string $name;                        // stock name
    public int $days;                           // approximate delivery time from order confirmation 
    public int $quantity;                       // number of pcs in this stock
    public bool $moreThanQuantity;              // determines if quantity is exact or minimal
}