Trendsic Platform Service

<back to all web services

AttachmentRequest

Requires Authentication
Requires any of the roles:Agent, Administrator
The following routes are available for this service:
GET,PUT,DELETE,OPTIONS/v1/Attachment/{AttachmentId}
POST,OPTIONS/v1/Attachment/{TableName}/{FieldName}/{RecordId}/{NeedsOCR}
POST,OPTIONS/v1/Attachment/{TableName}/{FieldName}/{RecordId}
<?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 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 AttachmentResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var array<Attachment>|null */
        public ?array $Attachment=null
    ) {
    }

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

class AttachmentRequest implements JsonSerializable
{
    public function __construct(
        /** @var array<Attachment>|null */
        public ?array $Attachment=null,
        /** @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 bool|null */
        public ?bool $NeedsOCR=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Attachment'])) $this->Attachment = JsonConverters::fromArray('Attachment', $o['Attachment']);
        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['NeedsOCR'])) $this->NeedsOCR = $o['NeedsOCR'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Attachment)) $o['Attachment'] = JsonConverters::toArray('Attachment', $this->Attachment);
        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->NeedsOCR)) $o['NeedsOCR'] = $this->NeedsOCR;
        return empty($o) ? new class(){} : $o;
    }
}

PHP AttachmentRequest 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 /v1/Attachment/{TableName}/{FieldName}/{RecordId}/{NeedsOCR} HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"Attachment":[{"AttachmentId":"00000000000000000000000000000000","TableName":"String","FieldName":"String","RecordId":0,"AttachmentName":"String","MimeType":"String","AttachmentData":"AA==","FileSizeInKB":0,"CreatedDate":"0001-01-01T00:00:00.0000000","CreatedBy":"String","NeedsOCR":false,"OCRDate":"0001-01-01T00:00:00.0000000","IsSecurities":false,"AWSKey":"String","PresignedUrl":"String"}],"AttachmentId":"00000000000000000000000000000000","TableName":"String","FieldName":"String","RecordId":0,"NeedsOCR":false}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"Attachment":[{"AttachmentId":"00000000000000000000000000000000","TableName":"String","FieldName":"String","RecordId":0,"AttachmentName":"String","MimeType":"String","AttachmentData":"AA==","FileSizeInKB":0,"CreatedDate":"0001-01-01T00:00:00.0000000","CreatedBy":"String","NeedsOCR":false,"OCRDate":"0001-01-01T00:00:00.0000000","IsSecurities":false,"AWSKey":"String","PresignedUrl":"String"}]}