inshore / laravel-bookwhen
Bookwhen API SDK,为Laravel应用程序提供Bookwhen预订平台的即插即用访问。
Requires
- inshore/bookwhen: ^0.9.5
Requires (Dev)
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2024-09-30 02:05:29 UTC
README
Bookwhen API的Laravel SDK套件。
安装
要求
PHP 8.1 及以上。
Composer
$ composer require inshore/laravel-bookwhen
使用方法
首先,确保通过运行 vendor:publish 命令已发布配置和其他项目。
php artisan vendor:publish
选择InShore\Bookwhen\ServiceProvider选项。
Provider: InShore\Bookwhen\ServiceProvider .....................................................................................................
现在只需将您的Bookwhen API密钥添加到.env文件中。
BOOKWHEN_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
您可以通过在浏览器中访问https://:8000/bookwhen/或根据您的设置来检查一切是否正常工作。
除了这些,要实际访问您的Bookwhen数据,请包含Bookwhen外观。
use InShore\Bookwhen\Facades\Bookwhen;
然后按照以下方式使用...
附件
实现https://api.bookwhen.com/v2#tag/Attachment
附件
https://api.bookwhen.com/v2#tag/Attachment/paths/~1attachments/get
// Fetch attachments accessible by the API token. $attachments = Bookwhen::attachments());
过滤器
过滤器参数可以作为函数参数传递。
标题 - 根据文件标题文本进行过滤。
文件名 - 根据文件名进行过滤。
文件类型 - 根据文件类型进行过滤。
// Fetch attachments accessible by the API token. $attachments = Bookwhen::attachments(fileName: 'CV')); $attachments = Bookwhen::attachments(fileType: 'pdf')); $attachments = Bookwhen::attachments(title: 'Title to filter by')); $attachments = Bookwhen::attachments(fileName: 'CV', fileType: 'pdf', title: 'Title to filter by'));
附件
https://api.bookwhen.com/v2#tag/Attachment/paths/1attachments1%7Battachment_id%7D/g
// Returns the attachment for the provided attachment ID.
$attachment = Bookwhen::attachment('ev-smij-20200530100000' );
###类通行证
实现https://api.bookwhen.com/v2#tag/ClassPass
ClassPasses
https://api.bookwhen.com/v2#tag/ClassPass/paths/~1class_passes/get
// Fetch class passes accessible by the API token. $classPasses = Bookwhen::classPasses());
过滤器
过滤器参数可以作为函数参数传递
标题 - 根据通行证的标题文本进行过滤。
详细信息 - 根据详细信息进行过滤。
使用类型 - 根据通行证类型:个人或任何类型进行过滤。
成本 - 根据精确值或使用比较运算符进行过滤。例如,filter[cost][gte]=2000
gt - 大于
gte - 大于等于
lt - 小于
lte - 小于等于
eq - 等于
使用限额 - 根据通行证使用限额进行过滤。这也接受比较运算符,如成本。
useRestrictedForDays - 根据通行证天数限制进行过滤。这也接受比较运算符,如成本。
// Fetch class passes accessible by the API token. $classPasses = Bookwhen::classPasses()); $classPasses = Bookwhen::classPasses(title: 'Title to filter by'));
ClassPass
https://api.bookwhen.com/v2#tag/ClassPass/paths/~1class_passes~1%7Bclass_pass_id%7D/get
// Returns the class pass for the provided class pass ID. $classPass = Bookwhen::classPass('ev-smij-20200530100000');
事件
https://api.bookwhen.com/v2#tag/Event
事件
https://api.bookwhen.com/v2#tag/Event/paths/~1events/get
// Returns the event for the provided event ID. $event = Bookwhen::events();
过滤器
日历 - 限制到给定日历(计划页面)的事件。
条目 - 限制到给定条目。
位置 - 包含位置标签的数组。
标签 - 包含标签单词的数组。
标题 - 要搜索的条目标题的数组。
详细信息 - 要搜索的条目详细信息的数组。
从 - 获取事件的起始时间(格式为YYYYMMDD或YYYYMMDDHHMISS)。默认为今天。
到 - 获取事件截至时间(格式为YYYYMMDD或YYYYMMDDHHMISS)
紧凑 - 布尔值:将课程中的事件合并为单个虚拟事件。
包含
默认情况下,事件将不会填充其附件、位置和门票。
要检索包含关联的事件,只需为所需关联传递布尔值true。
includeAttachments includeLocation includeTickets includeTickets.class_passes includeTickets.events
例如,要检索包含其位置和门票的事件。
// Returns the event for the provided event ID. $event = Bookwhen::events(title: 'Title to filter by'));
事件
https://api.bookwhen.com/v2#tag/Event/paths/1events1%7Bevent_id%7D/get
// Returns the event for the provided event ID. $event = Bookwhen::event('ev-smij-20200530100000');
过滤器
事件列表可以根据API文档进行筛选。
包含
默认情况下,事件将不会填充其附件、位置和门票。
要检索包含关联的事件,只需为所需关联传递布尔值true。
includeAttachments includeLocation includeTickets.class_passes includeTickets.events
例如,要检索包含其位置和门票的事件。
// Returns the event for the provided event ID. $event = Bookwhen::event(eventId: 'ev-smij-20200530100000', includeLocation: true, includeTickets: true);
位置
实现 https://api.bookwhen.com/v2#tag/Location
位置
https://api.bookwhen.com/v2#tag/Location/paths/~1locations/get
// Fetch events accessible by the API token. $locations = Bookwhen::locations()); // Returns the location for the provided location ID.
过滤器
addressText - 限制包含地址文本的地点。
additionalInfo - 通过附加信息中包含的文本进行筛选。
// Fetch events accessible by the API token. $locations = Bookwhen::locations(addressText: 'Remote')); // Returns the location for the provided location ID.
位置
https://api.bookwhen.com/v2#tag/Location/paths/1locations1%7Blocation_id%7D/get
// Returns the location for the provided location ID. $location = Bookwhen::location('ev-smij-20200530100000');
门票
实现 https://api.bookwhen.com/v2#tag/Ticket
门票
https://api.bookwhen.com/v2#tag/Ticket/paths/~1tickets/get
// Fetch tickets for the given event. $eventId = 'ev-smij-20200530100000'; $client->tickets($eventId);
包含
默认情况下,门票将不会填充其附件、事件和位置。
要检索包含关联的事件,只需为所需关联传递布尔值true。
includeAttachments includeLocation includeTickets.class_passes includeTickets.events
// Fetch tickets for the given event. $eventId = 'ev-smij-20200530100000'; $client->tickets($eventId, includeAttachments: true);
门票
https://api.bookwhen.com/v2#tag/Ticket/paths/1tickets1%7Bticket_id%7D/get
// Retrieve a single ticket. $ticketId = 'ti-sboe-20200320100000-tk1m'; $client->ticket($ticketId);
包含
默认情况下,门票将不会填充其附件、事件和位置。
要检索包含关联的事件,只需为所需关联传递布尔值true。
includeAttachments includeLocation includeTickets.class_passes includeTickets.events
// Retrieve a single ticket. $client->ticket('ti-sboe-20200320100000-tk1m', includeAttachments: true););
日志记录
提供了完整的syslog级别日志记录,可以通过在实例化Client时传递一个级别来启用。如RFC 5424所示,该协议描述了syslog协议,以下列出了强度级别。
DEBUG:详细的调试信息。INFO:处理正常事件。例如:SQL日志NOTICE:处理正常事件,但更为重要的事件WARNING:警告状态,在此状态之前应该采取行动以避免错误ERROR:错误状态,表示有问题需要立即处理CRITICAL:临界状态。例如:系统组件不可用ALERT:应采取立即行动。这应触发一些警报并在夜间唤醒你。EMERGENCY:系统不可用时使用。
$bookwhen = new Bookwhen()->debug('Debug');
测试
工作进行中
$ composer phpunit
贡献
有关详细信息,请参阅https://github.com/inshore/laravel-bookwhen/blob/main/CONTRIBUTING.md。
支持
如果您需要此包的帮助或将其实现在自己的项目或业务中...
<script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="danielmullin" data-color="#FFDD00" data-emoji="" data-font="Cookie" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#000000" data-coffee-color="#ffffff" ></script>https://www.buymeacoffee.com/danielmullin
致谢
- Daniel Mullin inshore@danielmullin.com
- Brandon Lubbehusen inshore@danielmullin.com
许可证
MIT
https://github.com/inshore/laravel-bookwhen/blob/main/LICENSE.md