BokaMera.API.Host

<back to all web services

CreateVossUsage

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/voss/usageAdd product to company invoicingAdd new product to company invoicing. Sends that product to VOSS 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};


enum ProductGroupTypeEnum : string
{
    case Optional = 'Optional';
    case Included = 'Included';
}

enum StatusEnum : string
{
    case Active = 'Active';
    case Terminated = 'Terminated';
}

// @DataContract(Name="SubscriptionProductGroupProductResultDto")
class SubscriptionProductGroupProductResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="name", IsRequired=true)
        /** @var string */
        public string $name='',

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

        // @DataMember(Name="articleNumber", IsRequired=true)
        /** @var string */
        public string $articleNumber=''
    ) {
    }

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

enum TypeEnum : string
{
    case AtSubscriptionBillingPeriodEnd = 'AtSubscriptionBillingPeriodEnd';
    case AtBindingPeriodEnd = 'AtBindingPeriodEnd';
    case Immediately = 'Immediately';
}

enum SourceEnum : string
{
    case Direct = 'Direct';
    case Plan = 'Plan';
    case CustomerExpiration = 'CustomerExpiration';
    case Update = 'Update';
    case Unpaid = 'Unpaid';
}

// @DataContract(Name="SubscriptionItemTerminationReasonDto")
class SubscriptionItemTerminationReasonDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="reasonId", IsRequired=true)
        /** @var string */
        public string $reasonId='',

        // @DataMember(Name="reasonName", IsRequired=true)
        /** @var string */
        public string $reasonName='',

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

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

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

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

        // @DataMember(Name="comment", IsRequired=true)
        /** @var string */
        public string $comment=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['reasonId'])) $this->reasonId = $o['reasonId'];
        if (isset($o['reasonName'])) $this->reasonName = $o['reasonName'];
        if (isset($o['reasonExternalId'])) $this->reasonExternalId = $o['reasonExternalId'];
        if (isset($o['subReasonId'])) $this->subReasonId = $o['subReasonId'];
        if (isset($o['subReasonName'])) $this->subReasonName = $o['subReasonName'];
        if (isset($o['subReasonExternalId'])) $this->subReasonExternalId = $o['subReasonExternalId'];
        if (isset($o['comment'])) $this->comment = $o['comment'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->reasonId)) $o['reasonId'] = $this->reasonId;
        if (isset($this->reasonName)) $o['reasonName'] = $this->reasonName;
        if (isset($this->reasonExternalId)) $o['reasonExternalId'] = $this->reasonExternalId;
        if (isset($this->subReasonId)) $o['subReasonId'] = $this->subReasonId;
        if (isset($this->subReasonName)) $o['subReasonName'] = $this->subReasonName;
        if (isset($this->subReasonExternalId)) $o['subReasonExternalId'] = $this->subReasonExternalId;
        if (isset($this->comment)) $o['comment'] = $this->comment;
        return empty($o) ? new class(){} : $o;
    }
}

enum SubscriptionBehaviourEnum : string
{
    case Prorate = 'Prorate';
    case Full = 'Full';
    case None = 'None';
}

enum CreditKindEnum : string
{
    case Normal = 'Normal';
    case Internal = 'Internal';
}

// @DataContract(Name="CreditOptionsDto")
class CreditOptionsDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="behaviour", IsRequired=true)
        /** @var SubscriptionBehaviourEnum|null */
        public ?SubscriptionBehaviourEnum $behaviour=null,

        // @DataMember(Name="creditKind", IsRequired=true)
        /** @var CreditKindEnum|null */
        public ?CreditKindEnum $creditKind=null,

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

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

