quisui/order-basic-notification
Composer 安装命令:
composer require quisui/order-basic-notification
包简介
To ensure that we will not miss any sale and to keep track of the statuses of the orders a basic notification service needs to be created.
README 文档
README
Buckhill Challenge create a package for notifications - NotificationOrderStatusUpdater
To ensure that we will not miss any sale and to keep track of the statuses of the orders a basic notification service needs to be created.
Information
The Observer pattern is implemented through events and listeners.
The package defines an event class called OrderStatusUpdated, which contains the data that will be passed to the listeners.
The package also defines a listener class called SendOrderStatusNotification, which is responsible for sending a notification to a webhook when an order status is updated.
The listener is registered to listen to the OrderStatusUpdated event in the EventServiceProvider class.
When the OrderStatusUpdated event is fired (usually through code that updates an order's status), the SendOrderStatusNotification listener is triggered and the notification is sent via a webhook.
This implementation allows other developers to easily add new listeners for the OrderStatusUpdated event if they want to perform additional actions when an order status is updated, without having to modify the existing code.
This method will make this listener available inside your app:
src/ordernotificationprovider.php
$this->app['events']->listen(
'Quisui\OrderBasicNotification\Events\OrderStatusUpdated',
'Quisui\OrderBasicNotification\Listeners\SendOrderStatusNotification'
);
Installation
composer require quisui/order-basic-notification
Usage
- create a new NotificationOrderStatusUpdater object on any part of your code
- When you have your object prepared
<?php
use Quisui\OrderBasicNotification\NotificationOrderStatusUpdater;
new NotificationOrderStatusUpdater(...);
?>
- This wil require some required parameters as an array
<?php
$required = [
'order_uuid' => rand(0, 666),
'new_status' => 'status',
'timestamp' => 'dateTimeRequired',
'webhook_url' => 'https://webhook.site/81872e1a-5b97-4a0d-b32a-55365cc1b774',
'webhook_http_method' => 'post'
]
use Quisui\OrderBasicNotification\NotificationOrderStatusUpdater;
new NotificationOrderStatusUpdater($required);
?>
Now everytime that you want to consume any webhook url and send specific information you can use this basic event listener that will send your information
To run your tests:
- navigate to your project with cd command: vendor/quisui/order-basic-notification
- now you will need to run: on your terminal: ../../vendor/bin/phpunit tests/OrderStatusUpdatedTest.php
quisui/order-basic-notification 适用场景与选型建议
quisui/order-basic-notification 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 quisui/order-basic-notification 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quisui/order-basic-notification 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-26
