<?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};
// @DataContract
class AuditBase implements JsonSerializable
{
public function __construct(
// @DataMember(Order=1)
/** @var DateTime */
public DateTime $createdDate=new DateTime(),
// @DataMember(Order=2)
// @Required()
/** @var string */
public string $createdBy='',
// @DataMember(Order=3)
/** @var DateTime */
public DateTime $modifiedDate=new DateTime(),
// @DataMember(Order=4)
// @Required()
/** @var string */
public string $modifiedBy='',
// @DataMember(Order=5)
/** @var DateTime|null */
public ?DateTime $deletedDate=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $deletedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
if (isset($o['modifiedDate'])) $this->modifiedDate = JsonConverters::from('DateTime', $o['modifiedDate']);
if (isset($o['modifiedBy'])) $this->modifiedBy = $o['modifiedBy'];
if (isset($o['deletedDate'])) $this->deletedDate = JsonConverters::from('DateTime', $o['deletedDate']);
if (isset($o['deletedBy'])) $this->deletedBy = $o['deletedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
if (isset($this->modifiedDate)) $o['modifiedDate'] = JsonConverters::to('DateTime', $this->modifiedDate);
if (isset($this->modifiedBy)) $o['modifiedBy'] = $this->modifiedBy;
if (isset($this->deletedDate)) $o['deletedDate'] = JsonConverters::to('DateTime', $this->deletedDate);
if (isset($this->deletedBy)) $o['deletedBy'] = $this->deletedBy;
return empty($o) ? new class(){} : $o;
}
}
class AppUser implements JsonSerializable
{
public function __construct(
/** @var string */
public string $id='',
/** @var string|null */
public ?string $firstName=null,
/** @var string|null */
public ?string $lastName=null,
/** @var string|null */
public ?string $displayName=null,
/** @var string|null */
public ?string $profileUrl=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['firstName'])) $this->firstName = $o['firstName'];
if (isset($o['lastName'])) $this->lastName = $o['lastName'];
if (isset($o['displayName'])) $this->displayName = $o['displayName'];
if (isset($o['profileUrl'])) $this->profileUrl = $o['profileUrl'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->firstName)) $o['firstName'] = $this->firstName;
if (isset($this->lastName)) $o['lastName'] = $this->lastName;
if (isset($this->displayName)) $o['displayName'] = $this->displayName;
if (isset($this->profileUrl)) $o['profileUrl'] = $this->profileUrl;
return empty($o) ? new class(){} : $o;
}
}
enum JobApplicationStatus : string
{
case Applied = 'Applied';
case PhoneScreening = 'PhoneScreening';
case PhoneScreeningCompleted = 'PhoneScreeningCompleted';
case Interview = 'Interview';
case InterviewCompleted = 'InterviewCompleted';
case Offer = 'Offer';
case Disqualified = 'Disqualified';
}
class PhoneScreen extends AuditBase implements JsonSerializable
{
/**
* @param DateTime $createdDate
* @param string $createdBy
* @param DateTime $modifiedDate
* @param string $modifiedBy
* @param DateTime|null $deletedDate
* @param string|null $deletedBy
*/
public function __construct(
DateTime $createdDate=new DateTime(),
string $createdBy='',
DateTime $modifiedDate=new DateTime(),
string $modifiedBy='',
?DateTime $deletedDate=null,
?string $deletedBy=null,
/** @var int */
public int $id=0,
// @References("typeof(MyApp.ServiceModel.AppUser)")
/** @var string */
public string $appUserId='',
/** @var AppUser|null */
public ?AppUser $appUser=null,
// @References("typeof(MyApp.ServiceModel.JobApplication)")
/** @var int */
public int $jobApplicationId=0,
/** @var JobApplicationStatus|null */
public ?JobApplicationStatus $applicationStatus=null,
/** @var string */
public string $notes=''
) {
parent::__construct($createdDate,$createdBy,$modifiedDate,$modifiedBy,$deletedDate,$deletedBy);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['appUserId'])) $this->appUserId = $o['appUserId'];
if (isset($o['appUser'])) $this->appUser = JsonConverters::from('AppUser', $o['appUser']);
if (isset($o['jobApplicationId'])) $this->jobApplicationId = $o['jobApplicationId'];
if (isset($o['applicationStatus'])) $this->applicationStatus = JsonConverters::from('JobApplicationStatus', $o['applicationStatus']);
if (isset($o['notes'])) $this->notes = $o['notes'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->appUserId)) $o['appUserId'] = $this->appUserId;
if (isset($this->appUser)) $o['appUser'] = JsonConverters::to('AppUser', $this->appUser);
if (isset($this->jobApplicationId)) $o['jobApplicationId'] = $this->jobApplicationId;
if (isset($this->applicationStatus)) $o['applicationStatus'] = JsonConverters::to('JobApplicationStatus', $this->applicationStatus);
if (isset($this->notes)) $o['notes'] = $this->notes;
return empty($o) ? new class(){} : $o;
}
}
// @ValidateRequest(Validator="IsAuthenticated")
/**
* @template ICreateDb of PhoneScreen
*/
class CreatePhoneScreen implements ICreateDb, JsonSerializable
{
public function __construct(
// @Validate(Validator="GreaterThan(0)")
/** @var int */
public int $jobApplicationId=0,
// @Validate(Validator="GreaterThan(0)", Message="An employee to perform the phone screening must be selected.")
/** @var string */
public string $appUserId='',
/** @var JobApplicationStatus|null */
public ?JobApplicationStatus $applicationStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['jobApplicationId'])) $this->jobApplicationId = $o['jobApplicationId'];
if (isset($o['appUserId'])) $this->appUserId = $o['appUserId'];
if (isset($o['applicationStatus'])) $this->applicationStatus = JsonConverters::from('JobApplicationStatus', $o['applicationStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->jobApplicationId)) $o['jobApplicationId'] = $this->jobApplicationId;
if (isset($this->appUserId)) $o['appUserId'] = $this->appUserId;
if (isset($this->applicationStatus)) $o['applicationStatus'] = JsonConverters::to('JobApplicationStatus', $this->applicationStatus);
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 /xml/reply/CreatePhoneScreen HTTP/1.1
Host: blazor-gallery.servicestack.net
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreatePhoneScreen xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel">
<AppUserId>String</AppUserId>
<ApplicationStatus>Applied</ApplicationStatus>
<JobApplicationId>0</JobApplicationId>
</CreatePhoneScreen>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <PhoneScreen xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel"> <CreatedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</CreatedDate> <CreatedBy xmlns="http://schemas.servicestack.net/types">String</CreatedBy> <ModifiedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</ModifiedDate> <ModifiedBy xmlns="http://schemas.servicestack.net/types">String</ModifiedBy> <DeletedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</DeletedDate> <DeletedBy xmlns="http://schemas.servicestack.net/types">String</DeletedBy> <AppUser> <DisplayName>String</DisplayName> <FirstName>String</FirstName> <Id>String</Id> <LastName>String</LastName> <ProfileUrl>String</ProfileUrl> </AppUser> <AppUserId>String</AppUserId> <ApplicationStatus>Applied</ApplicationStatus> <Id>0</Id> <JobApplicationId>0</JobApplicationId> <Notes>String</Notes> </PhoneScreen>