dominicwatts/onbuysdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dominicwatts/onbuysdk

最新稳定版本:1.3.7

Composer 安装命令:

composer create-project dominicwatts/onbuysdk

包简介

OnBuy PHP SDK

README 文档

README

OnBuy - UK Online Marketplace & Amazon Alternative

Unofficial PHP SDK to interact with OnBuy API

phpcs

PHPCompatibility

PHPStan

PHPUnit

Coverage Status

Install Instructions

composer require dominicwatts/onbuysdk

There is a composer archive at:

https://packagist.org/packages/dominicwatts/onbuysdk

Coveralls Status

API Documentation

https://docs.api.onbuy.com/?version=latest

Connection Details

The API settings page can be found in your Seller Control Panel. There are two sets of keys, Live and Test. You should use the Test keys when integrating with the API and switch to the Live Keys when you are ready to go live.

https://seller.onbuy.com/inventory/integrations/onbuy-api/

Usage

Get token

To connect to any API method, you first need to obtain your temporary secret access token.

require 'vendor/autoload.php';

$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
The access token is only valid for 15 minutes, after which a new token will need to be requested.

To debug

$auth->getResponse()->getBody();
$auth->getResponseArray();
$auth->getExpires(); 

General process

  1. Load token
  2. Build request
  3. Perform request and return results

Brands

use Xigen\Library\OnBuy\Brand\Brand;

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

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

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

Categories

Categories

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(); 

Categories Features

use Xigen\Library\OnBuy\Category\Feature;

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

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

Categories Technical Details

use Xigen\Library\OnBuy\Category\Technical;

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

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

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

Categories Variants

use Xigen\Library\OnBuy\Category\Variant;

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

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

Commission

use Xigen\Library\OnBuy\Commission\Commission;

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

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

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

Condition

use Xigen\Library\OnBuy\Condition\Condition;

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

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

Order

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();

Product

Submit

Product

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();

Product Listing

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();

Queue

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();

Seller

Seller

use Xigen\Library\OnBuy\Seller\Seller;

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

Seller Deliveries

use Xigen\Library\OnBuy\Seller\Delivery;

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

Seller Entities

use Xigen\Library\OnBuy\Seller\Entity;

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

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

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

Sites

use Xigen\Library\OnBuy\Site\Site;

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

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

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

统计信息

  • 总下载量: 1.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2020-08-14