Platform API

<back to all web services

SaveDimension

Add or update a dimensions details.

Requires Authentication
The following routes are available for this service:
POST/api/dimensions
PUT/api/dimensions/{DimensionId}
<?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};


// @ApiResponse(Description="Success of the create/update of the dimension")
class SaveDimensionResponse implements JsonSerializable
{
    public function __construct(
        /** @description Id of the Dimension created. */
        // @ApiMember(DataType="Guid", Description="Id of the Dimension created.", Name="DimensionId", ParameterType="query")
        /** @var string */
        public string $DimensionId='',

        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

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

class DimensionValueModel implements JsonSerializable
{
    public function __construct(
        /** @description Id of the dimension value. */
        // @ApiMember(DataType="Guid", Description="Id of the dimension value.", Name="DimensionValueId", ParameterType="body")
        /** @var string */
        public string $DimensionValueId='',

        /** @description Dimension Id this value is for. */
        // @ApiMember(Description="Dimension Id this value is for.", ParameterType="body")
        /** @var string */
        public string $DimensionId='',

        /** @description Name of the dimension value. */
        // @ApiMember(Description="Name of the dimension value.", ParameterType="body")
        /** @var string|null */
        public ?string $Name=null,

        /** @description Description of the dimension value. */
        // @ApiMember(Description="Description of the dimension value.", ParameterType="body")
        /** @var string|null */
        public ?string $Description=null,

        /** @description Short Name for the dimension value. */
        // @ApiMember(Description="Short Name for the dimension value.", ParameterType="body")
        /** @var string|null */
        public ?string $ShortName=null,

        /** @description Id of the colour associated. */
        // @ApiMember(Description="Id of the colour associated.", ParameterType="body")
        /** @var string */
        public string $TrafficLightId='',

        /** @description Colour associated with the dimension value. */
        // @ApiMember(Description="Colour associated with the dimension value.", ParameterType="body")
        /** @var string|null */
        public ?string $TrafficLightColour=null,

        /** @description Id that links this dimension value to an object. */
        // @ApiMember(Description="Id that links this dimension value to an object.", ParameterType="body")
        /** @var string */
        public string $ObjectConnectionId='',

        /** @description Owner Id of the dimension value. */
        // @ApiMember(Description="Owner Id of the dimension value.", ParameterType="body")
        /** @var string */
        public string $OwnerContactId='',

        /** @description Record status of the dimension value. */
        // @ApiMember(Description="Record status of the dimension value.", ParameterType="body")
        /** @var string|null */
        public ?string $RecordStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['DimensionValueId'])) $this->DimensionValueId = $o['DimensionValueId'];
        if (isset($o['DimensionId'])) $this->DimensionId = $o['DimensionId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ShortName'])) $this->ShortName = $o['ShortName'];
        if (isset($o['TrafficLightId'])) $this->TrafficLightId = $o['TrafficLightId'];
        if (isset($o['TrafficLightColour'])) $this->TrafficLightColour = $o['TrafficLightColour'];
        if (isset($o['ObjectConnectionId'])) $this->ObjectConnectionId = $o['ObjectConnectionId'];
        if (isset($o['OwnerContactId'])) $this->OwnerContactId = $o['OwnerContactId'];
        if (isset($o['RecordStatus'])) $this->RecordStatus = $o['RecordStatus'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->DimensionValueId)) $o['DimensionValueId'] = $this->DimensionValueId;
        if (isset($this->DimensionId)) $o['DimensionId'] = $this->DimensionId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ShortName)) $o['ShortName'] = $this->ShortName;
        if (isset($this->TrafficLightId)) $o['TrafficLightId'] = $this->TrafficLightId;
        if (isset($this->TrafficLightColour)) $o['TrafficLightColour'] = $this->TrafficLightColour;
        if (isset($this->ObjectConnectionId)) $o['ObjectConnectionId'] = $this->ObjectConnectionId;
        if (isset($this->OwnerContactId)) $o['OwnerContactId'] = $this->OwnerContactId;
        if (isset($this->RecordStatus)) $o['RecordStatus'] = $this->RecordStatus;
        return empty($o) ? new class(){} : $o;
    }
}

