datana-gmbh / datapool-api
datapool API
3.18.0
2023-12-02 21:52 UTC
Requires
- php: >=8.1
- oskarstark/trimmed-non-empty-string: ^1.0
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/http-client: ^5.4 || ^6.0 || ^7.0
- thecodingmachine/safe: ^1.0 || ^2.0
- webmozart/assert: ^1.7
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-03 10:18:54 UTC
README
用法
安装
composer require datana-gmbh/datapool-api
设置
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);
文件
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\AktenApiInterface
通过字符串(string
)搜索
use Datana\Datapool\Api\AktenApi; use Datana\Datapool\Api\DatapoolClient; $client = new DatapoolClient(/* ... */); $aktenApi = new AktenApi($client); $response = $aktenApi->search('MySearchTerm');
通过 Aktenzeichen(string
)获取
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']);
通过 Fahrzeug-Identifikationsnummer(string
)获取
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']);
通过 Aktenzeichen(string
)获取一个或抛出异常
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. */
通过 ID(Datana\Datapool\Api\Domain\Value\DatapoolId
)获取
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);
获取 KT Akten Info(Datana\Datapool\Api\Domain\Value\DatapoolId
)
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. */
获取 E-Termin Info(Datana\Datapool\Api\Domain\Value\DatapoolId
)
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. */
获取 SimplyBook Info(Datana\Datapool\Api\Domain\Value\DatapoolId
)
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. */
设置值 "Nutzer Mandantencockpit"(bool
)
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
Aktenzeichen
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\AktenzeichenApiInterface
获取一个新的
use Datana\Datapool\Api\AktenzeichenApi; use Datana\Datapool\Api\DatapoolClient; $client = new DatapoolClient(/* ... */); $aktenzeichenApi = new AktenzeichenApi($client); $aktenzeichenApi->new(); // returns sth like "6GU5DCB"
AktenEventLog
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\AktenEventLogApiInterface
创建一个新的日志
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 );
SystemEventLog
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\SystemEventLogApiInterface
创建一个新的日志
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) );
API内部将 "+2 months" 转换为 datetime 对象。如果这个日期时间到达,Datapool 将删除日志条目。传递 null
以保持日志条目永久。
ChatProtocol
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\ChatProtocolApiInterface
保存一个新的聊天协议
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 );
KnowledgeTools
在你的代码中,你应该使用类型提示 Datana\Datapool\Api\KnowledgeToolsApiInterface
通过实例和 OID 获取 Fieldvalue
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', );
通过 Aktenzeichen 获取 Fieldvalue
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', );