Booklinker.API

<back to all web services

GetShortLinkMetadataRequest

The following routes are available for this service:
GET/v1/shortlink/metadata
<?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 ProductMetadata extends ProductMetadata implements JsonSerializable
{
    /**
     * @param string|null $title
     * @param string|null $author
     * @param string|null $url
     * @param string|null $description
     * @param string|null $retailer
     * @param array<string,string>|null $productImages
     */
    public function __construct(
        ?string $title=null,
        ?string $author=null,
        ?string $url=null,
        ?string $description=null,
        ?string $retailer=null,
        ?array $productImages=null
    ) {
        parent::__construct($title,$author,$url,$description,$retailer,$productImages);
    }

    /** @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 Destination implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="isSuggestion")
        /** @var bool|null */
        public ?bool $isSuggestion=null,

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

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

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

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

// @DataContract
class GetShortLinkMetadataResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="baseCode")
        /** @var string|null */
        public ?string $baseCode=null,

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

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

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

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

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

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

// @DataContract
class GetShortLinkMetadataRequest implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="domain")
        /** @var string|null */
        public ?string $domain=null,

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

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

// @DataContract
class ProductMetadata implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="title")
        /** @var string|null */
        public ?string $title=null,

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

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

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

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

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

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['title'])) $this->title = $o['title'];
        if (isset($o['author'])) $this->author = $o['author'];
        if (isset($o['url'])) $this->url = JsonConverters::from('string', $o['url']);
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['retailer'])) $this->retailer = $o['retailer'];
        if (isset($o['productImages'])) $this->productImages = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','Uri']), $o['productImages']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->title)) $o['title'] = $this->title;
        if (isset($this->author)) $o['author'] = $this->author;
        if (isset($this->url)) $o['url'] = JsonConverters::to('string', $this->url);
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->retailer)) $o['retailer'] = $this->retailer;
        if (isset($this->productImages)) $o['productImages'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','Uri']), $this->productImages);
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetShortLinkMetadataRequest DTOs

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

HTTP + CSV

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

GET /v1/shortlink/metadata HTTP/1.1 
Host: api.booklinker.com 
Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"baseCode":"String","domain":"String","code":"String","productMetadata":{"title":"String","author":"String","description":"String","retailer":"String"},"destinations":[{"isSuggestion":false,"isAutoSuggestion":false,"destinationUrl":"String","replacementButton":"String"}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}