| POST | /api/attachments |
|---|
<?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 AddAttachmentsResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
class MediaModel implements JsonSerializable
{
public function __construct(
/** @var string */
public string $MediaFileId='',
/** @var string|null */
public ?string $MediaName=null,
/** @var string|null */
public ?string $FileContent=null,
/** @var string|null */
public ?string $FileContentType=null,
/** @var string|null */
public ?string $FilePath=null,
/** @var string|null */
public ?string $OriginalFileName=null,
/** @var int */
public int $ImageWidth=0,
/** @var int */
public int $ImageHeight=0,
/** @var int */
public int $FileSizeKB=0,
/** @var string|null */
public ?string $BlobUriRaw=null,
/** @var string|null */
public ?string $BlobUriFull=null,
/** @var string|null */
public ?string $BlobUriThumbnail=null,
/** @var string|null */
public ?string $WatermarkUri=null,
/** @var DateTime */
public DateTime $CapturedDate=new DateTime(),
/** @var string|null */
public ?string $CapturedByContactId=null,
/** @var string|null */
public ?string $CapturedByContactName=null,
/** @var string|null */
public ?string $CapturedByContactThumbnailUrl=null,
/** @var string|null */
public ?string $Notes=null,
/** @var string|null */
public ?string $ResourceActionName=null,
/** @var string|null */
public ?string $LocationVerified=null,
/** @var string */
public string $TrafficLightLocationVerified='',
/** @var string|null */
public ?string $AudienceLevel=null,
/** @var string|null */
public ?string $WorksFor=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['MediaFileId'])) $this->MediaFileId = $o['MediaFileId'];
if (isset($o['MediaName'])) $this->MediaName = $o['MediaName'];
if (isset($o['FileContent'])) $this->FileContent = $o['FileContent'];
if (isset($o['FileContentType'])) $this->FileContentType = $o['FileContentType'];
if (isset($o['FilePath'])) $this->FilePath = $o['FilePath'];
if (isset($o['OriginalFileName'])) $this->OriginalFileName = $o['OriginalFileName'];
if (isset($o['ImageWidth'])) $this->ImageWidth = $o['ImageWidth'];
if (isset($o['ImageHeight'])) $this->ImageHeight = $o['ImageHeight'];
if (isset($o['FileSizeKB'])) $this->FileSizeKB = $o['FileSizeKB'];
if (isset($o['BlobUriRaw'])) $this->BlobUriRaw = $o['BlobUriRaw'];
if (isset($o['BlobUriFull'])) $this->BlobUriFull = $o['BlobUriFull'];
if (isset($o['BlobUriThumbnail'])) $this->BlobUriThumbnail = $o['BlobUriThumbnail'];
if (isset($o['WatermarkUri'])) $this->WatermarkUri = $o['WatermarkUri'];
if (isset($o['CapturedDate'])) $this->CapturedDate = JsonConverters::from('DateTime', $o['CapturedDate']);
if (isset($o['CapturedByContactId'])) $this->CapturedByContactId = $o['CapturedByContactId'];
if (isset($o['CapturedByContactName'])) $this->CapturedByContactName = $o['CapturedByContactName'];
if (isset($o['CapturedByContactThumbnailUrl'])) $this->CapturedByContactThumbnailUrl = $o['CapturedByContactThumbnailUrl'];
if (isset($o['Notes'])) $this->Notes = $o['Notes'];
if (isset($o['ResourceActionName'])) $this->ResourceActionName = $o['ResourceActionName'];
if (isset($o['LocationVerified'])) $this->LocationVerified = $o['LocationVerified'];
if (isset($o['TrafficLightLocationVerified'])) $this->TrafficLightLocationVerified = $o['TrafficLightLocationVerified'];
if (isset($o['AudienceLevel'])) $this->AudienceLevel = $o['AudienceLevel'];
if (isset($o['WorksFor'])) $this->WorksFor = $o['WorksFor'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->MediaFileId)) $o['MediaFileId'] = $this->MediaFileId;
if (isset($this->MediaName)) $o['MediaName'] = $this->MediaName;
if (isset($this->FileContent)) $o['FileContent'] = $this->FileContent;
if (isset($this->FileContentType)) $o['FileContentType'] = $this->FileContentType;
if (isset($this->FilePath)) $o['FilePath'] = $this->FilePath;
if (isset($this->OriginalFileName)) $o['OriginalFileName'] = $this->OriginalFileName;
if (isset($this->ImageWidth)) $o['ImageWidth'] = $this->ImageWidth;
if (isset($this->ImageHeight)) $o['ImageHeight'] = $this->ImageHeight;
if (isset($this->FileSizeKB)) $o['FileSizeKB'] = $this->FileSizeKB;
if (isset($this->BlobUriRaw)) $o['BlobUriRaw'] = $this->BlobUriRaw;
if (isset($this->BlobUriFull)) $o['BlobUriFull'] = $this->BlobUriFull;
if (isset($this->BlobUriThumbnail)) $o['BlobUriThumbnail'] = $this->BlobUriThumbnail;
if (isset($this->WatermarkUri)) $o['WatermarkUri'] = $this->WatermarkUri;
if (isset($this->CapturedDate)) $o['CapturedDate'] = JsonConverters::to('DateTime', $this->CapturedDate);
if (isset($this->CapturedByContactId)) $o['CapturedByContactId'] = $this->CapturedByContactId;
if (isset($this->CapturedByContactName)) $o['CapturedByContactName'] = $this->CapturedByContactName;
if (isset($this->CapturedByContactThumbnailUrl)) $o['CapturedByContactThumbnailUrl'] = $this->CapturedByContactThumbnailUrl;
if (isset($this->Notes)) $o['Notes'] = $this->Notes;
if (isset($this->ResourceActionName)) $o['ResourceActionName'] = $this->ResourceActionName;
if (isset($this->LocationVerified)) $o['LocationVerified'] = $this->LocationVerified;
if (isset($this->TrafficLightLocationVerified)) $o['TrafficLightLocationVerified'] = $this->TrafficLightLocationVerified;
if (isset($this->AudienceLevel)) $o['AudienceLevel'] = $this->AudienceLevel;
if (isset($this->WorksFor)) $o['WorksFor'] = $this->WorksFor;
return empty($o) ? new class(){} : $o;
}
}
class AddAttachments implements JsonSerializable
{
public function __construct(
/** @description including file content, file type, content type and connected object. */
// @ApiMember(DataType="string", Description=" including file content, file type, content type and connected object.", Name="Files", ParameterType="query")
/** @var array<MediaModel>|null */
public ?array $Files=null,
/** @description Appliance from which primary image file is to be uploaded. */
// @ApiMember(DataType="Guid", Description="Appliance from which primary image file is to be uploaded.", IsRequired=true, Name="ApplianceId")
/** @var string */
public string $ApplianceId='',
/** @description Object for which primary image is to be uploaded. */
// @ApiMember(DataType="Guid", Description="Object for which primary image is to be uploaded.", IsRequired=true, Name="ConnectedObjectId")
/** @var string */
public string $ConnectedObjectId='',
/** @description Licensee Id of the Object owner for which primary image is to be uploaded. */
// @ApiMember(DataType="Guid", Description="Licensee Id of the Object owner for which primary image is to be uploaded.", IsRequired=true, Name="ConnectedObjectLicenseeId")
/** @var string */
public string $ConnectedObjectLicenseeId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Files'])) $this->Files = JsonConverters::fromArray('MediaModel', $o['Files']);
if (isset($o['ApplianceId'])) $this->ApplianceId = $o['ApplianceId'];
if (isset($o['ConnectedObjectId'])) $this->ConnectedObjectId = $o['ConnectedObjectId'];
if (isset($o['ConnectedObjectLicenseeId'])) $this->ConnectedObjectLicenseeId = $o['ConnectedObjectLicenseeId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Files)) $o['Files'] = JsonConverters::toArray('MediaModel', $this->Files);
if (isset($this->ApplianceId)) $o['ApplianceId'] = $this->ApplianceId;
if (isset($this->ConnectedObjectId)) $o['ConnectedObjectId'] = $this->ConnectedObjectId;
if (isset($this->ConnectedObjectLicenseeId)) $o['ConnectedObjectLicenseeId'] = $this->ConnectedObjectLicenseeId;
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/attachments HTTP/1.1
Host: pfapi.pstpf.com.au
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Files:
[
{
MediaName: String,
FileContent: String,
FileContentType: String,
FilePath: String,
OriginalFileName: String,
ImageWidth: 0,
ImageHeight: 0,
FileSizeKB: 0,
BlobUriRaw: String,
BlobUriFull: String,
BlobUriThumbnail: String,
WatermarkUri: String,
CapturedDate: 0001-01-01,
CapturedByContactId: 00000000000000000000000000000000,
CapturedByContactName: String,
CapturedByContactThumbnailUrl: String,
Notes: String,
ResourceActionName: String,
LocationVerified: String,
AudienceLevel: String,
WorksFor: 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
}
}
}