PHP code example of datana-gmbh / datapool-api

1. Go to this page and download the library: Download datana-gmbh/datapool-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

datana-gmbh / datapool-api example snippets


use Datana\Datapool\Api\DatapoolClient;

$client = new DatapoolClient(
    baseUri: 'https://api.datapool...',
    username: 'my-username',
    password: '******',
    timeout: 10 // optional
);

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

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;

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

$aktenApi = new AktenApi($client);
$response = $aktenApi->search('MySearchTerm');

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);
$response = $aktenApi->getByAktenzeichen('1abcde-1234-5678-Mustermann');

/*
 * to get the DatapoolId transform the response to array
 * and use the 'id' key.
 */
$akten = $response->toArray();
$datapoolId = DatapoolId::fromInt($akte['id']);

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);
$response = $aktenApi->getByFahrzeugIdentifikationsnummer('ABC1234ABCD123456');

/*
 * to get the DatapoolId transform the response to array
 * and use the 'id' key.
 */
$akten = $response->toArray();
$datapoolId = DatapoolId::fromInt($akte['id']);

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

// is an instance of AktenResponse
$result = $aktenApi->getOneByAktenzeichen('1abcde-1234-5678-Mustermann');
/*
 * $response->toArray():
 *   [
 *     'id' => 123,
 *     ...
 *   ]
 *
 * or use the dedicated getter methods like
 *  - getId(): DatapoolId
 * etc.
 */

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

$id = DatapoolId::fromInt(123);

$aktenApi->getById($id);

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

$id = DatapoolId::fromInt(123);

// is an instance of KtAktenInfoResponse
$result = $aktenApi->getKtAktenInfo($id);
/*
 * $response->toArray():
 *   [
 *     'id' => 123,
 *     'url' => 'https://projects.knowledgetools.de/rema/?tab=akten&akte=4528',
 *     'instance' => 'rema',
 *     'group' => 'GARA',
 *   ]
 *
 * or use the dedicated getter methods like
 *  - getId()
 *  - getUrl()
 *  - getInstance()
 *  - getGroup()
 * etc.
 */

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

$id = DatapoolId::fromInt(123);

/* @var $response Datana\Datapool\Api\Domain\Response\EterminInfoResponse */
$response = $aktenApi->getETerminInfo($id);
/*
 * $response->toArray():
 *   [
 *     'service_id' => 123,
 *     'service_url' => 'https://www.etermin.net/Gansel-Rechtsanwaelte/serviceid/123',
 *   ]
 *
 * or use the dedicated getter methods like
 *  - getServiceId()
 *  - getServiceUrl()
 * etc.
 */

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

$id = DatapoolId::fromInt(123);

/* @var $response Datana\Datapool\Api\Domain\Response\SimplyBookInfoResponse */
$response = $aktenApi->getETerminInfo($id);
/*
 * $response->toArray():
 *   [
 *     'service_id' => 12,
 *     'service_url' => 'https://ganselrechtsanwaelteag.simplybook.it/v2/#book/service/12/count/1/provider/any/',
 *   ]
 *
 * or use the dedicated getter methods like
 *  - getServiceId()
 *  - getServiceUrl()
 * etc.
 */

use Datana\Datapool\Api\AktenApi;
use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\Domain\Value\DatapoolId;

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

$aktenApi = new AktenApi($client);

$id = DatapoolId::fromInt(123);

$aktenApi->setValueNutzerMandantencockpit($id, true); // or false

use Datana\Datapool\Api\AktenzeichenApi;
use Datana\Datapool\Api\DatapoolClient;

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

$aktenzeichenApi = new AktenzeichenApi($client);
$aktenzeichenApi->new(); // returns sth like "6GU5DCB"

use Datana\Datapool\Api\AktenEventLogApi;
use Datana\Datapool\Api\DatapoolClient;

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

$aktenEventLog = new AktenEventLogApi($client);
$aktenEventLog->log(
    key: 'email.sent',
    aktenzeichen: '1234/12',
    info: 'E-Mail versendet',
    timestamp: new \DateTimeImmutable(), // Zeitpunkt des Events
    creator: 'Mein Service',             // Ersteller des Events
);

use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\SystemEventLogApi;

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

$systemEventLog = new SystemEventLogApi($client);
$systemEventLog->log(
    key: 'received.webhook',
    info: 'Webhook received on /api/cockpit/DAT-changed',  // Info-Text
    timestamp: new \DateTimeImmutable(),                   // Zeitpunkt des Events
    creator: 'Mein Service',                               // Ersteller des Events
    context: ['foo' => 'bar'],                             // Kontext (optional)
    ttl: '+2 months',                                      // Gültigkeitsdauer im strtotime Format (optional)
);

use Datana\Datapool\Api\ChatProtocolApi;
use Datana\Datapool\Api\DatapoolClient;

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

$chatProtocol = new ChatProtocolApi($client);
$chatProtocol->log(
    '1234/12',                // Aktenzeichen
    '123456',                 // Conversation ID
    array(/*...*/),           // Das JSON der Intercom conversation
    new \DateTimeImmutable(), // Startzeitpunkt der Conversation
);

use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\KnowledgeToolsApi;

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

$api = new KnowledgeToolsApi($client);
$api->getFieldvalueByInstanceAndOid(
    instance: 'my-instance',
    oid: 123456,
    fieldhash: 'abcdefghi',
);

use Datana\Datapool\Api\DatapoolClient;
use Datana\Datapool\Api\KnowledgeToolsApi;

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

$api = new KnowledgeToolsApi($client);
$api->getFieldvalueByAktenzeichen(
    oid: '1abcde-1234-5678-Mustermann',
    fieldhash: 'abcdefghi',
);