Platform API

<back to all web services

ManagePrimaryImage

Requires Authentication
The following routes are available for this service:
All Verbs/api/primaryimage
All Verbs/api/primaryimage/userprofile
<?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 SaveMediaResponse implements JsonSerializable
{
    public function __construct(
        /** @description Media File Guid */
        // @ApiMember(DataType="Guid", Description="Media File Guid", Name="ErosMediaFileId", ParameterType="query")
        /** @var string */
        public string $ErosMediaFileId='',

        /** @description Media File Name */
        // @ApiMember(DataType="string", Description="Media File Name", Name="MediaName", ParameterType="query")
        /** @var string|null */
        public ?string $MediaName=null,

        /** @description The original name of the media being saved. */
        // @ApiMember(DataType="string", Description="The original name of the media being saved.", Name="OriginalFileName", ParameterType="query")
        /** @var string|null */
        public ?string $OriginalFileName=null,

        /** @description Url of the media file. */
        // @ApiMember(DataType="string", Description="Url of the media file.", Name="MediaFileUrl", ParameterType="query")
        /** @var string|null */
        public ?string $MediaFileUrl=null,

        /** @description Url of the media file thumbnail. */
        // @ApiMember(DataType="string", Description="Url of the media file thumbnail.", Name="MediaFileThumbnailUrl", ParameterType="query")
        /** @var string|null */
        public ?string $MediaFileThumbnailUrl=null,

        /** @description Service Stack Response Status. */
        // @ApiMember(DataType="ResponseStatus", Description="Service Stack Response Status.", Name="ResponseStatus", ParameterType="query")
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ErosMediaFileId'])) $this->ErosMediaFileId = $o['ErosMediaFileId'];
        if (isset($o['MediaName'])) $this->MediaName = $o['MediaName'];
        if (isset($o['OriginalFileName'])) $this->OriginalFileName = $o['OriginalFileName'];
        if (isset($o['MediaFileUrl'])) $this->MediaFileUrl = $o['MediaFileUrl'];
        if (isset($o['MediaFileThumbnailUrl'])) $this->MediaFileThumbnailUrl = $o['MediaFileThumbnailUrl'];
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ErosMediaFileId)) $o['ErosMediaFileId'] = $this->ErosMediaFileId;
        if (isset($this->MediaName)) $o['MediaName'] = $this->MediaName;
        if (isset($this->OriginalFileName)) $o['OriginalFileName'] = $this->OriginalFileName;
        if (isset($this->MediaFileUrl)) $o['MediaFileUrl'] = $this->MediaFileUrl;
        if (isset($this->MediaFileThumbnailUrl)) $o['MediaFileThumbnailUrl'] = $this->MediaFileThumbnailUrl;
        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 ManagePrimaryImage implements JsonSerializable
{
    public function __construct(
        /** @description The licensee's contact Id linked to the media file. */
        // @ApiMember(DataType="Guid", Description="The licensee's contact Id linked to the media file.", IsRequired=true, Name="ContactIdOwner", ParameterType="query")
        /** @var string */
        public string $ContactIdOwner='',

        /** @description Primary image file to be uploaded including file type and content type. */
        // @ApiMember(DataType="MediaModel", Description="Primary image file to be uploaded including file type and content type.", IsRequired=true, Name="File")
        /** @var MediaModel|null */
        public ?MediaModel $File=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 Blob storage container to which primary image file is to be uploaded. */
        // @ApiMember(DataType="Guid", Description="Blob storage container to which primary image file is to be uploaded.", IsRequired=true, Name="ContainerName")
        /** @var string */
        public string $ContainerName='',

        /** @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=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ContactIdOwner'])) $this->ContactIdOwner = $o['ContactIdOwner'];
        if (isset($o['File'])) $this->File = JsonConverters::from('MediaModel', $o['File']);
        if (isset($o['ApplianceId'])) $this->ApplianceId = $o['ApplianceId'];
        if (isset($o['ContainerName'])) $this->ContainerName = $o['ContainerName'];
        if (isset($o['ConnectedObjectId'])) $this->ConnectedObjectId = $o['ConnectedObjectId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ContactIdOwner)) $o['ContactIdOwner'] = $this->ContactIdOwner;
        if (isset($this->File)) $o['File'] = JsonConverters::to('MediaModel', $this->File);
        if (isset($this->ApplianceId)) $o['ApplianceId'] = $this->ApplianceId;
        if (isset($this->ContainerName)) $o['ContainerName'] = $this->ContainerName;
        if (isset($this->ConnectedObjectId)) $o['ConnectedObjectId'] = $this->ConnectedObjectId;
        return empty($o) ? new class(){} : $o;
    }
}

PHP ManagePrimaryImage 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 /api/primaryimage HTTP/1.1 
Host: pfapi.pstpf.com.au 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	File: 
	{
		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
	},
	ContainerName: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	MediaName: String,
	OriginalFileName: String,
	MediaFileUrl: String,
	MediaFileThumbnailUrl: String,
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}