Required role: | Admin |
<?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 ArtifactComment 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,
/** @var int */
public int $artifactId=0,
/** @var int|null */
public ?int $replyId=null,
/** @var string */
public string $content='',
/** @var int */
public int $upVotes=0,
/** @var int */
public int $downVotes=0,
/** @var int */
public int $votes=0,
/** @var string|null */
public ?string $flagReason=null,
/** @var string|null */
public ?string $notes=null,
/** @var string */
public string $refId='',
/** @var int */
public int $appUserId=0
) {
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['artifactId'])) $this->artifactId = $o['artifactId'];
if (isset($o['replyId'])) $this->replyId = $o['replyId'];
if (isset($o['content'])) $this->content = $o['content'];
if (isset($o['upVotes'])) $this->upVotes = $o['upVotes'];
if (isset($o['downVotes'])) $this->downVotes = $o['downVotes'];
if (isset($o['votes'])) $this->votes = $o['votes'];
if (isset($o['flagReason'])) $this->flagReason = $o['flagReason'];
if (isset($o['notes'])) $this->notes = $o['notes'];
if (isset($o['refId'])) $this->refId = $o['refId'];
if (isset($o['appUserId'])) $this->appUserId = $o['appUserId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->artifactId)) $o['artifactId'] = $this->artifactId;
if (isset($this->replyId)) $o['replyId'] = $this->replyId;
if (isset($this->content)) $o['content'] = $this->content;
if (isset($this->upVotes)) $o['upVotes'] = $this->upVotes;
if (isset($this->downVotes)) $o['downVotes'] = $this->downVotes;
if (isset($this->votes)) $o['votes'] = $this->votes;
if (isset($this->flagReason)) $o['flagReason'] = $this->flagReason;
if (isset($this->notes)) $o['notes'] = $this->notes;
if (isset($this->refId)) $o['refId'] = $this->refId;
if (isset($this->appUserId)) $o['appUserId'] = $this->appUserId;
return empty($o) ? new class(){} : $o;
}
}
// @ValidateRequest(Validator="IsAdmin")
/**
* @template IPatchDb of ArtifactComment
*/
class AdminUpdateArtifactComment implements IPatchDb, JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var int|null */
public ?int $replyId=null,
// @Validate(Validator="Length(1,280)")
/** @var string|null */
public ?string $content=null,
/** @var string|null */
public ?string $notes=null,
/** @var string|null */
public ?string $flagReason=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['replyId'])) $this->replyId = $o['replyId'];
if (isset($o['content'])) $this->content = $o['content'];
if (isset($o['notes'])) $this->notes = $o['notes'];
if (isset($o['flagReason'])) $this->flagReason = $o['flagReason'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->replyId)) $o['replyId'] = $this->replyId;
if (isset($this->content)) $o['content'] = $this->content;
if (isset($this->notes)) $o['notes'] = $this->notes;
if (isset($this->flagReason)) $o['flagReason'] = $this->flagReason;
return empty($o) ? new class(){} : $o;
}
}
PHP AdminUpdateArtifactComment DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/reply/AdminUpdateArtifactComment HTTP/1.1
Host: blazordiffusion.com
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"id":0,"replyId":0,"content":"String","notes":"String","flagReason":"String"}
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"id":0,"artifactId":0,"replyId":0,"content":"String","upVotes":0,"downVotes":0,"votes":0,"flagReason":"String","notes":"String","refId":"String","appUserId":0,"createdDate":"0001-01-01T00:00:00","createdBy":"String","modifiedDate":"0001-01-01T00:00:00","modifiedBy":"String","deletedDate":"0001-01-01T00:00:00","deletedBy":"String"}