dividebv/phpdivideiq

Divide IQ 的 PHP 连接库

v0.6.0 2018-09-07 07:29 UTC

This package is auto-updated.

Last update: 2024-09-12 18:09:44 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

一个用于连接 Divide.IQ 的 PHP 库。

安装

Composer

composer require dividebv/phpdivideiq

示例用法

use DivideBV\PHPDivideIQ\DivideIQ;

$username = 'user';          // You will receive this from the provider.
$password = 'password';      // You will receive this from the provider.
$environment = 'production'; // May also be `staging` or an arbitrary URL.

// A file storing the connection status.
$file = new SplFileObject('persist.iq.txt', 'c+');

if ($file->getSize()) {
    // The file already exists, instantiate DivideIQ using the file.
    $divideIq = DivideIQ::fromFile($file);
} else {
    // File doesn't exist. Instantiate DivideIQ using the constructor.
    $divideIq = new DivideIQ($username, $password, $environment);
    $divideIq->setFile($file);
}

// Access a resource provided by this Divide.IQ server.
$result = $divideIq->request('stockbase_stock');

调试

如果您像上面的示例一样实现了这个库,那么调试的第一步就是删除 persist.iq.txt 文件。这是一个包含连接凭证的 JSON 文件。删除它将强制库重新开始,通过登录您的用户名和密码来进行。

注意:这仅在连接之前工作过的情况下有帮助。

OrderRequest

$this->result = $this->divideIq->request('stockbase_orderrequest', $this->payload, 'POST');

$this->payload = array(
                'OrderDelivery' => (object) $orderDelivery,
                'OrderHeader' => (object) $orderHeader,
                'OrderLines' => $orderLines,
            );

示例

$this->payload = {
       "OrderDelivery": {
         "Person": {
         "Gender": "Male",
         "Initials": "J",
         "FirstName": "John",
         "SurnamePrefix": "",
         "Surname": "Doe",
         "Company": "Stockbase",
         "EmailAddress": ""
       },
       "Address": {
         "Street": "Koraalrood",
         "StreetNumber": "33",
         "StreetNumberAddition": "A",
         "ZipCode": "2718SB",
         "City": "Zoetermeer",
         "CountryCode": "NLD"
       }
     },
     "OrderHeader": {
       "OrderNumber": "1574425588",
       "TimeStamp": "2019-11-15T15:56:36.1187035Z"
     },
     "OrderLines": 
     [{
      "Number": "1",
      "EAN": "8700000000001",
      "Amount": "1",
      "Price": "1.95"
     },
     {
      "Number": "2",
      "EAN": "8700000000002",
      "Amount": "1",
      "Price": "2.95"
    },
    {
     "Number": "3",
     "EAN": "8700000000003",
     "Amount": "1",
     "Price": "3.95"
    }]
  }