| GET | /api/object/{ObjectId}/reads |
|---|
<?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 ObjectAccessModel implements JsonSerializable
{
public function __construct(
/** @description Object Access Read Id. */
// @ApiMember(Description="Object Access Read Id.", Name="ObjectReadId")
/** @var string */
public string $ObjectReadId='',
/** @description Object Id viewing the specified Object. */
// @ApiMember(Description="Object Id viewing the specified Object.", IsRequired=true, Name="ViewingObjectId")
/** @var string */
public string $ViewingObjectId='',
/** @description Name of the object viewing the specified Object. */
// @ApiMember(Description="Name of the object viewing the specified Object.", Name="ViewingObjectName")
/** @var string|null */
public ?string $ViewingObjectName=null,
/** @description Name of the object viewing the specified Object. */
// @ApiMember(Description="Name of the object viewing the specified Object.", Name="ViewingObjectPrimaryImageUrl")
/** @var string|null */
public ?string $ViewingObjectPrimaryImageUrl=null,
/** @description Id of the object being viewed. */
// @ApiMember(Description="Id of the object being viewed.", IsRequired=true, Name="ViewedObjectId")
/** @var string */
public string $ViewedObjectId='',
/** @description Name of the object being viewed. */
// @ApiMember(Description="Name of the object being viewed.", Name="ViewedObjectName")
/** @var string|null */
public ?string $ViewedObjectName=null,
/** @description Date and Time of object read */
// @ApiMember(Description="Date and Time of object read", Name="TimeRead")
/** @var DateTime|null */
public ?DateTime $TimeRead=null,
/** @description Date and Time object started watching the specified object. */
// @ApiMember(Description="Date and Time object started watching the specified object.", Name="TimeStartWatching")
/** @var DateTime|null */
public ?DateTime $TimeStartWatching=null,
/** @description Date and Time of object being flagged. */
// @ApiMember(Description="Date and Time of object being flagged.", Name="Flagged")
/** @var DateTime */
public DateTime $Flagged=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ObjectReadId'])) $this->ObjectReadId = $o['ObjectReadId'];
if (isset($o['ViewingObjectId'])) $this->ViewingObjectId = $o['ViewingObjectId'];
if (isset($o['ViewingObjectName'])) $this->ViewingObjectName = $o['ViewingObjectName'];
if (isset($o['ViewingObjectPrimaryImageUrl'])) $this->ViewingObjectPrimaryImageUrl = $o['ViewingObjectPrimaryImageUrl'];
if (isset($o['ViewedObjectId'])) $this->ViewedObjectId = $o['ViewedObjectId'];
if (isset($o['ViewedObjectName'])) $this->ViewedObjectName = $o['ViewedObjectName'];
if (isset($o['TimeRead'])) $this->TimeRead = JsonConverters::from('DateTime', $o['TimeRead']);
if (isset($o['TimeStartWatching'])) $this->TimeStartWatching = JsonConverters::from('DateTime', $o['TimeStartWatching']);
if (isset($o['Flagged'])) $this->Flagged = JsonConverters::from('DateTime', $o['Flagged']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ObjectReadId)) $o['ObjectReadId'] = $this->ObjectReadId;
if (isset($this->ViewingObjectId)) $o['ViewingObjectId'] = $this->ViewingObjectId;
if (isset($this->ViewingObjectName)) $o['ViewingObjectName'] = $this->ViewingObjectName;
if (isset($this->ViewingObjectPrimaryImageUrl)) $o['ViewingObjectPrimaryImageUrl'] = $this->ViewingObjectPrimaryImageUrl;
if (isset($this->ViewedObjectId)) $o['ViewedObjectId'] = $this->ViewedObjectId;
if (isset($this->ViewedObjectName)) $o['ViewedObjectName'] = $this->ViewedObjectName;
if (isset($this->TimeRead)) $o['TimeRead'] = JsonConverters::to('DateTime', $this->TimeRead);
if (isset($this->TimeStartWatching)) $o['TimeStartWatching'] = JsonConverters::to('DateTime', $this->TimeStartWatching);
if (isset($this->Flagged)) $o['Flagged'] = JsonConverters::to('DateTime', $this->Flagged);
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="Returns the reads (object access) to the specified object.")
class GetObjectReadsResponse implements JsonSerializable
{
public function __construct(
/** @var array<ObjectAccessModel>|null */
public ?array $ObjectReads=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ObjectReads'])) $this->ObjectReads = JsonConverters::fromArray('ObjectAccessModel', $o['ObjectReads']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ObjectReads)) $o['ObjectReads'] = JsonConverters::toArray('ObjectAccessModel', $this->ObjectReads);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
/** @description Get reads (object access) for the specified object. */
// @Api(Description="Get reads (object access) for the specified object.")
class GetObjectReads implements JsonSerializable
{
public function __construct(
/** @description Object Id to get object access reads for */
// @ApiMember(DataType="Guid", Description="Object Id to get object access reads for", IsRequired=true, Name="ObjectId")
/** @var string */
public string $ObjectId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ObjectId'])) $this->ObjectId = $o['ObjectId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ObjectId)) $o['ObjectId'] = $this->ObjectId;
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.
GET /api/object/{ObjectId}/reads HTTP/1.1
Host: pfapi.pstpf.com.au
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
ObjectReads:
[
{
ViewingObjectName: String,
ViewingObjectPrimaryImageUrl: String,
ViewedObjectName: String,
TimeRead: 0001-01-01,
TimeStartWatching: 0001-01-01,
Flagged: 0001-01-01
}
],
ResponseStatus:
{
ErrorCode: String,
Message: String,
StackTrace: String,
Errors:
[
{
ErrorCode: String,
FieldName: String,
Message: String,
Meta:
{
String: String
}
}
],
Meta:
{
String: String
}
}
}