edoc automate Guide
Breadcrumbs

Service class for the connection of edoc datahub

You can use the DatahubService class in an Actions plug-in, for example, to query data from edoc datahub and to create new destination objects or webhooks.

Class name and namespace

\edoc\appserver\services\DatahubService

Public functions

getClients(): array

This function returns a list of all companies created.

Parameters

None

Return

Type

Description

array

Returns the list of all companies.


getTargetObjects(): array

This function returns a list of all created destination objects and their properties.

Parameters

None

Return

Type

Description

array

Returns the list of all created destination objects and their properties.

createTargetObject($source, $name, $text, $properties): void

This function creates a new destination object.

Parameters

Name

Type

Description

source

string

Specifies the origin of the object, e.g. the app ID of your own app, to identify objects in your own app.

name

string

Specifies the name of the destination object.

text

string

Specifies the text of the destination object.

properties

#[ArrayShape([[
"id" => "string",
"text" => "string",
"key" => "boolean",
"source" => ["string"]
]])] array

Specifies the list with the properties of the destination object.

Return

None

getTargetObjectData($clientId, $targetObjectName, $propertyIds, $createdAfter, $updatedAfter, $pageNumber, $pageSize): array

This function returns the imported data of the destination object.

Parameters

Name

Type

Description

clientId

string

Specifies the company.

targetObjectName

string

Specifies the name of the destination object.

propertyIds

array

Specifies the list with the IDs of the properties of the destination object.

createdAfter

int

Only returns data that was generated after the specified timestamp.

Standard: 0

updatedAfter

int

Only returns data that was updated after the specified timestamp.

Standard: 0

pageNumber

int

Specifies which page of the data is to be loaded.

Standard: 0

pageSize

int

Specifies how many lines a page should display.

Standard: 100


Return

Type

Description

array

Returns the list with all imported data of the destination object.

A line only contains the properties specified in the propertyIds parameter.


createWebhook($host, $path): string

This function creates a new webhook.

Parameters

Name

Type

Description

host

string

Specifies the address of the destination server.

If you use edoc services, only enter the service name.

If you use external services, specify the protocol used, e.g.: http://

path

string

Specifies the relative path of the end point to be called up.

Return

Type

Description

string

Returns the ID of the newly created webhook.

getSchemas($source, $clientShortName): array

This function returns a schema for the specified source and for the specified company (client).

Parameters

Name

Type

Description

source

string

Specifies the origin of the schema, e.g. the app ID of your own app to identify objects of your own app.

clientShortName

string

Specifies the name of the company.

Return

Type

Description

array

Returns the list of all schemas created for the source and for the company.


deleteSchema($source, $clientShortName): array

This function deletes the schema specified with source and company (client).

Parameters

Name

Type

Description

source

string

Specifies the origin of the schema, e.g. the app ID of your own app to identify objects of your own app.

clientShortName

string

Specifies the name of the company.

Return

Type

Description

array

Returns the list of all schemas deleted for the source and for the company (client).


createSchema($source, $clientShortName, array $collections): array

This function creates a new schema.

Parameters

Name

Type

Description

source

string

Specifies the origin of the schema, e.g. the app ID of your own app to identify objects of your own app.

clientShortName

string

Specifies the name of the company.

Return

Type

Description

array

Returns the list of all new schemas created for the source and for the company.


updateSchema($source, $clientShortName, array $collections): array

This function updates the specified schema.

Parameters

Name

Type

Description

source

string

Specifies the origin of the schema, e.g. the app ID of your own app to identify objects of your own app.

clientShortName

string

Specifies the name of the company.

Return

Type

Description

array

Returns the list of all schemas updated for the source and for the company.


getEvents($source = null): array

This function returns all events.

Parameters

Name

Type

Description

source

string

Specifies the origin of the event, e.g. the app ID of your own app to identify objects in your own app.

Return

Type

Description

array

Returns a list of all events found for the specified source.


createEvents($source, $description, $events): array

This function creates new events.

Parameters

Name

Type

Description

source

string

Specifies the origin of the event, e.g. the app ID of your own app to identify objects in your own app.

description

string

Specifies a description for the events.

events

array

Specifies the list of events to be created.

Return

Type

Description

array

Returns the list of events created.


updateEvents($source, $events, $description = null): array

This function updates the specified events.

Parameters

Name

Type

Description

source

string

Specifies the origin of the event, e.g. the app ID of your own app to identify objects in your own app.

events

array

Specifies a list with the information to be adjusted for the events.

description

string

Specifies the description of the events if they are to be updated.

Return

Type

Description

array

Returns the list of updated events.


deleteEvents($source, $name = null): void

This function deletes the specified events.

Parameters

Name

Type

Description

source

string

Specifies the relative path of the end point to be called up.

name

string

Specifies the name of the event to be deleted.

sendEvent($source, $eventName, $eventId, $clientShortName, $payload)

This function starts a transactional data export for the specified event.

Parameters

Name

Type

Description

source

string

Specifies the relative path of the end point to be called up.

eventName

string

Specifies the event that is to be triggered.

eventId

string

Specifies a unique ID.

clientShortName

string

Specifies the name of the company.

payload

array

Specifies the data for the export.

Example of an action plug-in

In this code example, all clients are retrieved from edoc datahub.

PHP
<?php

namespace edoc\appserver\app\actions\plugins;

use edoc\appserver\app\AbstractAction;
use edoc\appserver\services\DatahubService;

class GetClients extends AbstractAction
{
    use \edoc\appserver\app\actions\DatasetAction;
    
    protected function init()
    {
    }

    protected function exec(): AbstractAction
    {        
      $processedClients = [];

      $dh = new DatahubService();
      $clients = $dh->getClients();
      
      foreach ($clients as $client) {
        // process client data
      }

      return $this->returnDataset($processedClients);
    
    }
}