Booklinker.API

<back to all web services

GetCollectionsRequest

Requires Authentication
The following routes are available for this service:
GET/v2/collections/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 V2BaseRequest implements JsonSerializable
{
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class V2PaginatedBaseRequest extends V2BaseRequest 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 V2ListRequest extends V2PaginatedBaseRequest implements JsonSerializable
{
    /**
     * @param int $offset
     * @param int $limit
     */
    public function __construct(
        int $offset=0,
        int $limit=0,
        // @DataMember(Name="ids")
        /** @var array<string>|null */
        public ?array $ids=null
    ) {
        parent::__construct($offset,$limit);
    }

    /** @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;
    }
}

// @DataContract
class V2BaseResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="responseStatus")
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class V2PageObject 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 V2PaginatedBaseResponse extends V2BaseResponse implements JsonSerializable
{
    /**
     * @param ResponseStatus|null $responseStatus
     */
    public function __construct(
        ?ResponseStatus $responseStatus=null,
        // @DataMember(Name="page")
        /** @var V2PageObject|null */
        public ?V2PageObject $page=null
    ) {
        parent::__construct($responseStatus);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['page'])) $this->page = JsonConverters::from('V2PageObject', $o['page']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->page)) $o['page'] = JsonConverters::to('V2PageObject', $this->page);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class GetCollectionsResponse extends V2PaginatedBaseResponse implements IGetCollectionsResponse, JsonSerializable
{
    /**
     * @param ResponseStatus|null $responseStatus
     * @param V2PageObject|null $page
     */
    public function __construct(
        ?ResponseStatus $responseStatus=null,
        ?V2PageObject $page=null
    ) {
        parent::__construct($responseStatus,$page);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class GetCollectionsRequest extends V2ListRequest implements JsonSerializable
{
    /**
     * @param int $offset
     * @param int $limit
     * @param array<string>|null $ids
     */
    public function __construct(
        int $offset=0,
        int $limit=0,
        ?array $ids=null
    ) {
        parent::__construct($offset,$limit,$ids);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetCollectionsRequest DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /v2/collections/list HTTP/1.1 
Host: api.booklinker.com 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"page":{"offset":0,"limit":0,"totalRecords":0},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}