| 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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
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: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"EntityType":"String","ErrorField":"String","ContinueOnError":false,"Rows":[{"Fields":[{"Name":"String","Value":"String"}]}],"FixedValues":[{"Name":"String","Value":"String"}]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"TotalRows":0,"TotalAdded":0,"TotalUpdated":0,"SuccesfullRows":0,"ErrorRows":0,"Errors":["String"]}