kerekit/copy-depo-xml-export-client

v0.2.4 2024-09-03 15:19 UTC

This package is auto-updated.

Last update: 2024-11-03 15:49:39 UTC


README

Features

Implemented endpoints (methods):

  • categoryList
  • priceAndStockByProductCode
  • productAttributes

Endpoints (methods) to be implemented:

  • stockInformation
  • bevasarloListaCreate
  • priceAndStockByCategory
  • priceAndStockInfo
  • invoices
  • promotions

Installation

Install the latest version with:

$ composer require kerekit/copy-depo-xml-export-client

Basic Usage

<?php

use Kerekit\CopyDepoXmlExportClient\Client;
use Kerekit\CopyDepoXmlExportClient\Resources\SimpleStock;

// Init client
$client = new Client ('your-auth-code');

// Query categories
echo "Querying categories...\n";
$categories = $client->categoryList ();
$firstCategory = reset ($categories);

// Query product details
echo "Querying products of category '$firstCategory->name'...\n";
$products = $client->productAttributes ([
    'categoryId'  => $firstCategory->id,
    'description' => true,
    'imageUrl'    => true,
]);
$firstProduct = reset ($products);

// Query product stock & price only
echo "Querying price & stock for found product '$firstProduct->name'...\n";
$ids = [$firstProduct->id];
$pricesAndStocks = $client->priceAndStockByProductCode (['productIds' => $ids]);
$priceAndStock = reset ($pricesAndStocks);
switch ($priceAndStock->simpleStock) {
  case SimpleStock::GREEN:
    echo "Product is in stock.\n";
    break;

  case SimpleStock::YELLOW:
    echo "Product is expected to be in stock shortly.\n";
    break;

  case SimpleStock::RED:
    echo "Product can be pre-ordered.\n";
    break;

  default:
    throw new \Exception ("Unexpected stock: '$priceAndStock->simpleStock'");
    break;
}