matejch/webareal-api-handler

获取和发送数据到 webareal 类型电商平台的 API

1.1.0 2021-10-18 12:40 UTC

This package is auto-updated.

Last update: 2024-09-18 18:43:51 UTC


README

获取和发送数据到 webareal 类型电商平台的 API

完整文档 在这里

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一

php composer.phar require --prefer-dist matejch/webareal-api-handler "^1.0"

或者

"matejch/webareal-api-handler": "^1.0"

将其添加到您的 composer.json 文件的 require 部分。

用法

您需要从您的 webareal 电商平台获取 用户名密码令牌(API密钥)。API密钥位于 API 选项卡中

登录请求中检索用于请求的令牌载体

所有类都扩展自 \matejch\webarealApiHandler\WebarealHandler

/** create handler, constructor requires username, password, adn token */
/** all can be acquired from your webareal admin interface */
$handler = new \matejch\webarealApiHandler\WebarealHandler($username,$password,$apiToken);

/** New handler instance can be also created with json file, that contains username, password, apiKey and url(optional) */

$handler = \matejch\webarealApiHandler\WebarealHandler::createFromFile('path_to_the_json_file');

/** login before other requests */
$handler->login();

/** this is function for testing successful login, returns message whether access was granted */
$handler->test();

/** 
 * You can check info about how many request you have remaining, 
 * what's your limit and whether you are blocked 
 */
$handler->apiInfo()

/** API subdomain */
/** If you don't use subdomain set in class use this method*/
$handler->setBaseUrl($apiSubDomainUrl);

客户

有关客户端点的信息 这里

/** Only one api endpoint exists, and that is for getting list of customers */
$customers = new \matejch\webarealApiHandler\WCustomers($username,$password,$apiToken);
$customers->login();

$customers->asArray = true; // optional

/** also query string for searching specific customers can be set*/
$customers->searchBy(['limit' => 20,
                      'offset' => 0,
                      'sortBy' => 'id',
                      'sortDirection' => 'desc',
                      'findBy' => 'id',
                      'searchedString' => 'search string here']);

/** data can be returned as json string or array of customers */
$customers->get();

产品

有关产品端点的信息 这里

新的批量产品更新方法

/**For mass update use */ 

function setFieldsAsString(array_of_products)
$products = new \matejch\webarealApiHandler\WProduct($username,$password,$apiToken);
$products->login();

$products->asArray = true; // optional

/** get list of products */
/** filter can be set with $products->searchBy(array of searchable options) */
$products->get();

/** 
 * id of product necessary for update, delete, view can be obtained with get() method, 
 * or through csv from your admin interface
 */

/** create new product */
$products->setFields(['name' => 'Name', ....]);
$products->create();

/** update existing product, you must know id beforehand */
$products->setFields(['secondName' => 'Second', ....]);
$products->update($id);

/** delete existing product, you must know id beforehand */
$products->delete($id);

/** detail info about one product, you must know id beforehand */
$products->view($id);

/** update and create multiple products at once */

$products->setFields(['name' => 'product', ....]);

$products->createMultiple();

/** to update multiple product id is required for every product */
$products->updateMultiple();

订单

有关订单端点的信息 这里

$orders = new \matejch\webarealApiHandler\WOrder($username,$password,$apiToken);
$orders->login();

$orders->get();

$orders->states();

$orders->view($id);

$products->setFields(['firstname' => 'Jane', 'lastname' => 'Doe',...]);
$orders->update($id);

$orders->delete($id)

产品属性

有关产品属性端点的信息 这里

$property = new \matejch\webarealApiHandler\WProductProperty($username,$password,$apiToken);
$property->login();

$property->get();

$property->view($id);

$property->setFields(['name' => 'Color']);
$property->create($id);

/** before calling update, setFields must set fields you want to update on property */
$property->setFields(['name' => 'Color']);
$property->update($id);

/** delete property */
$property->delete($id);

/** create and update multiple */
$property->setFields(['name' => 'Color']);
$property->createMultiple();

/** id for every property must be set when updating */
$property->updateMultiple();

产品变体

有关产品变体端点的信息 这里

/** Product variants are products connected to other product */
$variants = new \matejch\webarealApiHandler\WProductVariants($username,$password,$apiToken);
$variants->login();

/** get list of variants, can be search by using searchBy method */
$variants->get();

$variants->view($id);

/** before calling create, setFields must set fields you want to update on property */
$variants->setFields(['idProduct' => 9,'name' => 'Jacket']);
$variants->create($id);

/** before calling update, setFields must set fields you want to update on property */
$variants->setFields(['idProduct' => 9,'name' => 'Jacket']);
$variants->update($id);

/** delete property */
$variants->delete($id);

/** create and update multiple */
$variants->setFields(['name' => 'Color']);
$variants->createMultiple();

/** id for every variant must be set when updating */
$variants->updateMultiple();

完成

  • 登录请求
  • 测试请求
  • API 信息
  • 获取客户
  • 获取产品
  • 创建产品
  • 获取产品信息
  • 删除产品
  • 更新产品
  • 创建多个产品
  • 更新多个产品
  • 创建属性
  • 更新属性
  • 获取属性
  • 更新属性
  • 删除属性
  • 获取属性列表
  • 创建产品变体
  • 获取产品变体列表
  • 获取产品变体
  • 创建产品变体
  • 更新产品变体
  • 获取产品变体列表
  • 更新产品变体列表
  • 删除产品变体
  • 获取属性值列表
  • 创建属性值
  • 创建属性值
  • 获取属性值信息
  • 删除特定的属性值
  • 更新特定的属性值
  • 获取订单列表
  • 更新订单
  • 获取订单信息
  • 更新订单
  • 删除订单
  • 获取所有订单状态
  • 更新订单产品
  • 更新订单产品
  • 删除订单产品

待办事项