DigiOffice API Services Services

<back to all web services

ImportData

Import entity data into DigiOffice (v1)

Requires Authentication
The following routes are available for this service:
PUT/api/importdata
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


class ImportResult implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $TotalRows=0,
        /** @var int */
        public int $TotalAdded=0,
        /** @var int */
        public int $TotalUpdated=0,
        /** @var int */
        public int $SuccesfullRows=0,
        /** @var int */
        public int $ErrorRows=0,
        /** @var array<string>|null */
        public ?array $Errors=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['TotalRows'])) $this->TotalRows = $o['TotalRows'];
        if (isset($o['TotalAdded'])) $this->TotalAdded = $o['TotalAdded'];
        if (isset($o['TotalUpdated'])) $this->TotalUpdated = $o['TotalUpdated'];
        if (isset($o['SuccesfullRows'])) $this->SuccesfullRows = $o['SuccesfullRows'];
        if (isset($o['ErrorRows'])) $this->ErrorRows = $o['ErrorRows'];
        if (isset($o['Errors'])) $this->Errors = JsonConverters::fromArray('string', $o['Errors']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->TotalRows)) $o['TotalRows'] = $this->TotalRows;
        if (isset($this->TotalAdded)) $o['TotalAdded'] = $this->TotalAdded;
        if (isset($this->TotalUpdated)) $o['TotalUpdated'] = $this->TotalUpdated;
        if (isset($this->SuccesfullRows)) $o['SuccesfullRows'] = $this->SuccesfullRows;
        if (isset($this->ErrorRows)) $o['ErrorRows'] = $this->ErrorRows;
        if (isset($this->Errors)) $o['Errors'] = JsonConverters::toArray('string', $this->Errors);
        return empty($o) ? new class(){} : $o;
    }
}

class ImportField implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $Value=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Value'])) $this->Value = $o['Value'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Value)) $o['Value'] = $this->Value;
        return empty($o) ? new class(){} : $o;
    }
}

class Row implements JsonSerializable
{
    public function __construct(
        /** @var array<ImportField>|null */
        public ?array $Fields=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Fields'])) $this->Fields = JsonConverters::fromArray('ImportField', $o['Fields']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Fields)) $o['Fields'] = JsonConverters::toArray('ImportField', $this->Fields);
        return empty($o) ? new class(){} : $o;
    }
}

class FixedValue implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $Value=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Value'])) $this->Value = $o['Value'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Value)) $o['Value'] = $this->Value;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Import entity data into DigiOffice (v1) */
// @Api(Description="Import entity data into DigiOffice (v1)")
class ImportData implements JsonSerializable
{
    public function __construct(
        /** @description Entityname in which the data will be imported */
        // @ApiMember(Description="Entityname in which the data will be imported", IsRequired=true)
        /** @var string */
        public string $EntityType='',

        /** @description Reports errors with a reference to this field (for example ID) */
        // @ApiMember(Description="Reports errors with a reference to this field (for example ID)")
        /** @var string|null */
        public ?string $ErrorField=null,

        /** @description Should import continue on errors? (Default true) */
        // @ApiMember(Description="Should import continue on errors? (Default true)")
        /** @var bool|null */
        public ?bool $ContinueOnError=null,

        /** @description Rows to be imported */
        // @ApiMember(Description="Rows to be imported", IsRequired=true)
        /** @var array<Row>|null */
        public ?array $Rows=null,

        /** @description Additional values to be imported on every row */
        // @ApiMember(Description="Additional values to be imported on every row")
        /** @var array<FixedValue>|null */
        public ?array $FixedValues=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['EntityType'])) $this->EntityType = $o['EntityType'];
        if (isset($o['ErrorField'])) $this->ErrorField = $o['ErrorField'];
        if (isset($o['ContinueOnError'])) $this->ContinueOnError = $o['ContinueOnError'];
        if (isset($o['Rows'])) $this->Rows = JsonConverters::fromArray('Row', $o['Rows']);
        if (isset($o['FixedValues'])) $this->FixedValues = JsonConverters::fromArray('FixedValue', $o['FixedValues']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->EntityType)) $o['EntityType'] = $this->EntityType;
        if (isset($this->ErrorField)) $o['ErrorField'] = $this->ErrorField;
        if (isset($this->ContinueOnError)) $o['ContinueOnError'] = $this->ContinueOnError;
        if (isset($this->Rows)) $o['Rows'] = JsonConverters::toArray('Row', $this->Rows);
        if (isset($this->FixedValues)) $o['FixedValues'] = JsonConverters::toArray('FixedValue', $this->FixedValues);
        return empty($o) ? new class(){} : $o;
    }
}

PHP ImportData DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

PUT /api/importdata HTTP/1.1 
Host: test-do-services.klokgroep.nl 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<ImportData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.General">
  <ContinueOnError>false</ContinueOnError>
  <EntityType>String</EntityType>
  <ErrorField>String</ErrorField>
  <FixedValues>
    <ImportData.FixedValue>
      <Name>String</Name>
      <Value>String</Value>
    </ImportData.FixedValue>
  </FixedValues>
  <Rows>
    <ImportData.Row>
      <Fields>
        <ImportData.ImportField>
          <Name>String</Name>
          <Value>String</Value>
        </ImportData.ImportField>
      </Fields>
    </ImportData.Row>
  </Rows>
</ImportData>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ImportResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.General">
  <ErrorRows>0</ErrorRows>
  <Errors xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Errors>
  <SuccesfullRows>0</SuccesfullRows>
  <TotalAdded>0</TotalAdded>
  <TotalRows>0</TotalRows>
  <TotalUpdated>0</TotalUpdated>
</ImportResult>