| POST,OPTIONS | /v1/Attachment/ProjectFiles/{TableName}/{FieldName}/{RecordId} | ||
|---|---|---|---|
| POST,OPTIONS | /v1/Attachment/ProjectFiles/{TableName}/{FieldName}/{RecordId}/{NeedsOCR} |
<?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 ProjectAttachmentRequest 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 ProjectAttachmentRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /v1/Attachment/ProjectFiles/{TableName}/{FieldName}/{RecordId} HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<ProjectAttachmentRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<Attachment>
<Attachment>
<AWSKey>String</AWSKey>
<AttachmentData>AA==</AttachmentData>
<AttachmentId>00000000-0000-0000-0000-000000000000</AttachmentId>
<AttachmentName>String</AttachmentName>
<CreatedBy>String</CreatedBy>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
<FieldName>String</FieldName>
<FileSizeInKB>0</FileSizeInKB>
<IsSecurities>false</IsSecurities>
<MimeType>String</MimeType>
<NeedsOCR>false</NeedsOCR>
<OCRDate>0001-01-01T00:00:00</OCRDate>
<PresignedUrl>String</PresignedUrl>
<RecordId>0</RecordId>
<TableName>String</TableName>
</Attachment>
</Attachment>
<AttachmentId>00000000-0000-0000-0000-000000000000</AttachmentId>
<FieldName>String</FieldName>
<NeedsOCR>false</NeedsOCR>
<RecordId>0</RecordId>
<TableName>String</TableName>
</ProjectAttachmentRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<AttachmentResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<Attachment>
<Attachment>
<AWSKey>String</AWSKey>
<AttachmentData>AA==</AttachmentData>
<AttachmentId>00000000-0000-0000-0000-000000000000</AttachmentId>
<AttachmentName>String</AttachmentName>
<CreatedBy>String</CreatedBy>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
<FieldName>String</FieldName>
<FileSizeInKB>0</FileSizeInKB>
<IsSecurities>false</IsSecurities>
<MimeType>String</MimeType>
<NeedsOCR>false</NeedsOCR>
<OCRDate>0001-01-01T00:00:00</OCRDate>
<PresignedUrl>String</PresignedUrl>
<RecordId>0</RecordId>
<TableName>String</TableName>
</Attachment>
</Attachment>
<ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:Message>String</d2p1:Message>
<d2p1:StackTrace>String</d2p1:StackTrace>
<d2p1:Errors>
<d2p1:ResponseError>
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:FieldName>String</d2p1:FieldName>
<d2p1:Message>String</d2p1:Message>
<d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:KeyValueOfstringstring>
<d5p1:Key>String</d5p1:Key>
<d5p1:Value>String</d5p1:Value>
</d5p1:KeyValueOfstringstring>
</d2p1:Meta>
</d2p1:ResponseError>
</d2p1:Errors>
<d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d3p1:KeyValueOfstringstring>
<d3p1:Key>String</d3p1:Key>
<d3p1:Value>String</d3p1:Value>
</d3p1:KeyValueOfstringstring>
</d2p1:Meta>
</ResponseStatus>
</AttachmentResponse>