seniorprogramming / postisgate
Postis API 客户端
Requires
- php: >=7.1.3
- laravel/framework: 5.7.*
- php-curl-class/php-curl-class: ^7.1
Requires (Dev)
- phpunit/phpunit: 5.5.2
This package is auto-updated.
Last update: 2024-09-24 17:04:23 UTC
README
为 Laravel 实现的简单 PostisGate 实现。
安装
通过 Composer 安装此包。
从终端运行 Composer require 命令
composer require seniorprogramming/postisgate
现在,您只需将包的服务提供者和别名添加到配置文件中。为此,打开您的 config/app.php
文件。
在 providers
数组中添加新行
SeniorProgramming\PostisGate\Providers\ApiServiceProvider::class,
可选地,在 aliases
数组中添加新行
'PostisGate' => SeniorProgramming\PostisGate\Facades\PostisGate::class,
重要,在 .env 中添加 PostisGate 凭据
POSTISGATE_USERNAME= POSTISGATE_PASSWORD= POSTISGATE_API=
并在 config/filesystems.php
'postisgate' => [ 'driver' => 'local', 'root' => storage_path('postisgate'), ],
现在,您就可以开始在应用程序中使用 PostisGate API 客户端了。
概述
查看以下主题之一,以了解更多关于 PostisGate API 客户端的信息
用法
PostisGate API 客户端提供以下方法供使用
Login()
在调用方法时检索用于身份验证的令牌。
PostisGate::login()
CreateShipment()
为客户订单创建托运单。无需登录命令。它会自动完成。
PostisGate::createShipment()
createShipment()
方法将返回一个对象数组,包含:clientOrderDate、createdDate、sendType、productCategory、courierId、shipmentId、shipmentParcels[parcelReferenceId、parcelType、itemCode、itemDescription1、barCode]、clientOrderId。
GetShipmentLabel()
检索 AWB 到 pdf 文件。无需登录命令。它会自动完成。
PostisGate::getShipmentLabel()
getShipmentLabel()
方法将返回 TRUE。
异常
如果出现错误,PostisGate 包将抛出异常。这样,使用 PostisGate 包调试代码或根据异常类型处理错误会更简单。PostisGate 包可以抛出以下异常
示例
Login()
PostisGate::login(['name'=>'your_username', 'password'=>'your_password'])
CreateShipment()
PostisGate::createShipment([ "clientId" => "your_client_id", "clientOrderDate" => "2018-04-12 07:03:03", "clientOrderId" => "0005", "paymentType" => "CASH", "productCategory" => "Standard Delivery", "recipientLocation" => [ "addressText" => "Cal. Floreasca 40", "contactPerson" => "Gheorghe Ion", "country" => "Romania", "county" => "Bucuresti", "locality" => "Bucuresti", "locationId" => "1", "name" => "Georghe Ion", "phoneNumber" => "0700000000", "postalCode" => "123456", ], "sendType" => "FORWARD", "senderLocation" => [ "addressText" => "Calea Bucuresti 22, Tunari, Ilfov", "buildingNumber" => "22", "contactPerson" => "depozit", "country" => "Romania", "county" => "Ilfov", "locality" => "Tunari", "locationId" => "149", "name" => "Depozit central", "phoneNumber" => "0212210000", "postalCode" => "012345", "streetName" => "Calea Bucuresti", ], "shipmentParcels" => [[ "itemCode" => "AB1564", "itemDescription1" => "product_name", "itemUOMCode" => "BUC", "parcelBrutWeight" => 20, "parcelDeclaredValue" => 0, "parcelReferenceId" => "PRE0005", "parcelType" => "PACKAGE", ]], "shipmentPayer" => "SENDER", "shipmentReference" => "SRE0005", "sourceChannel" => "ONLINE", ])
GetShipmentLabel()
PostisGate::getShipmentLabel([ 'shipmentId' => '1234567890', 'filename' => '0005_1234567890.pdf' ])
有关更多信息,请参阅 PostisgGate API 文档。
如果您想创建更多操作,请创建一个类在 src/Operations
文件夹中,就像现有的一个,并通过调用
PostisGate::the_name_of_the_class([parameters])