PUT | /rating/ | Update RatingScore | Update rating from booking |
---|
<?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 RatingReviewResponse implements JsonSerializable
{
public function __construct(
/** @description The title for the review */
// @ApiMember(Description="The title for the review")
/** @var string|null */
public ?string $Title=null,
/** @description The description for the review */
// @ApiMember(Description="The description for the review")
/** @var string|null */
public ?string $Description=null,
/** @description The rating score */
// @ApiMember(Description="The rating score")
/** @var int */
public int $RatingScore=0,
/** @description The review author */
// @ApiMember(Description="The review author")
/** @var string|null */
public ?string $Author=null,
/** @description The created date */
// @ApiMember(Description="The created date")
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @description The review answer from the company */
// @ApiMember(Description="The review answer from the company")
/** @var string|null */
public ?string $ReviewAnswer=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Title'])) $this->Title = $o['Title'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['RatingScore'])) $this->RatingScore = $o['RatingScore'];
if (isset($o['Author'])) $this->Author = $o['Author'];
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
if (isset($o['ReviewAnswer'])) $this->ReviewAnswer = $o['ReviewAnswer'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Title)) $o['Title'] = $this->Title;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->RatingScore)) $o['RatingScore'] = $this->RatingScore;
if (isset($this->Author)) $o['Author'] = $this->Author;
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
if (isset($this->ReviewAnswer)) $o['ReviewAnswer'] = $this->ReviewAnswer;
return empty($o) ? new class(){} : $o;
}
}
class CompanyRatingResponse implements JsonSerializable
{
public function __construct(
/** @description */
// @ApiMember(Description="")
/** @var string */
public string $CompanyId='',
/** @description Id of the booking */
// @ApiMember(Description="Id of the booking")
/** @var int */
public int $BookingId=0,
/** @description The status of the rating, 1 = Active */
// @ApiMember(Description="The status of the rating, 1 = Active")
/** @var int */
public int $Status=0,
/** @description The rating score */
// @ApiMember(Description="The rating score")
/** @var int */
public int $RatingScore=0,
/** @description The review if any exists to the rating */
// @ApiMember(Description="The review if any exists to the rating")
/** @var RatingReviewResponse|null */
public ?RatingReviewResponse $Review=null,
/** @var DateTime */
public DateTime $CreatedDate=new DateTime(),
/** @var DateTime */
public DateTime $UpdatedDate=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['RatingScore'])) $this->RatingScore = $o['RatingScore'];
if (isset($o['Review'])) $this->Review = JsonConverters::from('RatingReviewResponse', $o['Review']);
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->RatingScore)) $o['RatingScore'] = $this->RatingScore;
if (isset($this->Review)) $o['Review'] = JsonConverters::to('RatingReviewResponse', $this->Review);
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
return empty($o) ? new class(){} : $o;
}
}
class UpdateReview implements JsonSerializable
{
public function __construct(
/** @description The title for the review */
// @ApiMember(Description="The title for the review")
/** @var string|null */
public ?string $Title=null,
/** @description The description for the review */
// @ApiMember(Description="The description for the review")
/** @var string|null */
public ?string $Description=null,
/** @description The review author */
// @ApiMember(Description="The review author")
/** @var string|null */
public ?string $Author=null,
/** @description The review answer from the company. Only the company can respond to this */
// @ApiMember(Description="The review answer from the company. Only the company can respond to this")
/** @var string|null */
public ?string $ReviewAnswer=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Title'])) $this->Title = $o['Title'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Author'])) $this->Author = $o['Author'];
if (isset($o['ReviewAnswer'])) $this->ReviewAnswer = $o['ReviewAnswer'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Title)) $o['Title'] = $this->Title;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Author)) $o['Author'] = $this->Author;
if (isset($this->ReviewAnswer)) $o['ReviewAnswer'] = $this->ReviewAnswer;
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
class UpdateRating implements JsonSerializable
{
public function __construct(
/** @description */
// @ApiMember(Description="", IsRequired=true)
/** @var string */
public string $CompanyId='',
/** @description Id of the booking */
// @ApiMember(Description="Id of the booking", IsRequired=true)
/** @var int */
public int $BookingId=0,
/** @description The identifier for the booking, use to verify the booking. Only needed when a customer, not admin */
// @ApiMember(Description="The identifier for the booking, use to verify the booking. Only needed when a customer, not admin")
/** @var string|null */
public ?string $Identifier=null,
/** @description The rating score between 1 and 5. */
// @ApiMember(Description="The rating score between 1 and 5.")
/** @var int|null */
public ?int $RatingScore=null,
/** @description The review for the rating */
// @ApiMember(Description="The review for the rating")
/** @var UpdateReview|null */
public ?UpdateReview $Review=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
if (isset($o['Identifier'])) $this->Identifier = $o['Identifier'];
if (isset($o['RatingScore'])) $this->RatingScore = $o['RatingScore'];
if (isset($o['Review'])) $this->Review = JsonConverters::from('UpdateReview', $o['Review']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
if (isset($this->Identifier)) $o['Identifier'] = $this->Identifier;
if (isset($this->RatingScore)) $o['RatingScore'] = $this->RatingScore;
if (isset($this->Review)) $o['Review'] = JsonConverters::to('UpdateReview', $this->Review);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /rating/ HTTP/1.1
Host: api.bokamera.se
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","BookingId":0,"Identifier":"String","RatingScore":0,"Review":{"Title":"String","Description":"String","Author":"String","ReviewAnswer":"String"}}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"BookingId":0,"Status":0,"RatingScore":0,"Review":{"Title":"String","Description":"String","RatingScore":0,"Author":"String","ReviewAnswer":"String"}}