Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /administrators/ | Add a new administrator to your company | If you want to add a new administrator to your company. A generated password will be sent to the 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 CompanyUserResource implements JsonSerializable
{
public function __construct(
/** @description The resource id */
// @ApiMember(Description="The resource id")
/** @var int */
public int $Id=0,
/** @description The resource name */
// @ApiMember(Description="The resource name")
/** @var string|null */
public ?string $Name=null,
/** @description The resource status */
// @ApiMember(Description="The resource status")
/** @var bool|null */
public ?bool $Active=null,
/** @description The resource description */
// @ApiMember(Description="The resource description")
/** @var string|null */
public ?string $Description=null,
/** @description The resource email */
// @ApiMember(Description="The resource email")
/** @var string|null */
public ?string $Email=null,
/** @description The resource phone */
// @ApiMember(Description="The resource phone")
/** @var string|null */
public ?string $Phone=null,
/** @description The resource color */
// @ApiMember(Description="The resource color")
/** @var string|null */
public ?string $Color=null,
/** @description The resource image */
// @ApiMember(Description="The resource image")
/** @var string|null */
public ?string $ImageUrl=null,
/** @description If the resource want to receive email notifications */
// @ApiMember(Description="If the resource want to receive email notifications")
/** @var bool|null */
public ?bool $EmailNotification=null,
/** @description If the resource want to receive sms notifications */
// @ApiMember(Description="If the resource want to receive sms notifications")
/** @var bool|null */
public ?bool $SMSNotification=null,
/** @description If the resource want to receive email reminders */
// @ApiMember(Description="If the resource want to receive email reminders")
/** @var bool|null */
public ?bool $EmailReminder=null,
/** @description If the resource want to receive sms reminders */
// @ApiMember(Description="If the resource want to receive sms reminders")
/** @var bool|null */
public ?bool $SMSReminder=null
) {
}
/** @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['Active'])) $this->Active = $o['Active'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['Phone'])) $this->Phone = $o['Phone'];
if (isset($o['Color'])) $this->Color = $o['Color'];
if (isset($o['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
if (isset($o['EmailNotification'])) $this->EmailNotification = $o['EmailNotification'];
if (isset($o['SMSNotification'])) $this->SMSNotification = $o['SMSNotification'];
if (isset($o['EmailReminder'])) $this->EmailReminder = $o['EmailReminder'];
if (isset($o['SMSReminder'])) $this->SMSReminder = $o['SMSReminder'];
}
/** @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->Active)) $o['Active'] = $this->Active;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->Phone)) $o['Phone'] = $this->Phone;
if (isset($this->Color)) $o['Color'] = $this->Color;
if (isset($this->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
if (isset($this->EmailNotification)) $o['EmailNotification'] = $this->EmailNotification;
if (isset($this->SMSNotification)) $o['SMSNotification'] = $this->SMSNotification;
if (isset($this->EmailReminder)) $o['EmailReminder'] = $this->EmailReminder;
if (isset($this->SMSReminder)) $o['SMSReminder'] = $this->SMSReminder;
return empty($o) ? new class(){} : $o;
}
}
class CompanyUserRolesQueryResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $RoleId='',
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RoleId'])) $this->RoleId = $o['RoleId'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RoleId)) $o['RoleId'] = $this->RoleId;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
return empty($o) ? new class(){} : $o;
}
}
class CompanyUserQueryResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $Id='',
/** @var string */
public string $CompanyId='',
/** @var string|null */
public ?string $Firstname=null,
/** @var string|null */
public ?string $Lastname=null,
/** @var string|null */
public ?string $Email=null,
/** @var string|null */
public ?string $Phone=null,
/** @var string|null */
public ?string $WorkerId=null,
/** @var int|null */
public ?int $ResourceId=null,
/** @description The resource information connected to the administrator. */
// @ApiMember(Description="The resource information connected to the administrator.")
/** @var CompanyUserResource|null */
public ?CompanyUserResource $Resource=null,
/** @description The roles that are connected to the administrator. */
// @ApiMember(Description="The roles that are connected to the administrator.")
/** @var array<CompanyUserRolesQueryResponse>|null */
public ?array $Roles=null,
/** @var bool|null */
public ?bool $Active=null,
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @var DateTime */
public DateTime $Updated=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Firstname'])) $this->Firstname = $o['Firstname'];
if (isset($o['Lastname'])) $this->Lastname = $o['Lastname'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['Phone'])) $this->Phone = $o['Phone'];
if (isset($o['WorkerId'])) $this->WorkerId = $o['WorkerId'];
if (isset($o['ResourceId'])) $this->ResourceId = $o['ResourceId'];
if (isset($o['Resource'])) $this->Resource = JsonConverters::from('CompanyUserResource', $o['Resource']);
if (isset($o['Roles'])) $this->Roles = JsonConverters::fromArray('CompanyUserRolesQueryResponse', $o['Roles']);
if (isset($o['Active'])) $this->Active = $o['Active'];
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
if (isset($o['Updated'])) $this->Updated = JsonConverters::from('DateTime', $o['Updated']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Firstname)) $o['Firstname'] = $this->Firstname;
if (isset($this->Lastname)) $o['Lastname'] = $this->Lastname;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->Phone)) $o['Phone'] = $this->Phone;
if (isset($this->WorkerId)) $o['WorkerId'] = $this->WorkerId;
if (isset($this->ResourceId)) $o['ResourceId'] = $this->ResourceId;
if (isset($this->Resource)) $o['Resource'] = JsonConverters::to('CompanyUserResource', $this->Resource);
if (isset($this->Roles)) $o['Roles'] = JsonConverters::toArray('CompanyUserRolesQueryResponse', $this->Roles);
if (isset($this->Active)) $o['Active'] = $this->Active;
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
if (isset($this->Updated)) $o['Updated'] = JsonConverters::to('DateTime', $this->Updated);
return empty($o) ? new class(){} : $o;
}
}
class AddCompanyUserRolesResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $RoleId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RoleId'])) $this->RoleId = $o['RoleId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RoleId)) $o['RoleId'] = $this->RoleId;
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="Returned if there is a validation error on the input parameters", StatusCode=400)
// @ApiResponse(Description="Returned if the current user is not allowed to perform the action", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateCompanyUser implements ICompany, JsonSerializable
{
public function __construct(
/** @description Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used. */
// @ApiMember(Description="Enter the company and id for the customer, if blank company id and you are an admin, your company id will be used.", ParameterType="query")
/** @var string|null */
public ?string $CompanyId=null,
// @ApiMember(IsRequired=true)
/** @var string */
public string $Firstname='',
// @ApiMember(IsRequired=true)
/** @var string */
public string $Lastname='',
// @ApiMember(IsRequired=true)
/** @var string */
public string $Phone='',
// @ApiMember(IsRequired=true)
/** @var string */
public string $Email='',
// @ApiMember()
/** @var int|null */
public ?int $ResourceId=null,
// @ApiMember()
/** @var array<AddCompanyUserRolesResponse>|null */
public ?array $Roles=null,
// @ApiMember()
/** @var int|null */
public ?int $WorkerId=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Firstname'])) $this->Firstname = $o['Firstname'];
if (isset($o['Lastname'])) $this->Lastname = $o['Lastname'];
if (isset($o['Phone'])) $this->Phone = $o['Phone'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['ResourceId'])) $this->ResourceId = $o['ResourceId'];
if (isset($o['Roles'])) $this->Roles = JsonConverters::fromArray('AddCompanyUserRolesResponse', $o['Roles']);
if (isset($o['WorkerId'])) $this->WorkerId = $o['WorkerId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Firstname)) $o['Firstname'] = $this->Firstname;
if (isset($this->Lastname)) $o['Lastname'] = $this->Lastname;
if (isset($this->Phone)) $o['Phone'] = $this->Phone;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->ResourceId)) $o['ResourceId'] = $this->ResourceId;
if (isset($this->Roles)) $o['Roles'] = JsonConverters::toArray('AddCompanyUserRolesResponse', $this->Roles);
if (isset($this->WorkerId)) $o['WorkerId'] = $this->WorkerId;
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 /administrators/ HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateCompanyUser 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>
<Email>String</Email>
<Firstname>String</Firstname>
<Lastname>String</Lastname>
<Phone>String</Phone>
<ResourceId>0</ResourceId>
<Roles>
<AddCompanyUserRolesResponse>
<RoleId>00000000-0000-0000-0000-000000000000</RoleId>
</AddCompanyUserRolesResponse>
</Roles>
<WorkerId>0</WorkerId>
</CreateCompanyUser>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CompanyUserQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <Active>false</Active> <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId> <Created>0001-01-01T00:00:00</Created> <Email>String</Email> <Firstname>String</Firstname> <Id>00000000-0000-0000-0000-000000000000</Id> <Lastname>String</Lastname> <Phone>String</Phone> <Resource> <Active>false</Active> <Color>String</Color> <Description>String</Description> <Email>String</Email> <EmailNotification>false</EmailNotification> <EmailReminder>false</EmailReminder> <Id>0</Id> <ImageUrl i:nil="true" /> <Name>String</Name> <Phone>String</Phone> <SMSNotification>false</SMSNotification> <SMSReminder>false</SMSReminder> </Resource> <ResourceId>0</ResourceId> <Roles> <CompanyUserRolesQueryResponse> <Description>String</Description> <Name>String</Name> <RoleId>00000000-0000-0000-0000-000000000000</RoleId> </CompanyUserRolesQueryResponse> </Roles> <Updated>0001-01-01T00:00:00</Updated> <WorkerId>String</WorkerId> </CompanyUserQueryResponse>