class DimensionModel implements JsonSerializable
{
    public function __construct(
        /** @description Id of the Dimension itself. */
        // @ApiMember(DataType="Guid", Description="Id of the Dimension itself.", Name="DimensionId")
        /** @var string */
        public string $DimensionId='',

        /** @description Dimension name. */
        // @ApiMember(DataType="string", Description="Dimension name.", Name="Name")
        /** @var string|null */
        public ?string $Name=null,

        /** @description Dimension description. */
        // @ApiMember(DataType="string", Description="Dimension description.", Name="Description")
        /** @var string|null */
        public ?string $Description=null,

        /** @description Dimension shortened name. */
        // @ApiMember(DataType="string", Description="Dimension shortened name.", Name="ShortName")
        /** @var string|null */
        public ?string $ShortName=null,

        /** @description True if the values for the dimension should have colours associated with them. */
        // @ApiMember(DataType="bool", Description="True if the values for the dimension should have colours associated with them.", Name="HasTrafficLightForValues")
        /** @var bool|null */
        public ?bool $HasTrafficLightForValues=null,

        /** @description  */
        // @ApiMember(DataType="bool", Description="", Name="HasImage")
        /** @var bool|null */
        public ?bool $HasImage=null,

        /** @description Owner Id of the dimension. */
        // @ApiMember(DataType="Guid", Description="Owner Id of the dimension.", Name="OwnerContactId")
        /** @var string */
        public string $OwnerContactId='',

        /** @description Record status of the dimension. */
        // @ApiMember(DataType="string", Description="Record status of the dimension.", Name="RecordStatus")
        /** @var string|null */
        public ?string $RecordStatus=null,

        /** @description Dimension values for this dimension. */
        // @ApiMember(DataType="List<DimensionValueModel>", Description="Dimension values for this dimension.", Name="DimensionValues")
        /** @var array<DimensionValueModel>|null */
        public ?array $DimensionValues=null,

        /** @description Id that links this dimension to an object. */
        // @ApiMember(Description="Id that links this dimension to an object.")
        /** @var string */
        public string $ObjectConnectionId=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['DimensionId'])) $this->DimensionId = $o['DimensionId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ShortName'])) $this->ShortName = $o['ShortName'];
        if (isset($o['HasTrafficLightForValues'])) $this->HasTrafficLightForValues = $o['HasTrafficLightForValues'];
        if (isset($o['HasImage'])) $this->HasImage = $o['HasImage'];
        if (isset($o['OwnerContactId'])) $this->OwnerContactId = $o['OwnerContactId'];
        if (isset($o['RecordStatus'])) $this->RecordStatus = $o['RecordStatus'];
        if (isset($o['DimensionValues'])) $this->DimensionValues = JsonConverters::fromArray('DimensionValueModel', $o['DimensionValues']);
        if (isset($o['ObjectConnectionId'])) $this->ObjectConnectionId = $o['ObjectConnectionId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->DimensionId)) $o['DimensionId'] = $this->DimensionId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ShortName)) $o['ShortName'] = $this->ShortName;
        if (isset($this->HasTrafficLightForValues)) $o['HasTrafficLightForValues'] = $this->HasTrafficLightForValues;
        if (isset($this->HasImage)) $o['HasImage'] = $this->HasImage;
        if (isset($this->OwnerContactId)) $o['OwnerContactId'] = $this->OwnerContactId;
        if (isset($this->RecordStatus)) $o['RecordStatus'] = $this->RecordStatus;
        if (isset($this->DimensionValues)) $o['DimensionValues'] = JsonConverters::toArray('DimensionValueModel', $this->DimensionValues);
        if (isset($this->ObjectConnectionId)) $o['ObjectConnectionId'] = $this->ObjectConnectionId;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Add or update a dimensions details. */
// @Api(Description="Add or update a dimensions details.")
class SaveDimension implements JsonSerializable
{
    public function __construct(
        /** @description Details of the dimension to be added or updated. */
        // @ApiMember(DataType="DimensionModel", Description="Details of the dimension to be added or updated.", IsRequired=true, Name="Dimension")
        /** @var DimensionModel|null */
        public ?DimensionModel $Dimension=null,

        /** @description Id of the dimension. */
        // @ApiMember(DataType="Guid", Description="Id of the dimension.", IsRequired=true, Name="DimensionId")
        /** @var string */
        public string $DimensionId=''
    ) {
    }

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

PHP SaveDimension DTOs

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

HTTP + CSV

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

POST /api/dimensions HTTP/1.1 
Host: pfapi.pstpf.com.au 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"Dimension":{"DimensionId":"00000000-0000-0000-0000-000000000000","Name":"String","Description":"String","ShortName":"String","HasTrafficLightForValues":false,"HasImage":false,"OwnerContactId":"00000000-0000-0000-0000-000000000000","RecordStatus":"String","DimensionValues":[{"DimensionValueId":"00000000-0000-0000-0000-000000000000","DimensionId":"00000000-0000-0000-0000-000000000000","Name":"String","Description":"String","ShortName":"String","TrafficLightId":"00000000-0000-0000-0000-000000000000","TrafficLightColour":"String","ObjectConnectionId":"00000000-0000-0000-0000-000000000000","OwnerContactId":"00000000-0000-0000-0000-000000000000","RecordStatus":"String"}],"ObjectConnectionId":"00000000-0000-0000-0000-000000000000"},"DimensionId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"DimensionId":"00000000-0000-0000-0000-000000000000","ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}