Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
PUT | /services/prices/{Id} | Update a price | Update a price on a service |
---|
<?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 DayOfWeekDto implements JsonSerializable
{
public function __construct(
/** @var int */
public int $DayOfWeekId=0,
/** @var int */
public int $DotNetDayOfWeekId=0,
/** @var string|null */
public ?string $DayOfWeek=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['DayOfWeekId'])) $this->DayOfWeekId = $o['DayOfWeekId'];
if (isset($o['DotNetDayOfWeekId'])) $this->DotNetDayOfWeekId = $o['DotNetDayOfWeekId'];
if (isset($o['DayOfWeek'])) $this->DayOfWeek = $o['DayOfWeek'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->DayOfWeekId)) $o['DayOfWeekId'] = $this->DayOfWeekId;
if (isset($this->DotNetDayOfWeekId)) $o['DotNetDayOfWeekId'] = $this->DotNetDayOfWeekId;
if (isset($this->DayOfWeek)) $o['DayOfWeek'] = $this->DayOfWeek;
return empty($o) ? new class(){} : $o;
}
}
class GroupBookingSettings implements JsonSerializable
{
public function __construct(
/** @var bool|null */
public ?bool $Active=null,
/** @var int */
public int $Min=0,
/** @var int */
public int $Max=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Active'])) $this->Active = $o['Active'];
if (isset($o['Min'])) $this->Min = $o['Min'];
if (isset($o['Max'])) $this->Max = $o['Max'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Active)) $o['Active'] = $this->Active;
if (isset($this->Min)) $o['Min'] = $this->Min;
if (isset($this->Max)) $o['Max'] = $this->Max;
return empty($o) ? new class(){} : $o;
}
}
class MultipleResourceSettings implements JsonSerializable
{
public function __construct(
/** @var bool|null */
public ?bool $Active=null,
/** @var int */
public int $Min=0,
/** @var int */
public int $Max=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Active'])) $this->Active = $o['Active'];
if (isset($o['Min'])) $this->Min = $o['Min'];
if (isset($o['Max'])) $this->Max = $o['Max'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Active)) $o['Active'] = $this->Active;
if (isset($this->Min)) $o['Min'] = $this->Min;
if (isset($this->Max)) $o['Max'] = $this->Max;
return empty($o) ? new class(){} : $o;
}
}
class ServiceInfoResponse implements JsonSerializable
{
public function __construct(
/** @var int */
public int $Id=0,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=null,
/** @var string|null */
public ?string $ImageUrl=null,
/** @var int|null */
public ?int $LengthInMinutes=null,
/** @var int */
public int $MaxNumberOfSpotsPerBooking=0,
/** @var int */
public int $MinNumberOfSpotsPerBooking=0,
/** @var GroupBookingSettings|null */
public ?GroupBookingSettings $GroupBooking=null,
/** @var MultipleResourceSettings|null */
public ?MultipleResourceSettings $MultipleResource=null,
/** @var bool|null */
public ?bool $IsGroupBooking=null,
/** @var bool|null */
public ?bool $IsPaymentEnabled=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['Description'])) $this->Description = $o['Description'];
if (isset($o['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
if (isset($o['LengthInMinutes'])) $this->LengthInMinutes = $o['LengthInMinutes'];
if (isset($o['MaxNumberOfSpotsPerBooking'])) $this->MaxNumberOfSpotsPerBooking = $o['MaxNumberOfSpotsPerBooking'];
if (isset($o['MinNumberOfSpotsPerBooking'])) $this->MinNumberOfSpotsPerBooking = $o['MinNumberOfSpotsPerBooking'];
if (isset($o['GroupBooking'])) $this->GroupBooking = JsonConverters::from('GroupBookingSettings', $o['GroupBooking']);
if (isset($o['MultipleResource'])) $this->MultipleResource = JsonConverters::from('MultipleResourceSettings', $o['MultipleResource']);
if (isset($o['IsGroupBooking'])) $this->IsGroupBooking = $o['IsGroupBooking'];
if (isset($o['IsPaymentEnabled'])) $this->IsPaymentEnabled = $o['IsPaymentEnabled'];
}
/** @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->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
if (isset($this->LengthInMinutes)) $o['LengthInMinutes'] = $this->LengthInMinutes;
if (isset($this->MaxNumberOfSpotsPerBooking)) $o['MaxNumberOfSpotsPerBooking'] = $this->MaxNumberOfSpotsPerBooking;
if (isset($this->MinNumberOfSpotsPerBooking)) $o['MinNumberOfSpotsPerBooking'] = $this->MinNumberOfSpotsPerBooking;
if (isset($this->GroupBooking)) $o['GroupBooking'] = JsonConverters::to('GroupBookingSettings', $this->GroupBooking);
if (isset($this->MultipleResource)) $o['MultipleResource'] = JsonConverters::to('MultipleResourceSettings', $this->MultipleResource);
if (isset($this->IsGroupBooking)) $o['IsGroupBooking'] = $this->IsGroupBooking;
if (isset($this->IsPaymentEnabled)) $o['IsPaymentEnabled'] = $this->IsPaymentEnabled;
return empty($o) ? new class(){} : $o;
}
}
class ServicePriceResponse implements JsonSerializable
{
public function __construct(
/** @description The company id */
// @ApiMember(Description="The company id")
/** @var string */
public string $CompanyId='',
/** @description The price id */
// @ApiMember(Description="The price id")
/** @var int */
public int $Id=0,
/** @description The service id */
// @ApiMember(Description="The service id")
/** @var int */
public int $ServiceId=0,
/** @description The price */
// @ApiMember(Description="The price")
/** @var float */
public float $Price=0.0,
/** @description The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day */
// @ApiMember(Description="The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day")
/** @var int */
public int $CalculationTypeId=0,
/** @description The price currency */
// @ApiMember(Description="The price currency")
/** @var string|null */
public ?string $CurrencyId=null,
/** @description The price sign */
// @ApiMember(Description="The price sign")
/** @var string|null */
public ?string $PriceSign=null,
/** @description The price VAT in percent */
// @ApiMember(Description="The price VAT in percent")
/** @var float */
public float $VAT=0.0,
/** @description The price category if price has a category */
// @ApiMember(Description="The price category if price has a category")
/** @var string|null */
public ?string $Category=null,
/** @description The price text to display */
// @ApiMember(Description="The price text to display")
/** @var string|null */
public ?string $PriceText=null,
/** @description The valid from date for the price. */
// @ApiMember(Description="The valid from date for the price.")
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description The valid to date for the price. */
// @ApiMember(Description="The valid to date for the price.")
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update. */
// @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
/** @var array<DayOfWeekDto>|null */
public ?array $DaysOfWeek=null,
/** @description If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update. */
// @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
/** @var DateInterval|null */
public ?DateInterval $FromTime=null,
/** @description If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters. */
// @ApiMember(Description="If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.")
/** @var DateInterval|null */
public ?DateInterval $ToTime=null,
/** @var ServiceInfoResponse|null */
public ?ServiceInfoResponse $Service=null,
/** @description If the price is only valid for a specific time span */
// @ApiMember(Description="If the price is only valid for a specific time span")
/** @var bool|null */
public ?bool $IsTimeSpecific=null,
/** @description If the price is only valid for specific days of week */
// @ApiMember(Description="If the price is only valid for specific days of week")
/** @var bool|null */
public ?bool $IsDaysOfWeekSpecific=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['ServiceId'])) $this->ServiceId = $o['ServiceId'];
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['CalculationTypeId'])) $this->CalculationTypeId = $o['CalculationTypeId'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['PriceSign'])) $this->PriceSign = $o['PriceSign'];
if (isset($o['VAT'])) $this->VAT = $o['VAT'];
if (isset($o['Category'])) $this->Category = $o['Category'];
if (isset($o['PriceText'])) $this->PriceText = $o['PriceText'];
if (isset($o['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
if (isset($o['DaysOfWeek'])) $this->DaysOfWeek = JsonConverters::fromArray('DayOfWeekDto', $o['DaysOfWeek']);
if (isset($o['FromTime'])) $this->FromTime = JsonConverters::from('TimeSpan', $o['FromTime']);
if (isset($o['ToTime'])) $this->ToTime = JsonConverters::from('TimeSpan', $o['ToTime']);
if (isset($o['Service'])) $this->Service = JsonConverters::from('ServiceInfoResponse', $o['Service']);
if (isset($o['IsTimeSpecific'])) $this->IsTimeSpecific = $o['IsTimeSpecific'];
if (isset($o['IsDaysOfWeekSpecific'])) $this->IsDaysOfWeekSpecific = $o['IsDaysOfWeekSpecific'];
}
/** @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->ServiceId)) $o['ServiceId'] = $this->ServiceId;
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->CalculationTypeId)) $o['CalculationTypeId'] = $this->CalculationTypeId;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->PriceSign)) $o['PriceSign'] = $this->PriceSign;
if (isset($this->VAT)) $o['VAT'] = $this->VAT;
if (isset($this->Category)) $o['Category'] = $this->Category;
if (isset($this->PriceText)) $o['PriceText'] = $this->PriceText;
if (isset($this->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
if (isset($this->DaysOfWeek)) $o['DaysOfWeek'] = JsonConverters::toArray('DayOfWeekDto', $this->DaysOfWeek);
if (isset($this->FromTime)) $o['FromTime'] = JsonConverters::to('TimeSpan', $this->FromTime);
if (isset($this->ToTime)) $o['ToTime'] = JsonConverters::to('TimeSpan', $this->ToTime);
if (isset($this->Service)) $o['Service'] = JsonConverters::to('ServiceInfoResponse', $this->Service);
if (isset($this->IsTimeSpecific)) $o['IsTimeSpecific'] = $this->IsTimeSpecific;
if (isset($this->IsDaysOfWeekSpecific)) $o['IsDaysOfWeekSpecific'] = $this->IsDaysOfWeekSpecific;
return empty($o) ? new class(){} : $o;
}
}
// @ValidateRequest(Validator="IsAuthenticated")
class UpdateServicePrice 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 price */
// @ApiMember(Description="Id of the price", IsRequired=true, ParameterType="path")
/** @var int */
public int $Id=0,
/** @description The price */
// @ApiMember(Description="The price")
/** @var float */
public float $Price=0.0,
/** @description The price currency */
// @ApiMember(Description="The price currency")
/** @var string|null */
public ?string $CurrencyId=null,
/** @description The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day */
// @ApiMember(Description="The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day")
/** @var int */
public int $CalculationTypeId=0,
/** @description The price VAT in percent */
// @ApiMember(Description="The price VAT in percent")
/** @var float */
public float $VAT=0.0,
/** @description The price category if price has a category */
// @ApiMember(Description="The price category if price has a category")
/** @var string|null */
public ?string $Category=null,
/** @description The valid from date for the price. */
// @ApiMember(Description="The valid from date for the price.")
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description The valid to date for the price. */
// @ApiMember(Description="The valid to date for the price.")
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update. */
// @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
/** @var int[]|null */
public ?array $DaysOfWeek=null,
/** @description If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update. */
// @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
/** @var DateInterval|null */
public ?DateInterval $FromTime=null,
/** @description If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters. */
// @ApiMember(Description="If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.")
/** @var DateInterval|null */
public ?DateInterval $ToTime=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['Price'])) $this->Price = $o['Price'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['CalculationTypeId'])) $this->CalculationTypeId = $o['CalculationTypeId'];
if (isset($o['VAT'])) $this->VAT = $o['VAT'];
if (isset($o['Category'])) $this->Category = $o['Category'];
if (isset($o['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
if (isset($o['DaysOfWeek'])) $this->DaysOfWeek = JsonConverters::fromArray('int', $o['DaysOfWeek']);
if (isset($o['FromTime'])) $this->FromTime = JsonConverters::from('TimeSpan', $o['FromTime']);
if (isset($o['ToTime'])) $this->ToTime = JsonConverters::from('TimeSpan', $o['ToTime']);
}
/** @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->Price)) $o['Price'] = $this->Price;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->CalculationTypeId)) $o['CalculationTypeId'] = $this->CalculationTypeId;
if (isset($this->VAT)) $o['VAT'] = $this->VAT;
if (isset($this->Category)) $o['Category'] = $this->Category;
if (isset($this->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
if (isset($this->DaysOfWeek)) $o['DaysOfWeek'] = JsonConverters::toArray('int', $this->DaysOfWeek);
if (isset($this->FromTime)) $o['FromTime'] = JsonConverters::to('TimeSpan', $this->FromTime);
if (isset($this->ToTime)) $o['ToTime'] = JsonConverters::to('TimeSpan', $this->ToTime);
return empty($o) ? new class(){} : $o;
}
}
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
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /services/prices/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: application/json
Content-Type: application/json
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","Id":0,"Price":0,"CurrencyId":"String","CalculationTypeId":0,"VAT":0,"Category":"String","DaysOfWeek":[0],"FromTime":"00:00:00","ToTime":"00:00:00"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"Id":0,"ServiceId":0,"Price":0,"CalculationTypeId":0,"CurrencyId":"String","PriceSign":"String","VAT":0,"Category":"String","PriceText":"String","DaysOfWeek":[{"DayOfWeekId":0,"DotNetDayOfWeekId":0,"DayOfWeek":"String"}],"FromTime":"00:00:00","ToTime":"00:00:00","Service":{"Id":0,"Name":"String","Description":"String","LengthInMinutes":0,"MaxNumberOfSpotsPerBooking":0,"MinNumberOfSpotsPerBooking":0,"GroupBooking":{"Active":false,"Min":0,"Max":0},"MultipleResource":{"Active":false,"Min":0,"Max":0},"IsGroupBooking":false,"IsPaymentEnabled":false},"IsTimeSpecific":false,"IsDaysOfWeekSpecific":false}