// @DataContract(Name="SubscriptionItemTerminationDto")
class SubscriptionItemTerminationDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="type")
        /** @var TypeEnum|null */
        public ?TypeEnum $type=null,

        // @DataMember(Name="source", IsRequired=true)
        /** @var SourceEnum|null */
        public ?SourceEnum $source=null,

        // @DataMember(Name="scheduledDate", IsRequired=true)
        /** @var DateTime */
        public DateTime $scheduledDate=new DateTime(),

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

        // @DataMember(Name="creditOptions", IsRequired=true)
        /** @var CreditOptionsDto|null */
        public ?CreditOptionsDto $creditOptions=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['type'])) $this->type = JsonConverters::from('TypeEnum', $o['type']);
        if (isset($o['source'])) $this->source = JsonConverters::from('SourceEnum', $o['source']);
        if (isset($o['scheduledDate'])) $this->scheduledDate = JsonConverters::from('DateTime', $o['scheduledDate']);
        if (isset($o['reason'])) $this->reason = JsonConverters::from('SubscriptionItemTerminationReasonDto', $o['reason']);
        if (isset($o['creditOptions'])) $this->creditOptions = JsonConverters::from('CreditOptionsDto', $o['creditOptions']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->type)) $o['type'] = JsonConverters::to('TypeEnum', $this->type);
        if (isset($this->source)) $o['source'] = JsonConverters::to('SourceEnum', $this->source);
        if (isset($this->scheduledDate)) $o['scheduledDate'] = JsonConverters::to('DateTime', $this->scheduledDate);
        if (isset($this->reason)) $o['reason'] = JsonConverters::to('SubscriptionItemTerminationReasonDto', $this->reason);
        if (isset($this->creditOptions)) $o['creditOptions'] = JsonConverters::to('CreditOptionsDto', $this->creditOptions);
        return empty($o) ? new class(){} : $o;
    }
}

enum ProductTypeEnum : string
{
    case Main = 'Main';
    case Addon = 'Addon';
    case License = 'License';
    case Usage = 'Usage';
}

// @DataContract(Name="CustomerBalanceChangeItemDto")
class CustomerBalanceChangeItemDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="type", IsRequired=true)
        /** @var ProductTypeEnum|null */
        public ?ProductTypeEnum $type=null,

        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="name", IsRequired=true)
        /** @var string */
        public string $name='',

        // @DataMember(Name="productGroupId", IsRequired=true)
        /** @var string */
        public string $productGroupId='',

        // @DataMember(Name="productGroupName", IsRequired=true)
        /** @var string */
        public string $productGroupName='',

        // @DataMember(Name="quantity", IsRequired=true)
        /** @var float */
        public float $quantity=0.0,

        // @DataMember(Name="amount", IsRequired=true)
        /** @var float */
        public float $amount=0.0,

        // @DataMember(Name="discountAmount", IsRequired=true)
        /** @var float */
        public float $discountAmount=0.0,

        // @DataMember(Name="totalAmount", EmitDefaultValue=false)
        /** @var float */
        public float $totalAmount=0.0,

        // @DataMember(Name="invoiceRecipientCustomerId", IsRequired=true)
        /** @var string */
        public string $invoiceRecipientCustomerId=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['type'])) $this->type = JsonConverters::from('ProductTypeEnum', $o['type']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['productGroupId'])) $this->productGroupId = $o['productGroupId'];
        if (isset($o['productGroupName'])) $this->productGroupName = $o['productGroupName'];
        if (isset($o['quantity'])) $this->quantity = $o['quantity'];
        if (isset($o['amount'])) $this->amount = $o['amount'];
        if (isset($o['discountAmount'])) $this->discountAmount = $o['discountAmount'];
        if (isset($o['totalAmount'])) $this->totalAmount = $o['totalAmount'];
        if (isset($o['invoiceRecipientCustomerId'])) $this->invoiceRecipientCustomerId = $o['invoiceRecipientCustomerId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->type)) $o['type'] = JsonConverters::to('ProductTypeEnum', $this->type);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->productGroupId)) $o['productGroupId'] = $this->productGroupId;
        if (isset($this->productGroupName)) $o['productGroupName'] = $this->productGroupName;
        if (isset($this->quantity)) $o['quantity'] = $this->quantity;
        if (isset($this->amount)) $o['amount'] = $this->amount;
        if (isset($this->discountAmount)) $o['discountAmount'] = $this->discountAmount;
        if (isset($this->totalAmount)) $o['totalAmount'] = $this->totalAmount;
        if (isset($this->invoiceRecipientCustomerId)) $o['invoiceRecipientCustomerId'] = $this->invoiceRecipientCustomerId;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CustomerBalanceChangeDto")
class CustomerBalanceChangeDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="items", EmitDefaultValue=false)
        /** @var array<CustomerBalanceChangeItemDto>|null */
        public ?array $items=null,

        // @DataMember(Name="totalAmount", EmitDefaultValue=false)
        /** @var float */
        public float $totalAmount=0.0,

        // @DataMember(Name="totalDiscountAmount", EmitDefaultValue=false)
        /** @var float */
        public float $totalDiscountAmount=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['items'])) $this->items = JsonConverters::fromArray('CustomerBalanceChangeItemDto', $o['items']);
        if (isset($o['totalAmount'])) $this->totalAmount = $o['totalAmount'];
        if (isset($o['totalDiscountAmount'])) $this->totalDiscountAmount = $o['totalDiscountAmount'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->items)) $o['items'] = JsonConverters::toArray('CustomerBalanceChangeItemDto', $this->items);
        if (isset($this->totalAmount)) $o['totalAmount'] = $this->totalAmount;
        if (isset($this->totalDiscountAmount)) $o['totalDiscountAmount'] = $this->totalDiscountAmount;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CreateSubscriptionProductGroupResult")
