jacobdekeizer/redjepakketje-client
最新稳定版本:v2.0.0
Composer 安装命令:
composer require jacobdekeizer/redjepakketje-client
包简介
Red je Pakketje API client for PHP
README 文档
README
Red je Pakketje API documentation
Installation
Get it with composer
composer require jacobdekeizer/redjepakketje-client
Usage
This readme shows basic usage of this package, for all available options see the class definitions and the api documentation.
Create the client
$client = new \JacobDeKeizer\RedJePakketje\Client(); $client->setApiKey('api_key');
Shipments
List shipments
$shipmentsList = $client->shipments()->all( new \JacobDeKeizer\RedJePakketje\Parameters\Shipments\All() // optional );
List recently created shipments
Retrieves shipments from the last 7 days.
$shipmentsList = $client->shipments()->allRecentlyCreated();
Get shipment
$shipment = $client->shipments()->get('tracking_code'); // for example check the shipment status $isDelivered = $shipment->getStatus() === \JacobDeKeizer\RedJePakketje\Models\Shipment\Enums\ShipmentStatus::DELIVERED;
Create shipment
$shipment = (new \JacobDeKeizer\RedJePakketje\Models\Shipment\CreateShipment()) ->setCompanyName('Boeren BV') ->setName('Gijs Boersma') ->setStreet('Lange laan') ->setHouseNumber(29) ->setHouseNumberExtension('a') ->setZipcode('9281EM') ->setCity('Zevenaar') ->setTelephone('0602938172') ->setEmail('noreply@example.com') ->setNote('Some note') ->setDeliveryDate(date('Y-m-d')) ->setProduct(\JacobDeKeizer\RedJePakketje\Models\Shipment\Enums\ShipmentProduct::SAME_DAY_PARCEL_STANDARD) ->setReference('reference') ->setNote('my_note') ->setSender('sender_uuid'); // optionally set product options $shipment->setProductOptions( (new \JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption()) ->setOption(\JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption::OPTION_ALLOW_NEIGHBOURS) ->setValue(true), (new \JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption()) ->setOption(\JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption::OPTION_REQUIRE_SIGNATURE) ->setValue(false), (new \JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption()) ->setOption(\JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption::OPTION_AGE_CHECK_18) ->setValue(false), (new \JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption()) ->setOption(\JacobDeKeizer\RedJePakketje\Models\Shipment\ProductOption::OPTION_ALLOW_NEIGHBOURS) ->setValue(true) ->setMaxAttempts(2) ); $shipmentResponse = $client->shipments()->create( $shipment, new \JacobDeKeizer\RedJePakketje\Parameters\Shipments\Create() // optional ); $label = $shipmentResponse->getLabel();
Update shipment
$shipment = $client->shipments()->update( 'tracking_code', (new \JacobDeKeizer\RedJePakketje\Models\Shipment\UpdateShipment()) ->setProduct(\JacobDeKeizer\RedJePakketje\Models\Shipment\Enums\ShipmentProduct::NEXT_DAY_PARCEL_LARGE) );
Cancel shipment
$shipment = $client->shipments()->cancel('tracking_code');
Get label of a shipment
$label = $client->shipments()->getLabel( 'tracking_code', (new \JacobDeKeizer\RedJePakketje\Parameters\Shipments\GetLabel()) // optional );
Return shipments
List return shipments
$returnShipmentsList = $client->returnShipments()->all( new \JacobDeKeizer\RedJePakketje\Parameters\ReturnShipments\All() // optional );
Get return shipment
$returnShipment = $client->returnShipments()->get('return_shipment_uuid');
Create return shipment
$returnShipment = (new \JacobDeKeizer\RedJePakketje\Models\ReturnShipment\CreateReturnShipment()) ->setName('Gijs Boersma') ->setStreet('Lange laan') ->setHouseNumber(29) ->setHouseNumberExtension('a') ->setZipcode('9281EM') ->setCity('Zevenaar') ->setTelephone('0602938172') ->setEmail('noreply@example.com') ->setReference('Bestelling 123') ->setNote('Some note') ->setReceiverName('My company') ->setProduct(\JacobDeKeizer\RedJePakketje\Models\ReturnShipment\Enums\ReturnShipmentProduct::SAME_DAY_PARCEL_MEDIUM) ->setNote('some text') ->setSender('sender_uuid'); $returnShipmentResponse = $client->returnShipments()->create($returnShipment);
Cancel return shipment
$returnShipment = $client->returnShipments()->cancel('return_shipment_uuid');
Senders
List senders
$senderList = $client->senders()->all();
Get sender
$sender = $client->senders()->get('sender_uuid');
Update sender
$sender = $client->senders()->update( 'sender_uuid', (new \JacobDeKeizer\RedJePakketje\Models\Sender\UpdateSender()) ->setName('My Webshop 123') ->setTelephone('+31612345678') ->setStreet('Streetname') ->setHouseNumber('11') ->setZipcode('8327SD') ->setCity('Breda') );
Create sender
$sender = $client->senders()->create( (new \JacobDeKeizer\RedJePakketje\Models\Sender\CreateSender()) ->setReference('A1234567890Q') ->setName('My Webshop') ->setTelephone('+31612345678') ->setStreet('Streetname') ->setHouseNumber('11') ->setZipcode('8327SD') ->setCity('Breda') );
Deactivate sender
$client->senders()->deactivate( 'sender_uuid', (new \JacobDeKeizer\RedJePakketje\Models\Sender\DeactivateSender()) ->setInactiveFrom(date('Y-m-d', strtotime('+1 day'))) );
Pick-up Locations
List pick-up locations
$pickUpLocationsList = $client->pickUpLocations()->all( new JacobDeKeizer\RedJePakketje\Parameters\PickUpLocation\All() // optional );
Get pick-up location
$pickUpLocation = $client->pickUpLocations()->get('pick_up_location_uuid');
Create pick-up location
$pickUpLocation = $client->pickUpLocations()->create( (new JacobDeKeizer\RedJePakketje\Models\PickUpLocation\CreatePickUpLocation()) ->setName('Warehouse') ->setStreet('Streetname') ->setHouseNumber('11') ->setHouseNumberExtension('a') ->setZipcode('8327SD') ->setCity('Breda') ->setAvailableDays([1, 2, 3, 4, 5]) ->setTypes([\JacobDeKeizer\RedJePakketje\Models\PickUpLocation\Enums\PickUpLocationType::PICK_UP_POINT]) );
Update pick-up location
$pickUpLocation = $client->pickUpLocations()->update( 'pick_up_location_uuid', (new \JacobDeKeizer\RedJePakketje\Models\PickUpLocation\UpdatePickUpLocation()) ->setAvailableDays([1, 2, 3, 4, 5, 6, 7]) );
Pick-up rules
List pick-up rules
$pickUpRulesList = $client->pickUpRules()->all('sender_uuid');
Create pick-up rule
$pickUpRule = $client->pickUpRules()->create( 'sender_uuid', (new \JacobDeKeizer\RedJePakketje\Models\PickUpRule\CreatePickUpRule()) ->setPickUpLocation('pick_up_location_uuid') ->setStartDate(date('Y-m-d')) );
Update pick-up rule
$pickUpRule = $client->pickUpRules()->update( 'sender_uuid', 'pick_up_rule_uuid', (new \JacobDeKeizer\RedJePakketje\Models\PickUpRule\UpdatePickUpRule()) ->setStartDate(date('Y-m-d', strtotime('+1 day'))) );
Delete pick-up rule
$client->pickUpRules()->delete( 'sender_uuid', 'pick_up_rule_uuid' );
Contacts
List contacts
$contactsList = $client->contacts()->all();
Get contact
$contact = $client->contacts()->get('contact_uuid');
Create contact
$contact = $client->contacts()->create( (new \JacobDeKeizer\RedJePakketje\Models\Contact\CreateContact()) ->setFirstName('John') ->setLastName('Doe') ->setEmail('john.doe@example.com') ->setTelephone('+31612345678') ->setGender(\JacobDeKeizer\RedJePakketje\Models\Contact\Enums\Gender::MALE) ->setReference('reference') );
Update contact
$contact = $client->contacts()->update( 'contact_uuid', (new \JacobDeKeizer\RedJePakketje\Models\Contact\UpdateContact()) ->setFirstName('Jane') ->setLastName('Doe') ->setEmail('jane.doe@example.com') ->setTelephone('+31612345678') ->setGender(\JacobDeKeizer\RedJePakketje\Models\Contact\Enums\Gender::FEMALE) ->setReference('reference') );
Exceptions
You can catch the RedJePakketjeException and check if there is a response and response error or if it is a json error:
// example bad call try { $shipmentResponse = $client->shipments()->create( (new \JacobDeKeizer\RedJePakketje\Models\Shipment\CreateShipment()), ); } catch (\JacobDeKeizer\RedJePakketje\Exceptions\RedJePakketjeException $exception) { if ($exception->hasResponse()) { var_dump($exception->getResponse()); } if ($exception->hasResponseError()) { var_dump($exception->getResponseError()->getErrorCode()); var_dump($exception->getResponseError()->getErrorMessage()); var_dump($exception->getResponseError()->getErrorDetails()); } if ($exception->isJsonError()) { var_dump($exception->getPrevious()); } }
Code sniffer
Check: composer phpcs
Autofix: composer phpcbf
jacobdekeizer/redjepakketje-client 适用场景与选型建议
jacobdekeizer/redjepakketje-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.1k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「client」 「red je pakketje」 「redjepakketje」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jacobdekeizer/redjepakketje-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jacobdekeizer/redjepakketje-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jacobdekeizer/redjepakketje-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 15.1k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-07