Booklinker.API

<back to all web services

GetCollectionRequest

Requires Authentication
The following routes are available for this service:
GET/v2/collections
GET/v2/collections/{Id}
<?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 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 UserCollection implements IUserCollection, JsonSerializable
{
    public function __construct(
        // @DataMember(Name="type")
        /** @var string|null */
        public ?string $type=null,

        // @DataMember(Name="id")
        /** @var string|null */
        public ?string $id=null,

        // @DataMember(Name="baseCode")
        /** @var string|null */
        public ?string $baseCode=null,

        // @DataMember(Name="url")
        /** @var string|null */
        public ?string $url=null,

        // @DataMember(Name="title")
        /** @var string|null */
        public ?string $title=null,

        // @DataMember(Name="linkIds")
        /** @var array<string>|null */
        public ?array $linkIds=null,

        // @DataMember(Name="collectionSettingsId")
        /** @var string|null */
        public ?string $collectionSettingsId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['type'])) $this->type = $o['type'];
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['baseCode'])) $this->baseCode = $o['baseCode'];
        if (isset($o['url'])) $this->url = $o['url'];
        if (isset($o['title'])) $this->title = $o['title'];
        if (isset($o['linkIds'])) $this->linkIds = JsonConverters::fromArray('string', $o['linkIds']);
        if (isset($o['collectionSettingsId'])) $this->collectionSettingsId = $o['collectionSettingsId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->type)) $o['type'] = $this->type;
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->baseCode)) $o['baseCode'] = $this->baseCode;
        if (isset($this->url)) $o['url'] = $this->url;
        if (isset($this->title)) $o['title'] = $this->title;
        if (isset($this->linkIds)) $o['linkIds'] = JsonConverters::toArray('string', $this->linkIds);
        if (isset($this->collectionSettingsId)) $o['collectionSettingsId'] = $this->collectionSettingsId;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class GetCollectionResponse extends V2BaseResponse implements JsonSerializable
{
    /**
     * @param ResponseStatus|null $responseStatus
     */
    public function __construct(
        ?ResponseStatus $responseStatus=null,
        // @DataMember(Name="data")
        /** @var UserCollection|null */
        public ?UserCollection $data=null
    ) {
        parent::__construct($responseStatus);
    }

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

// @DataContract
class GetCollectionRequest extends V2BaseRequest implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="id")
        /** @var string|null */
        public ?string $id=null
    ) {
    }

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

PHP GetCollectionRequest 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 /v2/collections HTTP/1.1 
Host: api.booklinker.com 
Accept: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"data":{"type":"collection","id":"String","baseCode":"String","url":"String","title":"String","collectionSettingsId":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}