BokaMera.API.Host

<back to all web services

CompanyTrialsQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read
The following routes are available for this service:
GET/trials/company/Get all company started trialsGet all trials that have been started for a specific company
<?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 TrialQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Name=null,
        /** @var int */
        public int $TrialDays=0
    ) {
    }

    /** @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['TrialDays'])) $this->TrialDays = $o['TrialDays'];
    }
    
    /** @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->TrialDays)) $o['TrialDays'] = $this->TrialDays;
        return empty($o) ? new class(){} : $o;
    }
}

class CompanyTrialQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $TrialTypeId=0,
        /** @var TrialQueryResponse|null */
        public ?TrialQueryResponse $TrialType=null,
        /** @var DateTime|null */
        public ?DateTime $Started=null,
        /** @var DateTime */
        public DateTime $Created=new DateTime(),
        /** @var DateTime|null */
        public ?DateTime $ValidTo=null,
        /** @var bool|null */
        public ?bool $Active=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['TrialTypeId'])) $this->TrialTypeId = $o['TrialTypeId'];
        if (isset($o['TrialType'])) $this->TrialType = JsonConverters::from('TrialQueryResponse', $o['TrialType']);
        if (isset($o['Started'])) $this->Started = JsonConverters::from('DateTime', $o['Started']);
        if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
        if (isset($o['ValidTo'])) $this->ValidTo = JsonConverters::from('DateTime', $o['ValidTo']);
        if (isset($o['Active'])) $this->Active = $o['Active'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->TrialTypeId)) $o['TrialTypeId'] = $this->TrialTypeId;
        if (isset($this->TrialType)) $o['TrialType'] = JsonConverters::to('TrialQueryResponse', $this->TrialType);
        if (isset($this->Started)) $o['Started'] = JsonConverters::to('DateTime', $this->Started);
        if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
        if (isset($this->ValidTo)) $o['ValidTo'] = JsonConverters::to('DateTime', $this->ValidTo);
        if (isset($this->Active)) $o['Active'] = $this->Active;
        return empty($o) ? new class(){} : $o;
    }
}

// @ValidateRequest(Validator="IsAuthenticated")
class CompanyTrialsQuery implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description Enter the company and id you want to see the information for a resource, if blank company id and you are an admin, your company id will be used. If blank id, all resources will be shown  */
        // @ApiMember(Description="Enter the company and id you want to see the information for a resource, if blank company id and you are an admin, your company id will be used. If blank id, all resources will be shown ", IsRequired=true, ParameterType="query")
        /** @var string */
        public string $CompanyId='',

        /** @description Trial Id */
        // @ApiMember(Description="Trial Id", IsRequired=true, ParameterType="query")
        /** @var int */
        public int $Id=0
    ) {
    }

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

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

GET /trials/company/ HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"TrialTypeId":0,"TrialType":{"Id":0,"Name":"String","TrialDays":0},"Started":"0001-01-01T00:00:00","ValidTo":"0001-01-01T00:00:00","Active":false}