class CreateSubscriptionProductGroupResult implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="productGroupType", IsRequired=true)
        /** @var ProductGroupTypeEnum|null */
        public ?ProductGroupTypeEnum $productGroupType=null,

        // @DataMember(Name="status", IsRequired=true)
        /** @var StatusEnum|null */
        public ?StatusEnum $status=null,

        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="name", IsRequired=true)
        /** @var string */
        public string $name='',

        // @DataMember(Name="products", EmitDefaultValue=false)
        /** @var array<SubscriptionProductGroupProductResultDto>|null */
        public ?array $products=null,

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

        // @DataMember(Name="created", IsRequired=true)
        /** @var DateTime */
        public DateTime $created=new DateTime(),

        // @DataMember(Name="customerBalanceChange", IsRequired=true)
        /** @var CustomerBalanceChangeDto|null */
        public ?CustomerBalanceChangeDto $customerBalanceChange=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['productGroupType'])) $this->productGroupType = JsonConverters::from('ProductGroupTypeEnum', $o['productGroupType']);
        if (isset($o['status'])) $this->status = JsonConverters::from('StatusEnum', $o['status']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['products'])) $this->products = JsonConverters::fromArray('SubscriptionProductGroupProductResultDto', $o['products']);
        if (isset($o['termination'])) $this->termination = JsonConverters::from('SubscriptionItemTerminationDto', $o['termination']);
        if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
        if (isset($o['customerBalanceChange'])) $this->customerBalanceChange = JsonConverters::from('CustomerBalanceChangeDto', $o['customerBalanceChange']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->productGroupType)) $o['productGroupType'] = JsonConverters::to('ProductGroupTypeEnum', $this->productGroupType);
        if (isset($this->status)) $o['status'] = JsonConverters::to('StatusEnum', $this->status);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->products)) $o['products'] = JsonConverters::toArray('SubscriptionProductGroupProductResultDto', $this->products);
        if (isset($this->termination)) $o['termination'] = JsonConverters::to('SubscriptionItemTerminationDto', $this->termination);
        if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
        if (isset($this->customerBalanceChange)) $o['customerBalanceChange'] = JsonConverters::to('CustomerBalanceChangeDto', $this->customerBalanceChange);
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateVossUsage implements JsonSerializable
{
    public function __construct(
        /** @description The company id */
        // @ApiMember(Description="The company id", IsRequired=true)
        /** @var string */
        public string $CompanyId='',

        /** @description Article number. Can be fetched from products */
        // @ApiMember(Description="Article number. Can be fetched from products", IsRequired=true)
        /** @var string */
        public string $ArticleNumber='',

        /** @description Example: developer worked 6 hours */
        // @ApiMember(Description="Example: developer worked 6 hours", IsRequired=true)
        /** @var int */
        public int $Quantity=0
    ) {
    }

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

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

POST /voss/usage HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"ArticleNumber":"String","Quantity":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"productGroupType":"Optional","status":"Active","name":"String","products":[{}]}