BokaMera.API.Host

<back to all web services

CreateArticle

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/articlesAdd new articleAdd article to the company for the currently logged in user
<?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};


class BaseModel implements JsonSerializable
{
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        return empty($o) ? new class(){} : $o;
    }
}

class ArticleServiceRelation extends BaseModel implements JsonSerializable
{
    public function __construct(
        // @Required()
        /** @var string */
        public string $CompanyId='',

        /** @var int */
        public int $Id=0,
        // @Required()
        /** @var int */
        public int $ServiceId=0,

        // @Required()
        /** @var int */
        public int $ArticleId=0
    ) {
    }

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

class ArticleResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $CompanyId='',
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Name=null,
        /** @var int */
        public int $ArticleTypeId=0,
        /** @var string|null */
        public ?string $Description=null,
        /** @var string|null */
        public ?string $ImageUrl=null,
        /** @var bool|null */
        public ?bool $Active=null,
        /** @var int */
        public int $Amount=0,
        /** @var float */
        public float $Price=0.0,
        /** @var string|null */
        public ?string $CurrencyId=null,
        /** @var DateTime */
        public DateTime $UpdatedDate=new DateTime(),
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime(),
        /** @var array<ArticleServiceRelation>|null */
        public ?array $Services=null,
        /** @var array<int>|null */
        public ?array $ServiceIds=null,
        /** @var string|null */
        public ?string $PriceSign=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['ArticleTypeId'])) $this->ArticleTypeId = $o['ArticleTypeId'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ImageUrl'])) $this->ImageUrl = $o['ImageUrl'];
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['Amount'])) $this->Amount = $o['Amount'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
        if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
        if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
        if (isset($o['Services'])) $this->Services = JsonConverters::fromArray('ArticleServiceRelation', $o['Services']);
        if (isset($o['ServiceIds'])) $this->ServiceIds = JsonConverters::fromArray('int', $o['ServiceIds']);
        if (isset($o['PriceSign'])) $this->PriceSign = $o['PriceSign'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->ArticleTypeId)) $o['ArticleTypeId'] = $this->ArticleTypeId;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ImageUrl)) $o['ImageUrl'] = $this->ImageUrl;
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->Amount)) $o['Amount'] = $this->Amount;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
        if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
        if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
        if (isset($this->Services)) $o['Services'] = JsonConverters::toArray('ArticleServiceRelation', $this->Services);
        if (isset($this->ServiceIds)) $o['ServiceIds'] = JsonConverters::toArray('int', $this->ServiceIds);
        if (isset($this->PriceSign)) $o['PriceSign'] = $this->PriceSign;
        return empty($o) ? new class(){} : $o;
    }
}

class CreateArticle implements JsonSerializable
{
    public function __construct(
        /** @description  */
        // @ApiMember(Description="")
        /** @var string|null */
        public ?string $CompanyId=null,

        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var string */
        public string $Name='',

        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var int */
        public int $ArticleTypeId=0,

        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var string */
        public string $Description='',

        /** @description  */
        // @ApiMember(Description="")
        /** @var string|null */
        public ?string $ImageUrl=null,

        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var bool|null */
        public ?bool $Active=null,

        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var int */
        public int $Amount=0,

        /** @description . */
        // @ApiMember(Description=".", IsRequired=true)
        /** @var float */
        public float $Price=0.0,

        /** @description The payment currency id */
        // @ApiMember(Description="The payment currency id", IsRequired=true)
        /** @var string */
        public string $CurrencyId='',

        /** @description Query for specific services. */
        // @ApiMember(Description="Query for specific services.", ParameterType="query")
        /** @var int[]|null */
        public ?array $ServiceIds=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['ArticleTypeId'])) $this->ArticleTypeId = $o['ArticleTypeId'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['Amount'])) $this->Amount = $o['Amount'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
        if (isset($o['ServiceIds'])) $this->ServiceIds = JsonConverters::fromArray('int', $o['ServiceIds']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->ArticleTypeId)) $o['ArticleTypeId'] = $this->ArticleTypeId;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->Amount)) $o['Amount'] = $this->Amount;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
        if (isset($this->ServiceIds)) $o['ServiceIds'] = JsonConverters::toArray('int', $this->ServiceIds);
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateArticle 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 /articles HTTP/1.1 
Host: api.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateArticle xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <Active>false</Active>
  <Amount>0</Amount>
  <ArticleTypeId>0</ArticleTypeId>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CurrencyId>String</CurrencyId>
  <Description>String</Description>
  <ImageUrl i:nil="true" />
  <Name>String</Name>
  <Price>0</Price>
  <ServiceIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:int>0</d2p1:int>
  </ServiceIds>
</CreateArticle>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ArticleResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <Active>false</Active>
  <Amount>0</Amount>
  <ArticleTypeId>0</ArticleTypeId>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CreatedDate>0001-01-01T00:00:00</CreatedDate>
  <CurrencyId>String</CurrencyId>
  <Description>String</Description>
  <Id>0</Id>
  <ImageUrl>String</ImageUrl>
  <Name>String</Name>
  <Price>0</Price>
  <PriceSign>String</PriceSign>
  <ServiceIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:int>0</d2p1:int>
  </ServiceIds>
  <Services xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
    <d2p1:ArticleServiceRelation>
      <d2p1:ArticleId>0</d2p1:ArticleId>
      <d2p1:CompanyId>00000000-0000-0000-0000-000000000000</d2p1:CompanyId>
      <d2p1:Id>0</d2p1:Id>
      <d2p1:ServiceId>0</d2p1:ServiceId>
    </d2p1:ArticleServiceRelation>
  </Services>
  <UpdatedDate>0001-01-01T00:00:00</UpdatedDate>
</ArticleResponse>