| GET | /v4/links/list |
|---|
<?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};
// @DataContract
class V4BaseRequest implements JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class V4PaginatedBaseRequest extends V4BaseRequest implements JsonSerializable
{
public function __construct(
// @DataMember(Name="offset")
/** @var int */
public int $offset=0,
// @DataMember(Name="limit")
/** @var int */
public int $limit=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['offset'])) $this->offset = $o['offset'];
if (isset($o['limit'])) $this->limit = $o['limit'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->offset)) $o['offset'] = $this->offset;
if (isset($this->limit)) $o['limit'] = $this->limit;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class V4BaseResponse implements JsonSerializable
{
public function __construct(
// @DataMember(Name="status")
/** @var ResponseStatus|null */
public ?ResponseStatus $status=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['status'])) $this->status = JsonConverters::from('ResponseStatus', $o['status']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->status)) $o['status'] = JsonConverters::to('ResponseStatus', $this->status);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class V4PageObject implements JsonSerializable
{
public function __construct(
// @DataMember(Name="offset")
/** @var int */
public int $offset=0,
// @DataMember(Name="limit")
/** @var int */
public int $limit=0,
// @DataMember(Name="totalRecords")
/** @var int */
public int $totalRecords=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['offset'])) $this->offset = $o['offset'];
if (isset($o['limit'])) $this->limit = $o['limit'];
if (isset($o['totalRecords'])) $this->totalRecords = $o['totalRecords'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->offset)) $o['offset'] = $this->offset;
if (isset($this->limit)) $o['limit'] = $this->limit;
if (isset($this->totalRecords)) $o['totalRecords'] = $this->totalRecords;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class V4PaginatedBaseResponse extends V4BaseResponse implements JsonSerializable
{
/**
* @param ResponseStatus|null $status
*/
public function __construct(
?ResponseStatus $status=null,
// @DataMember(Name="page")
/** @var V4PageObject|null */
public ?V4PageObject $page=null
) {
parent::__construct($status);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['page'])) $this->page = JsonConverters::from('V4PageObject', $o['page']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->page)) $o['page'] = JsonConverters::to('V4PageObject', $this->page);
return empty($o) ? new class(){} : $o;
}
}
enum LinkType : string
{
case None = 'None';
case Simple = 'Simple';
case Split = 'Split';
case Interstitial = 'Interstitial';
case Advanced = 'Advanced';
case Collection = 'Collection';
}
class RefreshableMetadata implements IRefreshableMetadata, JsonSerializable
{
public function __construct(
/** @var DateTime */
public DateTime $createdDate=new DateTime(),
/** @var DateTime */
public DateTime $updatedDate=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
if (isset($o['updatedDate'])) $this->updatedDate = JsonConverters::from('DateTime', $o['updatedDate']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
if (isset($this->updatedDate)) $o['updatedDate'] = JsonConverters::to('DateTime', $this->updatedDate);
return empty($o) ? new class(){} : $o;
}
}
class VersionedRefreshableMetadata extends RefreshableMetadata implements JsonSerializable
{
/**
* @param DateTime $createdDate
* @param DateTime $updatedDate
*/
public function __construct(
DateTime $createdDate=new DateTime(),
DateTime $updatedDate=new DateTime(),
/** @var DateTime */
public DateTime $versionCreatedDate=new DateTime()
) {
parent::__construct($createdDate,$updatedDate);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['versionCreatedDate'])) $this->versionCreatedDate = JsonConverters::from('DateTime', $o['versionCreatedDate']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->versionCreatedDate)) $o['versionCreatedDate'] = JsonConverters::to('DateTime', $this->versionCreatedDate);
return empty($o) ? new class(){} : $o;
}
}
/**
* @property string|null $url
* @property string|null $baseCode
* @property LinkType $linkType
* @property string|null $typeDefinitionPublicId
* @property VersionedRefreshableMetadata|null $metadata
*/
interface IUserLink
{
}
// @DataContract
class GetUserLinksResponse extends V4PaginatedBaseResponse implements IGetUserLinksResponse, JsonSerializable
{
/**
* @param ResponseStatus|null $status
* @param V4PageObject|null $page
*/
public function __construct(
?ResponseStatus $status=null,
?V4PageObject $page=null,
// @DataMember(Name="data")
/** @var array<IUserLink>|null */
public ?array $data=null
) {
parent::__construct($status,$page);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['data'])) $this->data = JsonConverters::fromArray('IUserLink', $o['data']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->data)) $o['data'] = JsonConverters::toArray('IUserLink', $this->data);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class GetUserLinksRequest extends V4PaginatedBaseRequest implements JsonSerializable
{
/**
* @param int $offset
* @param int $limit
*/
public function __construct(
int $offset=0,
int $limit=0,
// @DataMember(Name="username")
/** @var string|null */
public ?string $username=null,
// @DataMember(Name="groupId")
/** @var int */
public int $groupId=0,
// @DataMember(Name="linkType")
/** @var LinkType|null */
public ?LinkType $linkType=null
) {
parent::__construct($offset,$limit);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['username'])) $this->username = $o['username'];
if (isset($o['groupId'])) $this->groupId = $o['groupId'];
if (isset($o['linkType'])) $this->linkType = JsonConverters::from('LinkType', $o['linkType']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->username)) $o['username'] = $this->username;
if (isset($this->groupId)) $o['groupId'] = $this->groupId;
if (isset($this->linkType)) $o['linkType'] = JsonConverters::to('LinkType', $this->linkType);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /v4/links/list HTTP/1.1 Host: shortlinks-api.qa.platform.georiot.com Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<GetUserLinksResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ShortlinksAPI.ServiceModel.V4.Responses">
<status 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>
</status>
<page>
<limit>0</limit>
<offset>0</offset>
<totalRecords>0</totalRecords>
</page>
<data xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
</GetUserLinksResponse>