Booklinker.API

<back to all web services

PostUnclaimedLinkCreationRequest

The following routes are available for this service:
POST/v1/links/unclaimed
<?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 PostLinkCreationRequestBase implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="url")
        // @ApiMember(IsRequired=true)
        /** @var string */
        public string $url='',

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

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

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

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

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

        // @DataMember(Name="destinations")
        /** @var array<ProductMetadata>|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['success'])) $this->success = $o['success'];
        if (isset($o['linkResult'])) $this->linkResult = $o['linkResult'];
        if (isset($o['destinations'])) $this->destinations = JsonConverters::fromArray('ProductMetadata', $o['destinations']);
        if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->success)) $o['success'] = $this->success;
        if (isset($this->linkResult)) $o['linkResult'] = $this->linkResult;
        if (isset($this->destinations)) $o['destinations'] = JsonConverters::toArray('ProductMetadata', $this->destinations);
        if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class AffiliateTokens implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="guid")
        /** @var string */
        public string $guid='',

        // @DataMember(Name="programGuid")
        /** @var string */
        public string $programGuid='',

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

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

class PostUnclaimedLinkCreationRequest extends PostLinkCreationRequestBase implements JsonSerializable
{
    /**
     * @param string $url
     * @param string|null $domain
     * @param array<string,string>|null $parameterKeyValues
     */
    public function __construct(
        string $url='',
        ?string $domain=null,
        ?array $parameterKeyValues=null,
        // @DataMember(Name="affiliatePrograms")
        /** @var array<AffiliateTokens>|null */
        public ?array $affiliatePrograms=null
    ) {
        parent::__construct($url,$domain,$parameterKeyValues);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['affiliatePrograms'])) $this->affiliatePrograms = JsonConverters::fromArray('AffiliateTokens', $o['affiliatePrograms']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->affiliatePrograms)) $o['affiliatePrograms'] = JsonConverters::toArray('AffiliateTokens', $this->affiliatePrograms);
        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 PostUnclaimedLinkCreationRequest DTOs

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

HTTP + XML

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

POST /v1/links/unclaimed HTTP/1.1 
Host: api.booklinker.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<PostUnclaimedLinkCreationRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.V1.Requests">
  <domain>String</domain>
  <parameterKeyValues xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </parameterKeyValues>
  <url>String</url>
  <AffiliatePrograms xmlns:d2p1="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.V1.DTOs">
    <d2p1:AffiliateTokens>
      <d2p1:affiliateTokens xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </d2p1:affiliateTokens>
      <d2p1:guid>00000000-0000-0000-0000-000000000000</d2p1:guid>
      <d2p1:programGuid>00000000-0000-0000-0000-000000000000</d2p1:programGuid>
    </d2p1:AffiliateTokens>
  </AffiliatePrograms>
</PostUnclaimedLinkCreationRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<PostLinkCreationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.V1.Responses">
  <destinations xmlns:d2p1="http://schemas.datacontract.org/2004/07/Booklinker.API.ServiceModel.V1.DTOs" i:nil="true" />
  <linkResult>String</linkResult>
  <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>
  <success>false</success>
</PostLinkCreationResponse>