| GET | /v1/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 PaginatedBaseRequest implements JsonSerializable
{
public function __construct(
// @DataMember(Name="skip")
/** @var int */
public int $skip=0,
// @DataMember(Name="take")
/** @var int */
public int $take=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['skip'])) $this->skip = $o['skip'];
if (isset($o['take'])) $this->take = $o['take'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->skip)) $o['skip'] = $this->skip;
if (isset($this->take)) $o['take'] = $this->take;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class LinkResult implements JsonSerializable
{
public function __construct(
// @DataMember(Name="baseCode")
/** @var string|null */
public ?string $baseCode=null,
// @DataMember(Name="url")
/** @var string|null */
public ?string $url=null,
// @DataMember(Name="originalUrl")
/** @var string|null */
public ?string $originalUrl=null,
// @DataMember(Name="imageUrl")
/** @var string|null */
public ?string $imageUrl=null,
// @DataMember(Name="retailer")
/** @var string|null */
public ?string $retailer=null,
// @DataMember(Name="title")
/** @var string|null */
public ?string $title=null,
// @DataMember(Name="author")
/** @var string|null */
public ?string $author=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['baseCode'])) $this->baseCode = $o['baseCode'];
if (isset($o['url'])) $this->url = $o['url'];
if (isset($o['originalUrl'])) $this->originalUrl = $o['originalUrl'];
if (isset($o['imageUrl'])) $this->imageUrl = $o['imageUrl'];
if (isset($o['retailer'])) $this->retailer = $o['retailer'];
if (isset($o['title'])) $this->title = $o['title'];
if (isset($o['author'])) $this->author = $o['author'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->baseCode)) $o['baseCode'] = $this->baseCode;
if (isset($this->url)) $o['url'] = $this->url;
if (isset($this->originalUrl)) $o['originalUrl'] = $this->originalUrl;
if (isset($this->imageUrl)) $o['imageUrl'] = $this->imageUrl;
if (isset($this->retailer)) $o['retailer'] = $this->retailer;
if (isset($this->title)) $o['title'] = $this->title;
if (isset($this->author)) $o['author'] = $this->author;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class GetLinksResponse implements JsonSerializable
{
public function __construct(
// @DataMember(Name="allLinksLoaded")
/** @var bool|null */
public ?bool $allLinksLoaded=null,
// @DataMember(Name="results")
/** @var array<LinkResult>|null */
public ?array $results=null,
// @DataMember(Name="responseStatus")
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['allLinksLoaded'])) $this->allLinksLoaded = $o['allLinksLoaded'];
if (isset($o['results'])) $this->results = JsonConverters::fromArray('LinkResult', $o['results']);
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->allLinksLoaded)) $o['allLinksLoaded'] = $this->allLinksLoaded;
if (isset($this->results)) $o['results'] = JsonConverters::toArray('LinkResult', $this->results);
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class GetLinksRequest extends PaginatedBaseRequest implements JsonSerializable
{
/**
* @param int $skip
* @param int $take
*/
public function __construct(
int $skip=0,
int $take=0,
// @DataMember(Name="ids")
/** @var array<string>|null */
public ?array $ids=null
) {
parent::__construct($skip,$take);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['ids'])) $this->ids = JsonConverters::fromArray('string', $o['ids']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->ids)) $o['ids'] = JsonConverters::toArray('string', $this->ids);
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 /v1/links/list HTTP/1.1 Host: api.booklinker.com Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<GetLinksResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.V1.Responses">
<allLinksLoaded>false</allLinksLoaded>
<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>
<results xmlns:d2p1="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.DTOs.Shortlinks">
<d2p1:LinkResult>
<d2p1:author>String</d2p1:author>
<d2p1:baseCode>String</d2p1:baseCode>
<d2p1:imageUrl>String</d2p1:imageUrl>
<d2p1:originalUrl>String</d2p1:originalUrl>
<d2p1:retailer>String</d2p1:retailer>
<d2p1:title>String</d2p1:title>
<d2p1:url>String</d2p1:url>
</d2p1:LinkResult>
</results>
</GetLinksResponse>