datana-gmbh / zendesk-api
API for Zendesk
Installs: 7 506
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=8.3
- ergebnis/php-cs-fixer-config: ^6.20
- oskarstark/trimmed-non-empty-string: ^1.0
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/http-client: ^5.4 || ^6.0 || ^7.0
- symfony/http-foundation: ^5.4 || ^6.0 || ^7.0
- symfony/mime: ^5.4 || ^6.0 || ^7.0
- thecodingmachine/safe: ^1.0 || ^2.0
- webmozart/assert: ^1.7
- zendesk/zendesk_api_client_php: ^3.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.2
- ergebnis/test-util: ^1.5
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^9.0
- thecodingmachine/phpstan-safe-rule: ^1.0 || ^2.0
README
Usage
Installation
composer require datana-gmbh/zendesk-api
Setup
use Zendesk\API\HttpClient; $subdomain = 'company' $username = 'username' $token = '...' $client = new HttpClient($subdomain); $client->setAuth('basic', [ 'token' => $token, 'username' => $username ]);
Tickets
In your code you should type-hint to Datana\Zendesk\Api\TicketsApiInterface
Create a ticket
use Datana\Zendesk\Api\Domain\Value\Ticket; use Datana\Zendesk\Api\TicketsApi; use Zendesk\API\HttpClient; $client = new HttpClient(/* ... */); $ticketsApi = new TicketsApi($client); $ticket = new Ticket(/* ... */); $responseAsBool = $ticketsApi->create($ticket);
Create a ticket with attachments
use Datana\Zendesk\Api\Domain\Value\Ticket; use Datana\Zendesk\Api\TicketsApi; use Datana\Zendesk\Api\AttachmentsApi; use Zendesk\API\HttpClient; $client = new HttpClient(/* ... */); $attachmentsApi = new AttachmentsApi($client); $upload = $attachmentsApi->create(/** ... */) $ticketsApi = new TicketsApi($client); $ticket = new Ticket(/* ... */ ); $responseAsBool = $ticketsApi->create($ticket);
Custom field definition
<?php declare(strict_types=1); namespace App\Bridge\Zendesk\CustomFields; use Datana\Zendesk\Api\Domain\Value\CustomFieldInterface; final class SampleCustomField implements CustomFieldInterface { public function id(): int { return 1231332332; } public function value(): mixed { return 'sample value'; } }