| POST | /api/DMS/AddUploadFile |
|---|
<?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};
// @DataContract
class MetaDataField implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var string|null */
public ?string $ID=null,
// @DataMember
/** @var string|null */
public ?string $DocumentVeldID=null,
// @DataMember
/** @var string|null */
public ?string $Name=null,
// @DataMember
/** @var string|null */
public ?string $Label=null,
// @DataMember
/** @var string|null */
public ?string $Datatype=null,
// @DataMember
/** @var string|null */
public ?string $PrintLabel=null,
// @DataMember
/** @var string|null */
public ?string $Entity=null,
// @DataMember
/** @var string|null */
public ?string $PrintValue=null,
// @DataMember
/** @var string|null */
public ?string $RegistrationValue=null,
// @DataMember
/** @var string|null */
public ?string $SPSiteColumnName=null,
// @DataMember
/** @var string|null */
public ?string $ShadowName=null,
// @DataMember
/** @var string|null */
public ?string $ShadowDatatype=null,
// @DataMember
/** @var string|null */
public ?string $ShadowSPSiteColumnName=null,
// @DataMember
/** @var string|null */
public ?string $ShadowSPSiteColumnRegistrationValue=null,
// @DataMember
/** @var string|null */
public ?string $ShadowRegistrationValue=null,
// @DataMember
/** @var bool|null */
public ?bool $IsKeyField=null,
// @DataMember
/** @var bool|null */
public ?bool $KopierenBijNieuweVersie=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ID'])) $this->ID = $o['ID'];
if (isset($o['DocumentVeldID'])) $this->DocumentVeldID = $o['DocumentVeldID'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Label'])) $this->Label = $o['Label'];
if (isset($o['Datatype'])) $this->Datatype = $o['Datatype'];
if (isset($o['PrintLabel'])) $this->PrintLabel = $o['PrintLabel'];
if (isset($o['Entity'])) $this->Entity = $o['Entity'];
if (isset($o['PrintValue'])) $this->PrintValue = $o['PrintValue'];
if (isset($o['RegistrationValue'])) $this->RegistrationValue = $o['RegistrationValue'];
if (isset($o['SPSiteColumnName'])) $this->SPSiteColumnName = $o['SPSiteColumnName'];
if (isset($o['ShadowName'])) $this->ShadowName = $o['ShadowName'];
if (isset($o['ShadowDatatype'])) $this->ShadowDatatype = $o['ShadowDatatype'];
if (isset($o['ShadowSPSiteColumnName'])) $this->ShadowSPSiteColumnName = $o['ShadowSPSiteColumnName'];
if (isset($o['ShadowSPSiteColumnRegistrationValue'])) $this->ShadowSPSiteColumnRegistrationValue = $o['ShadowSPSiteColumnRegistrationValue'];
if (isset($o['ShadowRegistrationValue'])) $this->ShadowRegistrationValue = $o['ShadowRegistrationValue'];
if (isset($o['IsKeyField'])) $this->IsKeyField = $o['IsKeyField'];
if (isset($o['KopierenBijNieuweVersie'])) $this->KopierenBijNieuweVersie = $o['KopierenBijNieuweVersie'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ID)) $o['ID'] = $this->ID;
if (isset($this->DocumentVeldID)) $o['DocumentVeldID'] = $this->DocumentVeldID;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Label)) $o['Label'] = $this->Label;
if (isset($this->Datatype)) $o['Datatype'] = $this->Datatype;
if (isset($this->PrintLabel)) $o['PrintLabel'] = $this->PrintLabel;
if (isset($this->Entity)) $o['Entity'] = $this->Entity;
if (isset($this->PrintValue)) $o['PrintValue'] = $this->PrintValue;
if (isset($this->RegistrationValue)) $o['RegistrationValue'] = $this->RegistrationValue;
if (isset($this->SPSiteColumnName)) $o['SPSiteColumnName'] = $this->SPSiteColumnName;
if (isset($this->ShadowName)) $o['ShadowName'] = $this->ShadowName;
if (isset($this->ShadowDatatype)) $o['ShadowDatatype'] = $this->ShadowDatatype;
if (isset($this->ShadowSPSiteColumnName)) $o['ShadowSPSiteColumnName'] = $this->ShadowSPSiteColumnName;
if (isset($this->ShadowSPSiteColumnRegistrationValue)) $o['ShadowSPSiteColumnRegistrationValue'] = $this->ShadowSPSiteColumnRegistrationValue;
if (isset($this->ShadowRegistrationValue)) $o['ShadowRegistrationValue'] = $this->ShadowRegistrationValue;
if (isset($this->IsKeyField)) $o['IsKeyField'] = $this->IsKeyField;
if (isset($this->KopierenBijNieuweVersie)) $o['KopierenBijNieuweVersie'] = $this->KopierenBijNieuweVersie;
return empty($o) ? new class(){} : $o;
}
}
/** @description Add a uploadfile with metadata. */
// @Api(Description="Add a uploadfile with metadata.")
class AddUploadFile implements JsonSerializable
{
public function __construct(
/** @description Registration profile ID */
// @ApiMember(Description="Registration profile ID", IsRequired=true)
/** @var string */
public string $RegistrationProfileID='',
/** @description Registration navigation path */
// @ApiMember(Description="Registration navigation path")
/** @var string|null */
public ?string $NavigationPath=null,
/** @description File name */
// @ApiMember(Description="File name", IsRequired=true)
/** @var string */
public string $FileName='',
/** @description File date */
// @ApiMember(Description="File date", IsRequired=true)
/** @var DateTime */
public DateTime $FileDate=new DateTime(),
/** @description File content */
// @ApiMember(Description="File content", IsRequired=true)
/** @var ByteArray|null */
public ?ByteArray $FileContent=null,
/** @description File description */
// @ApiMember(Description="File description", IsRequired=true)
/** @var string */
public string $Description='',
/** @description Keep document in uploads (false; register immediately) */
// @ApiMember(Description="Keep document in uploads (false; register immediately)")
/** @var bool|null */
public ?bool $DocumentUpload=null,
/** @description Source of the file */
// @ApiMember(Description="Source of the file")
/** @var string|null */
public ?string $Source=null,
/** @description MetaDataFields */
// @ApiMember(Description="MetaDataFields")
/** @var array<MetaDataField>|null */
public ?array $MetaDataFields=null,
/** @description Document ID */
// @ApiMember(Description="Document ID")
/** @var string|null */
public ?string $DocumentID=null,
/** @description Main Document ID */
// @ApiMember(Description="Main Document ID")
/** @var string|null */
public ?string $MainDocumentID=null,
/** @description Sub Document IDs */
// @ApiMember(Description="Sub Document IDs")
/** @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['FileContent'])) $this->FileContent = JsonConverters::from('ByteArray', $o['FileContent']);
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['MetaDataFields'])) $this->MetaDataFields = JsonConverters::fromArray('MetaDataField', $o['MetaDataFields']);
if (isset($o['DocumentID'])) $this->DocumentID = $o['DocumentID'];
if (isset($o['MainDocumentID'])) $this->MainDocumentID = $o['MainDocumentID'];
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->FileContent)) $o['FileContent'] = JsonConverters::to('ByteArray', $this->FileContent);
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->MetaDataFields)) $o['MetaDataFields'] = JsonConverters::toArray('MetaDataField', $this->MetaDataFields);
if (isset($this->DocumentID)) $o['DocumentID'] = $this->DocumentID;
if (isset($this->MainDocumentID)) $o['MainDocumentID'] = $this->MainDocumentID;
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 AddUploadFileResponse 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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/DMS/AddUploadFile HTTP/1.1
Host: dogw.klokgroep.nl
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
NavigationPath: String,
FileName: String,
FileDate: 0001-01-01,
FileContent: AA==,
Description: String,
DocumentUpload: False,
Source: String,
MetaDataFields:
[
{
ID: 00000000-0000-0000-0000-000000000000,
DocumentVeldID: 00000000-0000-0000-0000-000000000000,
Name: String,
Label: String,
Datatype: String,
PrintLabel: String,
Entity: String,
PrintValue: String,
RegistrationValue: String,
SPSiteColumnName: String,
ShadowName: String,
ShadowDatatype: String,
ShadowSPSiteColumnName: String,
ShadowSPSiteColumnRegistrationValue: String,
ShadowRegistrationValue: String,
IsKeyField: False,
KopierenBijNieuweVersie: False
}
],
DocumentID: 00000000-0000-0000-0000-000000000000,
MainDocumentID: 00000000-0000-0000-0000-000000000000,
SubDocumentIDs:
[
00000000-0000-0000-0000-000000000000
]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
DocumentId: 00000000-0000-0000-0000-000000000000,
DocumentUploadId: 0,
DocumentNr: String,
Messages:
[
{
}
]
}