Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
PUT | /resourcetypes/{Id} | Update existing resourcetype | Updates an existing resourcetype if you are authorized to do so. |
---|
<?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 ResourceTypeResource 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 The priority of the resource */
// @ApiMember(Description="The priority of the resource")
/** @var int */
public int $Priority=0,
/** @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['Priority'])) $this->Priority = $o['Priority'];
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->Priority)) $o['Priority'] = $this->Priority;
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 ResourceTypeQueryResponse implements JsonSerializable
{
public function __construct(
/** @description The resourcetype id */
// @ApiMember(Description="The resourcetype id")
/** @var int */
public int $Id=0,
/** @description The resourcetype name */
// @ApiMember(Description="The resourcetype name")
/** @var string|null */
public ?string $Name=null,
/** @description The resourcetype description */
// @ApiMember(Description="The resourcetype description")
/** @var string|null */
public ?string $Description=null,
/** @description The resources in the resourcetype. Only shows active resources if not admin. */
// @ApiMember(Description="The resources in the resourcetype. Only shows active resources if not admin.")
/** @var array<ResourceTypeResource>|null */
public ?array $Resources=null,
/** @description If resourcetype is active or not */
// @ApiMember(Description="If resourcetype is active or not")
/** @var bool|null */
public ?bool $Active=null,
/** @description Then date when the resource was created */
// @ApiMember(Description="Then date when the resource was created")
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @description Then date when the resource was updated */
// @ApiMember(Description="Then date when the resource was updated")
/** @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['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Resources'])) $this->Resources = JsonConverters::fromArray('ResourceTypeResource', $o['Resources']);
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->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Resources)) $o['Resources'] = JsonConverters::toArray('ResourceTypeResource', $this->Resources);
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 UpdateResourceTypeResource implements JsonSerializable
{
public function __construct(
/** @description The resource id */
// @ApiMember(Description="The resource id")
/** @var int */
public int $Id=0,
/** @description The priority of the resource */
// @ApiMember(Description="The priority of the resource")
/** @var int */
public int $Priority=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Priority'])) $this->Priority = $o['Priority'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Priority)) $o['Priority'] = $this->Priority;
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class UpdateResourceType 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 resourcetype */
// @ApiMember(Description="Id of the resourcetype", IsRequired=true, ParameterType="path")
/** @var int */
public int $Id=0,
/** @description The resources to be added */
// @ApiMember(Description="The resources to be added")
/** @var array<UpdateResourceTypeResource>|null */
public ?array $Resources=null,
/** @description The resourcetype name */
// @ApiMember(Description="The resourcetype name")
/** @var string|null */
public ?string $Name=null,
/** @description The resourcetype description */
// @ApiMember(Description="The resourcetype description")
/** @var string|null */
public ?string $Description=null,
/** @description If resourcetype is active or not */
// @ApiMember(Description="If resourcetype is active or not")
/** @var bool|null */
public ?bool $Active=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Resources'])) $this->Resources = JsonConverters::fromArray('UpdateResourceTypeResource', $o['Resources']);
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Active'])) $this->Active = $o['Active'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Resources)) $o['Resources'] = JsonConverters::toArray('UpdateResourceTypeResource', $this->Resources);
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Active)) $o['Active'] = $this->Active;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /resourcetypes/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
CompanyId: 00000000-0000-0000-0000-000000000000,
Id: 0,
Resources:
[
{
Id: 0,
Priority: 0
}
],
Name: String,
Description: String,
Active: False
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { Id: 0, Name: String, Description: String, Resources: [ { Id: 0, Name: String, Active: False, Description: String, Email: String, Phone: String, Color: String, Priority: 0, EmailNotification: False, SMSNotification: False, EmailReminder: False, SMSReminder: False } ], Active: False }