k-bit / laravel-keeping
此包的最新版本(v1.0.6.2)没有提供许可证信息。
Laravel 包,用于使用 Keeping 时间登记工具的 API
v1.0.6.2
2024-04-18 14:54 UTC
Requires
- guzzlehttp/guzzle: ^7.8
- illuminate/support: ~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0
- jenssegers/model: ^1.4
README
这是一个简单的库,可用于与时间管理工具 Keeping 通信。
安装
composer require k-bit/laravel-keeping
将以下项添加到您的 .env
文件中
KEEPING_TOKEN="XXXXX" KEEPING_ORGANISATION_ID="1234"
创建新时间条目的示例
以下示例显示了如何在 Keeping 中创建一个新的时间条目。
导入所需的依赖项
use KBit\LaravelKeeping\KeepingClient; use KBit\LaravelKeeping\Model\TimeEntry;
设置与 Keeping 的连接
作为一个简单的例子,我们现在检索所有可用的项目,获取其中的第一个,并为该项目创建一个时间条目。
查看: https://developer.keeping.nl/#tag/reports/paths/~1{organisation_id}~1report/get
$keepingClient = new KeepingClient(); // If you don't provide an ID to the getUser function as the first parameter, // your own user (== the one who is attached to your authorisation token) will // be returned as a default. $user = $keepingClient->getUser(); $project = $keepingClient->getProjects()->first(); // Create a time entry $entry = new TimeEntry([ 'user_id' => $user->id, 'project_id' => $project->id, 'date' => (new \DateTime)->format('Y-m-d'), 'purpose' => 'work', 'note' => 'Creating a new entry with laravel-keeping', 'hours' => 1, ]); $keepingClient->postTimeEntry($entry);
获取基于客户的报告的示例
以下示例检索特定客户的报告。请参阅 Keeping API 文档以获取可能的查询选项的完整列表。
导入所需的依赖项
use KBit\LaravelKeeping\KeepingClient; use KBit\LaravelKeeping\Model\Report;
检索报告数据
$clientId = 12345; $reportQuery = [ 'from' => '2021-01-01', 'to' => '2021-12-31', 'row_type' => Report::REPORT_ROW_TYPE_MONTH, 'client_ids' => [$clientId], 'page' => 1, 'per_page' => 100, ]; // Retrieve an overview of the hours made in each month $summary = $keepingClient->getReport($reportQuery); // Retrieves a Collection with TimeEntry models for all the entries that match the specified query variables. $timeEntriesCollection = $keepingClient->getReportTimeEntries($reportQuery);
待办事项
此包支持 Keeping 目前提供的所有 API 端点。未来可以进行一些改进。
- 添加对 Keeping 分页响应的支持
- 为各种端点的查询参数数组添加验证