PHP code example of dominicwatts / onbuysdk

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

    

dominicwatts / onbuysdk example snippets




$config = [
    'consumer_key' => 'test_consumer_key',
    'secret_key' => 'test_secret_key'
];

use Xigen\Library\OnBuy\Auth;

$auth = new Auth(
    $config
);

$auth->getToken(); // This is your token

use Xigen\Library\OnBuy\Brand\Brand;

$brand = new Brand($auth->getToken());

$brand->getBrand('keyword', 'asc', 10, 0);
$brand->getResponse();

$brand->getBrandById(123);
$brand->getResponse();

use Xigen\Library\OnBuy\Category\Category;

$category = new Category($auth->getToken());

$category->getCategory([
    'name' => 'test'
]);
$category->getResponse(); 

$category->getCategory([
    'name' => 'test',
    'category_type_id' => 1 // department
]);
$category->getResponse(); 

$category->getCategoryById(13490);
$category->getResponse(); 

use Xigen\Library\OnBuy\Category\Feature;

$categoryFeature = new Feature($auth->getToken());

$categoryFeature->getFeatureById(13490);
$categoryFeature->getResponse();

use Xigen\Library\OnBuy\Category\Technical;

$categoryTechnical = new Technical($auth->getToken());

$categoryTechnical->getTechnicalDetailById(13490);
$categoryTechnical->getResponse();

$categoryTechnical->getGroupById(13490, 125);
$categoryTechnical->getResponse();

use Xigen\Library\OnBuy\Category\Variant;

$categoryVariant = new Variant($auth->getToken());

$categoryVariant->getVariantId(13490);
$categoryVariant->getResponse();

use Xigen\Library\OnBuy\Commission\Commission;

$commission = new Commission($auth->getToken());

$commission->getTier();
$commission->getResponse();

$commission->getTierById(13490, 125);
$commission->getResponse();

use Xigen\Library\OnBuy\Condition\Condition;

$condition = new Condition($auth->getToken());

$condition->getCondition();
$condition->getResponse();

use Xigen\Library\OnBuy\Order\Order;

$order = new Order($auth->getToken());

$order->getOrder(
    [
        'status' => 'awaiting_dispatch',
        'previously_exported' => 0
    ],
    [
        'created' => 'asc'
    ]
);
$order->getResponse();

$order->getOrderById('T9R7V');
$order->getResponse();

$order->dispatchOrder([['order_id' => 'T9R7V']]);
$order->getResponse();

$order->dispatchOrder([
    [
        "order_id" => "T9R7V",
        "products" => [

            "sku" => "EXP-143-33S",
            "opc" => "PN8JV6",
            "quantity" => 125

        ],
        "tracking" => [
            "tracking_id" => "bar",
            "supplier_name" => "bar",
            "number" => "bar",
            "url" => "https://example.com/path-to-resource/"
        ]
    ]
]);
$order->getResponse();

$order->cancelOrder([
    'order_id' => 'T9R7V',
    'order_cancellation_reason_id' => 1,
    'cancel_order_additional_info' => 'Out of stock'
]);
$order->getResponse();

$order->refundOrder([
    'order_id' => 'T9R7V',
    'order_refund_reason_id' => 1,
    'seller_note' => 'Customer Return',
    'customer_note' => 'Item return received - Thank you!'
]);
$order->getResponse();

$order->getTrackingProviders();
$order->getResponse();


use Xigen\Library\OnBuy\Product\Product;

$product = new Product($auth->getToken());
$product->createProduct($insertArray);
$product->getResponse();

$product->testCreateProductByBatch($insertArray);
$product->getResponse();

$product->updateProduct($updateArray); // single array
$product->getResponse();

$product->updateProductByBatch($updateArray); // array of array
$product->getResponse();

$product->getProduct([
    'query' => 'test',
    'field' => 'name'
]);
$product->getResponse();


use Xigen\Library\OnBuy\Product\Listing;

$listing = new Listing($auth->getToken());

$listing->getListing(
    ['last_created' => 'asc'],
    ['sku' => 'test']
);
$listing->getResponse();

$listing->updateListingBySku([
    [
        "sku" => "EXP-143-33S",
        "price" => 126.34,
        "stock" => 125,
        "boost_marketing_commission" => 14.83
    ],
    [
        "sku" => "EXP-143-33L",
        "price" => 126.34,
        "stock" => 125,
        "boost_marketing_commission" => 14.83
    ],
]);
$listing->getResponse();

$listing->deleteListingBySku([
    "EXP-143-33S",
    "EXP-144-33L"
]);
$listing->getResponse();

$listing->createListing(
    'P5ZVSFF',
    [[
        "sku" => "EXP-143-33S",
        "group_sku" => "bar",
        "boost_marketing_commission" => 2.98
    ]]
);
$listing->getResponse();

$listing->createListingByBatch(
    [[
        "opc" => "PN8JV6",
        "condition" => "poor",
        "price" => 9.99,
        "stock" => 8,
        "delivery_weight" => 16,
        "handling_time" => 125,
        "free_returns" => "true",
        "warranty" => 7
    ]]
);
$listing->getResponse();

$listing->getWinningListing([
    "EXP-143-33S",
    "EXP-144-33L"
]);
$listing->getResponse();

use Xigen\Library\OnBuy\Queue\Queue;

$queue = new Queue($auth->getToken());

$queue->getQueue([
    'queue_ids' => '123,456',
    'status' => 'pending'
]);
$queue->getResponse();

$queue->getQueueById(123);
$queue->getResponse();

use Xigen\Library\OnBuy\Seller\Seller;

$seller = new Seller($auth->getToken());
$seller->getSellerById(123);
$seller->getResponse();

use Xigen\Library\OnBuy\Seller\Delivery;

$sellerDelivery = new Delivery($auth->getToken());
$sellerDelivery->getDelivery();
$sellerDelivery->getResponse();

use Xigen\Library\OnBuy\Seller\Entity;

$sellerEntity = new Entity($auth->getToken());

$sellerEntity->getEntity();
$sellerEntity->getResponse();

$sellerEntity->getEntityById(123);
$sellerEntity->getResponse();

use Xigen\Library\OnBuy\Site\Site;

$site = new Site($auth->getToken());

$site->getSite([
    'name' => 'test'
]);
$site->getResponse();

$site->getSiteById(123);
$site->getResponse();