muhameryildirim/kolaygelsin-php-client

KolayGelsin.com 货运的 PHP 客户端

v1.0.0 2022-08-06 20:13 UTC

This package is auto-updated.

Last update: 2024-09-07 00:43:51 UTC


README

KolayGelsin 的 PHP 货运客户端。可在 packagist.org 上找到。

此包由我创建和维护,这意味着它不是官方包。

安装

该包可以通过 composer 获取

$ composer require muharremyildirim/kolaygelsin-php-client

依赖项

基本用法

更多示例请查看 /examples (@@todo) 文件夹。

创建新的货运

$client = new Client('PUT_YOUR_TOKEN_HERE');

$shipment = new IntegrationShipment($client);

$shipment->ShipmentItemList = [
    [
        'Width' => 10,
        'Length' => 20,
        'Height' => 30,
        'Weight' => 1,
        'ContentText' => 'Detay',
        'DeliveryNote' => 'Müşteri İrsaliye Numarası',
        'DeliveryNoteDate' => '2018-07-19T00:00:00+03:00',
        'HasCommercialValue' => true,
        'CustomerBarcode' => 'ShpItem1',
        'CustomerTrackingId' => 'ABC123456'
    ],
    [
        'Width' => 10,
        'Length' => 20,
        'Height' => 30,
        'Weight' => 1,
        'ContentText' => 'Detay',
        'DeliveryNote' => 'Müşteri İrsaliye Numarası',
        'DeliveryNoteDate' => '2018-07-19T00:00:00+03:00',
        'HasCommercialValue' => true,
        'CustomerBarcode' => 'ShpItem2',
        'CustomerTrackingId' => 'ABC123456'
    ]
];
$shipment->Recipient =  [
    'RecipientId' => 45
];
$shipment->SenderCustomer =  [
    'Address' => [
        'AddressId' => 4389
    ],
    'CustomerId' => 2124
];
$shipment->PayingParty = 1;
$shipment->PackageType = 2;
$shipment->OnlyDeliverToRecipient = true;
$shipment->CustomerSpecificCode = 'Shp1';

$response = $shipment->post();

var_dump($response,$response->Payload);

示例响应

^ MuharremYildirim\KolayGelsin\Models\Response {#4 ▼
  +"Model": "MuharremYildirim\KolayGelsin\Models\IntegrationShipment"
  +"Source": ""
  +"Target": "APIReadQ"
  +"Intent": null
  +"Tag": null
  +"JobOwner": "APIReadQ"
  +"JobId": "ESUBEBETA-2022-08-06-08-39-03-28725.886"
  +"Payload": array:4 [▼
    "ShipmentId" => 70000
    "CustomerSpecificCode" => "Shp1"
    "ShipmentItemLabelList" => array:2 [▶]
    "ShipmentTrackingLink" => "https://esubebeta.klyglsn.com/shipment"
  ]
  +"Username": "-"
  +"ResultCode": 200.0
  +"ResultMessage": ""
  +"StepCount": 0
  +"Channel": "Integration"
  +"Language": null
  +"Location": null
}

添加新的收件人

$client = new Client('PUT_YOUR_TOKEN_HERE');

$recipient = new Recipient($client);

$recipient->RecipientType = 2;
$recipient->Address =
    array(
        'CityId' => 34,
        'TownName' => 'Sancaktepe',
        'AddressTypeId' => 2,
        'AddressText' => 'Ekol Lojistik İmam Hatip Cd. Eyüp Sultan Mah. Sancaktepe İstanbul',
        'BuildingNumber' => 1,
        'FloorNumber' => 1,
        'DoorNumber' => 1,
        'BuldingName' => 'Ekol',
        'PostalCode' => '34500',
        'CompanyTitle' => 'Ekol Lojistik',
        'CompanyDepartment' => 'Kargo',
        'Direction' => 'Ekol lojistik lavinya tesisi samandıra',
    );
$recipient->RecipientTaxIdentityNumber = '1234567891';
$recipient->Email = 'ekol@ekol.com';
$recipient->RecipientTitle = 'Ekol Lojistik AŞ';
$recipient->Gsm = '123457890';
$recipient->OnlyDeliverToRecipient = false;
$recipient->SaveOutOfCoverage = false;

var_dump($recipient->post());

测试

此包使用 PHPUnit 库进行单元测试。您可以使用以下命令运行测试

对于 Unix

export KOLAYGELSIN_API_KEY='YOUR_API_KEY' && ./vendor/bin/phpunit

对于 Windows

set KOLAYGELSIN_API_KEY='YOUR_API_KEY' && ./vendor/bin/phpunit