Platform API

<back to all web services

GetRelatedItems

Get related items related to the specified object.

Requires Authentication
The following routes are available for this service:
All Verbs/api/relateditems/{ObjectId}
<?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};


enum SortOrder : string
{
    case Ascending = 'Ascending';
    case Descending = 'Descending';
}

class PagedModel implements JsonSerializable
{
    public function __construct(
        /** @description Page Number to retrieve */
        // @ApiMember(DataType="int", Description="Page Number to retrieve", Name="PageNumber")
        /** @var int */
        public int $PageNumber=0,

        /** @description Number of records to retrieve */
        // @ApiMember(DataType="int", Description="Number of records to retrieve", Name="PageSize")
        /** @var int */
        public int $PageSize=0,

        /** @description Index of field to sort results by */
        // @ApiMember(DataType="int", Description="Index of field to sort results by", Name="SortIndex")
        /** @var int */
        public int $SortIndex=0,

        /** @description Sort Order - Ascending or Descending */
        // @ApiMember(DataType="int", Description="Sort Order - Ascending or Descending", Name="SortOrder")
        /** @var SortOrder|null */
        public ?SortOrder $SortOrder=null
    ) {
    }

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

class RelatedItemsModel implements JsonSerializable
{
    public function __construct(
        /** @description Object linked to the related item. */
        // @ApiMember(DataType="Guid", Description="Object linked to the related item.", IsRequired=true, Name="ObjectId")
        /** @var string */
        public string $ObjectId='',

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

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

        /** @description Date of creation of the related item. */
        // @ApiMember(DataType="DateTime", Description="Date of creation of the related item.", IsRequired=true, Name="CreatedAt")
        /** @var DateTime */
        public DateTime $CreatedAt=new DateTime(),

        /** @description Contact who created the related item */
        // @ApiMember(DataType="string", Description="Contact who created the related item", Name="CreatedByName")
        /** @var string|null */
        public ?string $CreatedByName=null,

        /** @description Contact who created the related item */
        // @ApiMember(DataType="Guid", Description="Contact who created the related item", Name="CreatedById")
        /** @var string */
        public string $CreatedById='',

        /** @description Profile photo of the contact who created the related item */
        // @ApiMember(DataType="string", Description="Profile photo of the contact who created the related item", Name="CreatedByThumbnailUrl")
        /** @var string|null */
        public ?string $CreatedByThumbnailUrl=null,

        /** @description Relationship between objects linked to the related item */
        // @ApiMember(DataType="string", Description="Relationship between objects linked to the related item", Name="Relationship")
        /** @var string|null */
        public ?string $Relationship=null,

        /** @description Is the related item significant? */
        // @ApiMember(DataType="bool", Description="Is the related item significant?", IsRequired=true, Name="IsSignificant")
        /** @var bool|null */
        public ?bool $IsSignificant=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ObjectId'])) $this->ObjectId = $o['ObjectId'];
        if (isset($o['RelatedItemName'])) $this->RelatedItemName = $o['RelatedItemName'];
        if (isset($o['RelatedItemType'])) $this->RelatedItemType = $o['RelatedItemType'];
        if (isset($o['CreatedAt'])) $this->CreatedAt = JsonConverters::from('DateTime', $o['CreatedAt']);
        if (isset($o['CreatedByName'])) $this->CreatedByName = $o['CreatedByName'];
        if (isset($o['CreatedById'])) $this->CreatedById = $o['CreatedById'];
        if (isset($o['CreatedByThumbnailUrl'])) $this->CreatedByThumbnailUrl = $o['CreatedByThumbnailUrl'];
        if (isset($o['Relationship'])) $this->Relationship = $o['Relationship'];
        if (isset($o['IsSignificant'])) $this->IsSignificant = $o['IsSignificant'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ObjectId)) $o['ObjectId'] = $this->ObjectId;
        if (isset($this->RelatedItemName)) $o['RelatedItemName'] = $this->RelatedItemName;
        if (isset($this->RelatedItemType)) $o['RelatedItemType'] = $this->RelatedItemType;
        if (isset($this->CreatedAt)) $o['CreatedAt'] = JsonConverters::to('DateTime', $this->CreatedAt);
        if (isset($this->CreatedByName)) $o['CreatedByName'] = $this->CreatedByName;
        if (isset($this->CreatedById)) $o['CreatedById'] = $this->CreatedById;
        if (isset($this->CreatedByThumbnailUrl)) $o['CreatedByThumbnailUrl'] = $this->CreatedByThumbnailUrl;
        if (isset($this->Relationship)) $o['Relationship'] = $this->Relationship;
        if (isset($this->IsSignificant)) $o['IsSignificant'] = $this->IsSignificant;
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="Items related to the object.")
class GetRelatedItemsResponse implements JsonSerializable
{
    public function __construct(
        /** @var array<RelatedItemsModel>|null */
        public ?array $RelatedItems=null,
        /** @var int */
        public int $TotalRelatedItems=0,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

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

/** @description Get related items related to the specified object. */
// @Api(Description="Get related items related to the specified object.")
class GetRelatedItems extends PagedModel implements JsonSerializable
{
    /**
     * @param int $PageNumber
     * @param int $PageSize
     * @param int $SortIndex
     * @param SortOrder|null $SortOrder
     */
    public function __construct(
        int $PageNumber=0,
        int $PageSize=0,
        int $SortIndex=0,
        ?SortOrder $SortOrder=null,
        /** @description Object to get related items for. */
        // @ApiMember(Description="Object to get related items for.", IsRequired=true, Name="ObjectId")
        /** @var string */
        public string $ObjectId='',

        /** @description Significant Only or All */
        // @ApiMember(Description="Significant Only or All", IsRequired=true, Name="RelatedItemsLevel")
        /** @var string */
        public string $RelatedItemsLevel='',

        /** @description Return all connections or paged results? */
        // @ApiMember(Description="Return all connections or paged results?", Name="IsPagedMode")
        /** @var bool|null */
        public ?bool $IsPagedMode=null
    ) {
        parent::__construct($PageNumber,$PageSize,$SortIndex,$SortOrder);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['ObjectId'])) $this->ObjectId = $o['ObjectId'];
        if (isset($o['RelatedItemsLevel'])) $this->RelatedItemsLevel = $o['RelatedItemsLevel'];
        if (isset($o['IsPagedMode'])) $this->IsPagedMode = $o['IsPagedMode'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->ObjectId)) $o['ObjectId'] = $this->ObjectId;
        if (isset($this->RelatedItemsLevel)) $o['RelatedItemsLevel'] = $this->RelatedItemsLevel;
        if (isset($this->IsPagedMode)) $o['IsPagedMode'] = $this->IsPagedMode;
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetRelatedItems DTOs

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

HTTP + XML

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

POST /api/relateditems/{ObjectId} HTTP/1.1 
Host: pfapi.pstpf.com.au 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<GetRelatedItems xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Canvara.WebAPIModel.ServiceModel">
  <PageNumber xmlns="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">0</PageNumber>
  <PageSize xmlns="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">0</PageSize>
  <SortIndex xmlns="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">0</SortIndex>
  <SortOrder xmlns="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">Ascending</SortOrder>
  <IsPagedMode>false</IsPagedMode>
  <ObjectId>00000000-0000-0000-0000-000000000000</ObjectId>
  <RelatedItemsLevel>00000000-0000-0000-0000-000000000000</RelatedItemsLevel>
</GetRelatedItems>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<GetRelatedItemsResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Canvara.WebAPIModel.ServiceModel">
  <RelatedItems xmlns:d2p1="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">
    <d2p1:RelatedItemsModel>
      <d2p1:CreatedAt>0001-01-01T00:00:00</d2p1:CreatedAt>
      <d2p1:CreatedById>00000000-0000-0000-0000-000000000000</d2p1:CreatedById>
      <d2p1:CreatedByName>String</d2p1:CreatedByName>
      <d2p1:CreatedByThumbnailUrl>String</d2p1:CreatedByThumbnailUrl>
      <d2p1:IsSignificant>false</d2p1:IsSignificant>
      <d2p1:ObjectId>00000000-0000-0000-0000-000000000000</d2p1:ObjectId>
      <d2p1:RelatedItemName>String</d2p1:RelatedItemName>
      <d2p1:RelatedItemType>String</d2p1:RelatedItemType>
      <d2p1:Relationship>String</d2p1:Relationship>
    </d2p1:RelatedItemsModel>
  </RelatedItems>
  <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>
  <TotalRelatedItems>0</TotalRelatedItems>
</GetRelatedItemsResponse>