| GET,OPTIONS | /v1/Roles/{RoleId} |
|---|
<?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 Permission implements JsonSerializable
{
public function __construct(
/** @var int */
public int $PermissionId=0,
/** @var string|null */
public ?string $Module=null,
/** @var string|null */
public ?string $Resource=null,
/** @var string|null */
public ?string $Action=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=null,
/** @var string|null */
public ?string $Tags=null,
/** @var int */
public int $SortOrder=0,
/** @var bool|null */
public ?bool $IsActive=null,
/** @var DateTime */
public DateTime $CreatedUtc=new DateTime(),
/** @var string|null */
public ?string $Code=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['PermissionId'])) $this->PermissionId = $o['PermissionId'];
if (isset($o['Module'])) $this->Module = $o['Module'];
if (isset($o['Resource'])) $this->Resource = $o['Resource'];
if (isset($o['Action'])) $this->Action = $o['Action'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Tags'])) $this->Tags = $o['Tags'];
if (isset($o['SortOrder'])) $this->SortOrder = $o['SortOrder'];
if (isset($o['IsActive'])) $this->IsActive = $o['IsActive'];
if (isset($o['CreatedUtc'])) $this->CreatedUtc = JsonConverters::from('DateTime', $o['CreatedUtc']);
if (isset($o['Code'])) $this->Code = $o['Code'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->PermissionId)) $o['PermissionId'] = $this->PermissionId;
if (isset($this->Module)) $o['Module'] = $this->Module;
if (isset($this->Resource)) $o['Resource'] = $this->Resource;
if (isset($this->Action)) $o['Action'] = $this->Action;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Tags)) $o['Tags'] = $this->Tags;
if (isset($this->SortOrder)) $o['SortOrder'] = $this->SortOrder;
if (isset($this->IsActive)) $o['IsActive'] = $this->IsActive;
if (isset($this->CreatedUtc)) $o['CreatedUtc'] = JsonConverters::to('DateTime', $this->CreatedUtc);
if (isset($this->Code)) $o['Code'] = $this->Code;
return empty($o) ? new class(){} : $o;
}
}
class Role implements JsonSerializable
{
public function __construct(
/** @var int */
public int $RoleId=0,
/** @var string */
public string $TenantId='',
/** @var string|null */
public ?string $Code=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=null,
/** @var bool|null */
public ?bool $IsSystem=null,
/** @var bool|null */
public ?bool $IsActive=null,
/** @var DateTime */
public DateTime $CreatedUtc=new DateTime(),
/** @var array<Permission>|null */
public ?array $Permissions=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RoleId'])) $this->RoleId = $o['RoleId'];
if (isset($o['TenantId'])) $this->TenantId = $o['TenantId'];
if (isset($o['Code'])) $this->Code = $o['Code'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['IsSystem'])) $this->IsSystem = $o['IsSystem'];
if (isset($o['IsActive'])) $this->IsActive = $o['IsActive'];
if (isset($o['CreatedUtc'])) $this->CreatedUtc = JsonConverters::from('DateTime', $o['CreatedUtc']);
if (isset($o['Permissions'])) $this->Permissions = JsonConverters::fromArray('Permission', $o['Permissions']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RoleId)) $o['RoleId'] = $this->RoleId;
if (isset($this->TenantId)) $o['TenantId'] = $this->TenantId;
if (isset($this->Code)) $o['Code'] = $this->Code;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->IsSystem)) $o['IsSystem'] = $this->IsSystem;
if (isset($this->IsActive)) $o['IsActive'] = $this->IsActive;
if (isset($this->CreatedUtc)) $o['CreatedUtc'] = JsonConverters::to('DateTime', $this->CreatedUtc);
if (isset($this->Permissions)) $o['Permissions'] = JsonConverters::toArray('Permission', $this->Permissions);
return empty($o) ? new class(){} : $o;
}
}
class GetRoleByIdRequest implements JsonSerializable
{
public function __construct(
/** @var int */
public int $RoleId=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RoleId'])) $this->RoleId = $o['RoleId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RoleId)) $o['RoleId'] = $this->RoleId;
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.
GET /v1/Roles/{RoleId} HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
RoleId: 0,
TenantId: 00000000000000000000000000000000,
Code: String,
Name: String,
Description: String,
IsSystem: False,
IsActive: False,
CreatedUtc: 0001-01-01,
Permissions:
[
{
PermissionId: 0,
Module: String,
Resource: String,
Action: String,
Name: String,
Description: String,
Tags: String,
SortOrder: 0,
IsActive: False,
CreatedUtc: 0001-01-01,
Code: String
}
]
}