datana-gmbh/zammad-api

API for Zammad

1.7.0 2024-02-01 11:23 UTC

This package is auto-updated.

Last update: 2024-11-30 13:10:58 UTC


README

Usage

Installation

composer require datana-gmbh/zammad-api

Setup

use Datana\Zammad\Api\ZammadClient;

$baseUri = 'https://...';
$token = '...';

$client = new ZammadClient($baseUri, $token);

// you can now request any endpoint which needs authentication
$client->request('GET', '/api/something', $options);

Tickets

In your code you should type-hint to Datana\Zammad\Api\TicketsApiInterface

Create a ticket

use Datana\Zammad\Api\Domain\Value\Ticket;
use Datana\Zammad\Api\TicketsApi;
use Datana\Zammad\Api\ZammadClient;

$client = new ZammadClient(/* ... */);

$ticketsApi = new TicketsApi($client);

$ticket = new Ticket(/* ... */);
$responseAsBool = $ticketsApi->create($ticket);

Update a ticket

use Datana\Zammad\Api\TicketsApi;
use Datana\Zammad\Api\ZammadClient;

$client = new ZammadClient(/* ... */);

$ticketsApi = new TicketsApi($client);

$responseAsBool = $ticketsApi->update(1, ['email' => 'foo@bar.de']);

Search for tickets

use Datana\Zammad\Api\TicketsApi;
use Datana\Zammad\Api\ZammadClient;
$client = new ZammadClient(/* ... */);

$responseAsArray = $ticketsApi->search('foo');