Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /trials/company/ | Add new trial to a company | Start a new trial to the company for the 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 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;
}
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class AddCompanyTrial implements ICompany, JsonSerializable
{
public function __construct(
/** @description The company id, if empty will use the company id for the user you are logged in with. */
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
/** @var string|null */
public ?string $CompanyId=null,
/** @description Id of the trial type */
// @ApiMember(Description="Id of the trial type", IsRequired=true)
/** @var int */
public int $TrialTypeId=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['TrialTypeId'])) $this->TrialTypeId = $o['TrialTypeId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->TrialTypeId)) $o['TrialTypeId'] = $this->TrialTypeId;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /trials/company/ HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<AddCompanyTrial xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<TrialTypeId>0</TrialTypeId>
</AddCompanyTrial>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CompanyTrialQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <Active>false</Active> <Created>0001-01-01T00:00:00</Created> <Started>0001-01-01T00:00:00</Started> <TrialType> <Id>0</Id> <Name>String</Name> <TrialDays>0</TrialDays> </TrialType> <TrialTypeId>0</TrialTypeId> <ValidTo>0001-01-01T00:00:00</ValidTo> </CompanyTrialQueryResponse>