Booklinker.API

<back to all web services

GetLinksRequest

Requires Authentication
The following routes are available for this service:
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;
    }
}

PHP GetLinksRequest DTOs

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

HTTP + OTHER

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: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"allLinksLoaded":false,"results":[{"baseCode":"String","url":"String","originalUrl":"String","imageUrl":"String","retailer":"String","title":"String","author":"String"}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}