| 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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
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: text/csv
Content-Type: text/csv
Content-Length: length
{"ObjectId":"00000000-0000-0000-0000-000000000000","RelatedItemsLevel":"00000000-0000-0000-0000-000000000000","IsPagedMode":false,"PageNumber":0,"PageSize":0,"SortIndex":0,"SortOrder":"Ascending"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"RelatedItems":[{"ObjectId":"00000000-0000-0000-0000-000000000000","RelatedItemName":"String","RelatedItemType":"String","CreatedAt":"0001-01-01T00:00:00.0000000","CreatedByName":"String","CreatedById":"00000000-0000-0000-0000-000000000000","CreatedByThumbnailUrl":"String","Relationship":"String","IsSignificant":false}],"TotalRelatedItems":0,"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}