Trendsic Platform Service

<back to all web services

AttachmentVersionRestoreRequest

Requires Authentication
Requires any of the roles:Agent, Administrator
The following routes are available for this service:
POST,OPTIONS/v1/AttachmentVersion/{AttachmentId}/{VersionNo}/restore
<?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 AttachmentVersion implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $AttachmentVersionId=0,
        /** @var string */
        public string $AttachmentId='',
        /** @var int */
        public int $VersionNo=0,
        /** @var string|null */
        public ?string $AttachmentName=null,
        /** @var string|null */
        public ?string $MimeType=null,
        /** @var float|null */
        public ?float $FileSizeInKB=null,
        /** @var string|null */
        public ?string $AWSKey=null,
        /** @var string|null */
        public ?string $RevisionLabel=null,
        /** @var string|null */
        public ?string $Notes=null,
        /** @var int|null */
        public ?int $RestoredFromVersionNo=null,
        /** @var string|null */
        public ?string $UploadedBy=null,
        /** @var DateTime|null */
        public ?DateTime $UploadedAt=null,
        /** @var bool|null */
        public ?bool $IsCurrent=null,
        /** @var string|null */
        public ?string $DownloadUrl=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['AttachmentVersionId'])) $this->AttachmentVersionId = $o['AttachmentVersionId'];
        if (isset($o['AttachmentId'])) $this->AttachmentId = $o['AttachmentId'];
        if (isset($o['VersionNo'])) $this->VersionNo = $o['VersionNo'];
        if (isset($o['AttachmentName'])) $this->AttachmentName = $o['AttachmentName'];
        if (isset($o['MimeType'])) $this->MimeType = $o['MimeType'];
        if (isset($o['FileSizeInKB'])) $this->FileSizeInKB = $o['FileSizeInKB'];
        if (isset($o['AWSKey'])) $this->AWSKey = $o['AWSKey'];
        if (isset($o['RevisionLabel'])) $this->RevisionLabel = $o['RevisionLabel'];
        if (isset($o['Notes'])) $this->Notes = $o['Notes'];
        if (isset($o['RestoredFromVersionNo'])) $this->RestoredFromVersionNo = $o['RestoredFromVersionNo'];
        if (isset($o['UploadedBy'])) $this->UploadedBy = $o['UploadedBy'];
        if (isset($o['UploadedAt'])) $this->UploadedAt = JsonConverters::from('DateTime', $o['UploadedAt']);
        if (isset($o['IsCurrent'])) $this->IsCurrent = $o['IsCurrent'];
        if (isset($o['DownloadUrl'])) $this->DownloadUrl = $o['DownloadUrl'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->AttachmentVersionId)) $o['AttachmentVersionId'] = $this->AttachmentVersionId;
        if (isset($this->AttachmentId)) $o['AttachmentId'] = $this->AttachmentId;
        if (isset($this->VersionNo)) $o['VersionNo'] = $this->VersionNo;
        if (isset($this->AttachmentName)) $o['AttachmentName'] = $this->AttachmentName;
        if (isset($this->MimeType)) $o['MimeType'] = $this->MimeType;
        if (isset($this->FileSizeInKB)) $o['FileSizeInKB'] = $this->FileSizeInKB;
        if (isset($this->AWSKey)) $o['AWSKey'] = $this->AWSKey;
        if (isset($this->RevisionLabel)) $o['RevisionLabel'] = $this->RevisionLabel;
        if (isset($this->Notes)) $o['Notes'] = $this->Notes;
        if (isset($this->RestoredFromVersionNo)) $o['RestoredFromVersionNo'] = $this->RestoredFromVersionNo;
        if (isset($this->UploadedBy)) $o['UploadedBy'] = $this->UploadedBy;
        if (isset($this->UploadedAt)) $o['UploadedAt'] = JsonConverters::to('DateTime', $this->UploadedAt);
        if (isset($this->IsCurrent)) $o['IsCurrent'] = $this->IsCurrent;
        if (isset($this->DownloadUrl)) $o['DownloadUrl'] = $this->DownloadUrl;
        return empty($o) ? new class(){} : $o;
    }
}

