samuel-olavo/laravel-rt-bestpratical
最新稳定版本:v1.1.0
Composer 安装命令:
composer require samuel-olavo/laravel-rt-bestpratical
包简介
Laravel package to interact with the RT (Request Tracker) API
README 文档
README
This Laravel package allows you to interact with the Request Tracker (RT) ^5.0.0 using the REST API, including both certificate-based and token-based authentication.
Documentation
For detailed API documentation, refer to the official Request Tracker REST API docs: Request Tracker API Docs.
Installation
-
Add the package to your Laravel project:
composer require samuel-olavo/laravel-rt-bestpratical
-
Publish the configuration file:
php artisan vendor:publish --provider="SamuelOlavo\LaravelRTBestpratical\RTServiceProvider" -
Add the following settings to your
.envfile:RT_BASE_URL="https://my.rt.server/rt5/REST/2.0" RT_CERTIFICATE=true RT_USER=user RT_PASSWORD=password RT_CERTIFICATE_PATH=/path/to/your-certificate.pem RT_PRIVATE_KEY_PATH=/path/to/your-private-key.pem RT_CERTIFICATE_CHAIN_PATH=/path/to/your-cert-chain.crt RT_API_TOKEN="your-api-token"
Usage
Example 1: Create a Ticket
To create a ticket:
use SamuelOlavo\LaravelRTBestpratical\RTService; $rtService = app(RTService::class); $ticketData = [ 'queue' => 'General', 'subject' => 'Test ticket subject', 'owner' => 'admin', 'requestor' => 'user@example.com', 'text' => 'This is the description of the ticket.', ]; $ticket = $rtService->createTicket($ticketData); if (isset($ticket['id'])) { return response()->json(['message' => 'Ticket created successfully', 'ticket_id' => $ticket['id']], 201); } return response()->json(['error' => $ticket], 500);
Example 2: Create a Ticket Details
$ticketDetails = $rtService->getTicket(1); // Get details for ticket ID 1
Example 3: Add a Response to a Ticket
$responseData = [ 'Content' => 'This is the response to the ticket. How can I assist you?', 'ContentType' => 'text/plain', ]; $response = $rtService->addResponseToTicket(1, $responseData); if (isset($response['message']) && $response['message'] === 'Correspondence added') { return response()->json(['message' => 'Response added successfully to the ticket!'], 200); } return response()->json(['error' => 'Error adding response to the ticket'], 500);
Example 4: Update a Ticket
$assignData = [ 'owner' => 'new-owner', ]; $response = $rtService->assignTicket(1, $assignData); if (isset($response['id'])) { return response()->json(['message' => 'Ticket assigned successfully', 'ticket_id' => $response['id']], 200); } return response()->json(['error' => 'Error assigning the ticket'], 500);
Available Methods
createTicket()getTicket()searchTickets()addComment()updateTicket()assignTicket()getTicketHistory()resolveTicket()deleteTicket()listQueues()listUsers()
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-18