DigiOffice Gateway Web Services

<back to all web services

UploadFile

Requires Authentication
The following routes are available for this service:
POST/api/DMS/UploadFile
<?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 UploadFile implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $RegistrationProfileID='',
        /** @var string|null */
        public ?string $NavigationPath=null,
        /** @var string|null */
        public ?string $FileName=null,
        /** @var DateTime|null */
        public ?DateTime $FileDate=null,
        /** @var string|null */
        public ?string $Description=null,
        /** @var bool|null */
        public ?bool $DocumentUpload=null,
        /** @var string|null */
        public ?string $Source=null,
        /** @var string|null */
        public ?string $MetaData=null,
        /** @var string|null */
        public ?string $DocumentID=null,
        /** @var string|null */
        public ?string $HoofdDocumentID=null,
        /** @var array<string>|null */
        public ?array $SubDocumentIDs=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['RegistrationProfileID'])) $this->RegistrationProfileID = $o['RegistrationProfileID'];
        if (isset($o['NavigationPath'])) $this->NavigationPath = $o['NavigationPath'];
        if (isset($o['FileName'])) $this->FileName = $o['FileName'];
        if (isset($o['FileDate'])) $this->FileDate = JsonConverters::from('DateTime', $o['FileDate']);
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['DocumentUpload'])) $this->DocumentUpload = $o['DocumentUpload'];
        if (isset($o['Source'])) $this->Source = $o['Source'];
        if (isset($o['MetaData'])) $this->MetaData = $o['MetaData'];
        if (isset($o['DocumentID'])) $this->DocumentID = $o['DocumentID'];
        if (isset($o['HoofdDocumentID'])) $this->HoofdDocumentID = $o['HoofdDocumentID'];
        if (isset($o['SubDocumentIDs'])) $this->SubDocumentIDs = JsonConverters::fromArray('Guid', $o['SubDocumentIDs']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->RegistrationProfileID)) $o['RegistrationProfileID'] = $this->RegistrationProfileID;
        if (isset($this->NavigationPath)) $o['NavigationPath'] = $this->NavigationPath;
        if (isset($this->FileName)) $o['FileName'] = $this->FileName;
        if (isset($this->FileDate)) $o['FileDate'] = JsonConverters::to('DateTime', $this->FileDate);
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->DocumentUpload)) $o['DocumentUpload'] = $this->DocumentUpload;
        if (isset($this->Source)) $o['Source'] = $this->Source;
        if (isset($this->MetaData)) $o['MetaData'] = $this->MetaData;
        if (isset($this->DocumentID)) $o['DocumentID'] = $this->DocumentID;
        if (isset($this->HoofdDocumentID)) $o['HoofdDocumentID'] = $this->HoofdDocumentID;
        if (isset($this->SubDocumentIDs)) $o['SubDocumentIDs'] = JsonConverters::toArray('Guid', $this->SubDocumentIDs);
        return empty($o) ? new class(){} : $o;
    }
}

enum MessageType : int
{
    case Information = 1;
    case Warning = 2;
    case Error = 3;
    case Success = 4;
}

class InformationMessageBase implements IInformationMessage, JsonSerializable
{
    public function __construct(
        /** @var MessageType|null */
        public ?MessageType $Type=null,
        /** @var string|null */
        public ?string $Summary=null,
        /** @var string|null */
        public ?string $FullMessage=null,
        /** @var string|null */
        public ?string $FieldName=null,
        /** @var bool|null */
        public ?bool $KeepOpen=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Type'])) $this->Type = JsonConverters::from('MessageType', $o['Type']);
        if (isset($o['Summary'])) $this->Summary = $o['Summary'];
        if (isset($o['FullMessage'])) $this->FullMessage = $o['FullMessage'];
        if (isset($o['FieldName'])) $this->FieldName = $o['FieldName'];
        if (isset($o['KeepOpen'])) $this->KeepOpen = $o['KeepOpen'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Type)) $o['Type'] = JsonConverters::to('MessageType', $this->Type);
        if (isset($this->Summary)) $o['Summary'] = $this->Summary;
        if (isset($this->FullMessage)) $o['FullMessage'] = $this->FullMessage;
        if (isset($this->FieldName)) $o['FieldName'] = $this->FieldName;
        if (isset($this->KeepOpen)) $o['KeepOpen'] = $this->KeepOpen;
        return empty($o) ? new class(){} : $o;
    }
}

/**
 * @template array of InformationMessageBase
 */
class InformationMessages extends \ArrayObject implements IInformationMessages, JsonSerializable
{
    public function __construct(InformationMessageBase ...$items) {
        parent::__construct($items, \ArrayObject::STD_PROP_LIST);
    }
    
    /** @throws \Exception */
    public function append($value): void {
        if ($value instanceof InformationMessageBase)
            parent::append($value);
        else
            throw new \Exception("Can only append a InformationMessageBase to " . __CLASS__);
    }
    
    /** @throws Exception */
    public function fromMap($o): void {
        foreach ($o as $item) {
            $el = new InformationMessageBase();
            $el->fromMap($item);
            $this->append($el);
        }
    }
    
    /** @throws Exception */
    public function jsonSerialize(): array {
        return parent::getArrayCopy();
    }
}

// @DataContract
class UploadFileResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var string|null */
        public ?string $DocumentId=null,

        // @DataMember
        /** @var int|null */
        public ?int $DocumentUploadId=null,

        // @DataMember
        /** @var string|null */
        public ?string $DocumentNr=null,

        // @DataMember
        /** @var InformationMessages|null */
        public ?InformationMessages $Messages=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['DocumentId'])) $this->DocumentId = $o['DocumentId'];
        if (isset($o['DocumentUploadId'])) $this->DocumentUploadId = $o['DocumentUploadId'];
        if (isset($o['DocumentNr'])) $this->DocumentNr = $o['DocumentNr'];
        if (isset($o['Messages'])) $this->Messages = JsonConverters::from('InformationMessages', $o['Messages']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->DocumentId)) $o['DocumentId'] = $this->DocumentId;
        if (isset($this->DocumentUploadId)) $o['DocumentUploadId'] = $this->DocumentUploadId;
        if (isset($this->DocumentNr)) $o['DocumentNr'] = $this->DocumentNr;
        if (isset($this->Messages)) $o['Messages'] = JsonConverters::to('InformationMessages', $this->Messages);
        return empty($o) ? new class(){} : $o;
    }
}

PHP UploadFile DTOs

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

HTTP + OTHER

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

POST /api/DMS/UploadFile HTTP/1.1 
Host: test-dogw.klokgroep.nl 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"RegistrationProfileID":"00000000-0000-0000-0000-000000000000","NavigationPath":"String","FileName":"String","FileDate":"0001-01-01T00:00:00.0000000","Description":"String","DocumentUpload":false,"Source":"String","MetaData":"String","DocumentID":"00000000-0000-0000-0000-000000000000","HoofdDocumentID":"00000000-0000-0000-0000-000000000000","SubDocumentIDs":["00000000-0000-0000-0000-000000000000"]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"DocumentId":"00000000-0000-0000-0000-000000000000","DocumentUploadId":0,"DocumentNr":"String","Messages":[{}]}