class Attachment implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $AttachmentId='',
        /** @var string|null */
        public ?string $TableName=null,
        /** @var string|null */
        public ?string $FieldName=null,
        /** @var int */
        public int $RecordId=0,
        /** @var string|null */
        public ?string $AttachmentName=null,
        /** @var string|null */
        public ?string $MimeType=null,
        /** @var ByteArray|null */
        public ?ByteArray $AttachmentData=null,
        /** @var float */
        public float $FileSizeInKB=0.0,
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime(),
        /** @var string|null */
        public ?string $CreatedBy=null,
        /** @var bool|null */
        public ?bool $NeedsOCR=null,
        /** @var DateTime */
        public DateTime $OCRDate=new DateTime(),
        /** @var bool|null */
        public ?bool $IsSecurities=null,
        /** @var string|null */
        public ?string $AWSKey=null,
        /** @var string|null */
        public ?string $PresignedUrl=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['AttachmentId'])) $this->AttachmentId = $o['AttachmentId'];
        if (isset($o['TableName'])) $this->TableName = $o['TableName'];
        if (isset($o['FieldName'])) $this->FieldName = $o['FieldName'];
        if (isset($o['RecordId'])) $this->RecordId = $o['RecordId'];
        if (isset($o['AttachmentName'])) $this->AttachmentName = $o['AttachmentName'];
        if (isset($o['MimeType'])) $this->MimeType = $o['MimeType'];
        if (isset($o['AttachmentData'])) $this->AttachmentData = JsonConverters::from('ByteArray', $o['AttachmentData']);
        if (isset($o['FileSizeInKB'])) $this->FileSizeInKB = $o['FileSizeInKB'];
        if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
        if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
        if (isset($o['NeedsOCR'])) $this->NeedsOCR = $o['NeedsOCR'];
        if (isset($o['OCRDate'])) $this->OCRDate = JsonConverters::from('DateTime', $o['OCRDate']);
        if (isset($o['IsSecurities'])) $this->IsSecurities = $o['IsSecurities'];
        if (isset($o['AWSKey'])) $this->AWSKey = $o['AWSKey'];
        if (isset($o['PresignedUrl'])) $this->PresignedUrl = $o['PresignedUrl'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->AttachmentId)) $o['AttachmentId'] = $this->AttachmentId;
        if (isset($this->TableName)) $o['TableName'] = $this->TableName;
        if (isset($this->FieldName)) $o['FieldName'] = $this->FieldName;
        if (isset($this->RecordId)) $o['RecordId'] = $this->RecordId;
        if (isset($this->AttachmentName)) $o['AttachmentName'] = $this->AttachmentName;
        if (isset($this->MimeType)) $o['MimeType'] = $this->MimeType;
        if (isset($this->AttachmentData)) $o['AttachmentData'] = JsonConverters::to('ByteArray', $this->AttachmentData);
        if (isset($this->FileSizeInKB)) $o['FileSizeInKB'] = $this->FileSizeInKB;
        if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
        if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
        if (isset($this->NeedsOCR)) $o['NeedsOCR'] = $this->NeedsOCR;
        if (isset($this->OCRDate)) $o['OCRDate'] = JsonConverters::to('DateTime', $this->OCRDate);
        if (isset($this->IsSecurities)) $o['IsSecurities'] = $this->IsSecurities;
        if (isset($this->AWSKey)) $o['AWSKey'] = $this->AWSKey;
        if (isset($this->PresignedUrl)) $o['PresignedUrl'] = $this->PresignedUrl;
        return empty($o) ? new class(){} : $o;
    }
}

class AttachmentVersionResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var string */
        public string $AttachmentId='',
        /** @var array<AttachmentVersion>|null */
        public ?array $Versions=null,
        /** @var int */
        public int $CurrentVersionNo=0,
        /** @var Attachment|null */
        public ?Attachment $Head=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
        if (isset($o['AttachmentId'])) $this->AttachmentId = $o['AttachmentId'];
        if (isset($o['Versions'])) $this->Versions = JsonConverters::fromArray('AttachmentVersion', $o['Versions']);
        if (isset($o['CurrentVersionNo'])) $this->CurrentVersionNo = $o['CurrentVersionNo'];
        if (isset($o['Head'])) $this->Head = JsonConverters::from('Attachment', $o['Head']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
        if (isset($this->AttachmentId)) $o['AttachmentId'] = $this->AttachmentId;
        if (isset($this->Versions)) $o['Versions'] = JsonConverters::toArray('AttachmentVersion', $this->Versions);
        if (isset($this->CurrentVersionNo)) $o['CurrentVersionNo'] = $this->CurrentVersionNo;
        if (isset($this->Head)) $o['Head'] = JsonConverters::to('Attachment', $this->Head);
        return empty($o) ? new class(){} : $o;
    }
}

class AttachmentVersionRestoreRequest implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $AttachmentId='',
        /** @var int */
        public int $VersionNo=0,
        /** @var string|null */
        public ?string $Notes=null
    ) {
    }

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

PHP AttachmentVersionRestoreRequest DTOs

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

HTTP + JSV

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

POST /v1/AttachmentVersion/{AttachmentId}/{VersionNo}/restore HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	AttachmentId: 00000000000000000000000000000000,
	VersionNo: 0,
	Notes: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	},
	AttachmentId: 00000000000000000000000000000000,
	Versions: 
	[
		{
			AttachmentVersionId: 0,
			AttachmentId: 00000000000000000000000000000000,
			VersionNo: 0,
			AttachmentName: String,
			MimeType: String,
			FileSizeInKB: 0,
			AWSKey: String,
			RevisionLabel: String,
			Notes: String,
			RestoredFromVersionNo: 0,
			UploadedBy: String,
			UploadedAt: 0001-01-01,
			IsCurrent: False,
			DownloadUrl: String
		}
	],
	CurrentVersionNo: 0,
	Head: 
	{
		AttachmentId: 00000000000000000000000000000000,
		TableName: String,
		FieldName: String,
		RecordId: 0,
		AttachmentName: String,
		MimeType: String,
		AttachmentData: AA==,
		FileSizeInKB: 0,
		CreatedDate: 0001-01-01,
		CreatedBy: String,
		NeedsOCR: False,
		OCRDate: 0001-01-01,
		IsSecurities: False,
		AWSKey: String,
		PresignedUrl: String
	}
}