BokaMera.API.Host

<back to all web services

CreateEAccountingArticle

The following routes are available for this service:
POST/eaccounting/articlesCreate a new article in e-accounting system
<?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 BaseArticleDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $ArticleId='',
        /** @var float */
        public float $ArticlePrice=0.0,
        /** @var string|null */
        public ?string $ArticleName=null,
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime()
    ) {
    }

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

class EAccountingArticleQueryResponse extends BaseArticleDto implements JsonSerializable
{
    /**
     * @param string $ArticleId
     * @param float $ArticlePrice
     * @param string|null $ArticleName
     * @param DateTime $CreatedDate
     */
    public function __construct(
        string $ArticleId='',
        float $ArticlePrice=0.0,
        ?string $ArticleName=null,
        DateTime $CreatedDate=new DateTime(),
        /** @var string|null */
        public ?string $UnitId=null,
        /** @var string|null */
        public ?string $CodingId=null,
        /** @var string|null */
        public ?string $VatRate=null,
        /** @var string|null */
        public ?string $VatRatePercent=null,
        /** @var string|null */
        public ?string $CurrencySign=null
    ) {
        parent::__construct($ArticleId,$ArticlePrice,$ArticleName,$CreatedDate);
    }

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

class CreateEAccountingArticle extends BaseArticleDto implements ICompany, JsonSerializable
{
    /**
     * @param string $ArticleId
     * @param float $ArticlePrice
     * @param string|null $ArticleName
     * @param DateTime $CreatedDate
     */
    public function __construct(
        string $ArticleId='',
        float $ArticlePrice=0.0,
        ?string $ArticleName=null,
        DateTime $CreatedDate=new DateTime(),
        /** @var int */
        public int $ServiceId=0,
        /** @var string|null */
        public ?string $CompanyId=null
    ) {
        parent::__construct($ArticleId,$ArticlePrice,$ArticleName,$CreatedDate);
    }

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

PHP CreateEAccountingArticle 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.

POST /eaccounting/articles HTTP/1.1 
Host: api.bokamera.se 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"ServiceId":0,"CompanyId":"00000000-0000-0000-0000-000000000000","ArticlePrice":0,"ArticleName":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"UnitId":"String","CodingId":"String","VatRate":"String","VatRatePercent":"String","CurrencySign":"String","ArticlePrice":0,"ArticleName":"String"}