| PUT,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 UpdateRoleRequest implements JsonSerializable
{
public function __construct(
/** @var int */
public int $RoleId=0,
/** @var string|null */
public ?string $Code=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=null,
/** @var array<int>|null */
public ?array $PermissionIds=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RoleId'])) $this->RoleId = $o['RoleId'];
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['PermissionIds'])) $this->PermissionIds = JsonConverters::fromArray('int', $o['PermissionIds']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RoleId)) $o['RoleId'] = $this->RoleId;
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->PermissionIds)) $o['PermissionIds'] = JsonConverters::toArray('int', $this->PermissionIds);
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.
PUT /v1/Roles/{RoleId} HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UpdateRoleRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<Code>String</Code>
<Description>String</Description>
<Name>String</Name>
<PermissionIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</PermissionIds>
<RoleId>0</RoleId>
</UpdateRoleRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<Role xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal.Models">
<Code>String</Code>
<CreatedUtc>0001-01-01T00:00:00</CreatedUtc>
<Description>String</Description>
<IsActive>false</IsActive>
<IsSystem>false</IsSystem>
<Name>String</Name>
<Permissions>
<Permission>
<Action>String</Action>
<Code>String</Code>
<CreatedUtc>0001-01-01T00:00:00</CreatedUtc>
<Description>String</Description>
<IsActive>false</IsActive>
<Module>String</Module>
<Name>String</Name>
<PermissionId>0</PermissionId>
<Resource>String</Resource>
<SortOrder>0</SortOrder>
<Tags>String</Tags>
</Permission>
</Permissions>
<RoleId>0</RoleId>
<TenantId>00000000-0000-0000-0000-000000000000</TenantId>
</Role>