Trendsic Platform Service

<back to all web services

GetUsersByRoleId

Requires Authentication
The following routes are available for this service:
GET/v1/roles/{RoleId}/users
<?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 UserSummary implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $UserId='',
        /** @var string|null */
        public ?string $UserName=null,
        /** @var string|null */
        public ?string $Email=null,
        /** @var DateTime|null */
        public ?DateTime $CreatedUtc=null,
        /** @var DateTime|null */
        public ?DateTime $LastActivityUtc=null,
        /** @var string|null */
        public ?string $FirstName=null,
        /** @var string|null */
        public ?string $LastName=null,
        /** @var string|null */
        public ?string $DisplayName=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['UserId'])) $this->UserId = $o['UserId'];
        if (isset($o['UserName'])) $this->UserName = $o['UserName'];
        if (isset($o['Email'])) $this->Email = $o['Email'];
        if (isset($o['CreatedUtc'])) $this->CreatedUtc = JsonConverters::from('DateTime', $o['CreatedUtc']);
        if (isset($o['LastActivityUtc'])) $this->LastActivityUtc = JsonConverters::from('DateTime', $o['LastActivityUtc']);
        if (isset($o['FirstName'])) $this->FirstName = $o['FirstName'];
        if (isset($o['LastName'])) $this->LastName = $o['LastName'];
        if (isset($o['DisplayName'])) $this->DisplayName = $o['DisplayName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->UserId)) $o['UserId'] = $this->UserId;
        if (isset($this->UserName)) $o['UserName'] = $this->UserName;
        if (isset($this->Email)) $o['Email'] = $this->Email;
        if (isset($this->CreatedUtc)) $o['CreatedUtc'] = JsonConverters::to('DateTime', $this->CreatedUtc);
        if (isset($this->LastActivityUtc)) $o['LastActivityUtc'] = JsonConverters::to('DateTime', $this->LastActivityUtc);
        if (isset($this->FirstName)) $o['FirstName'] = $this->FirstName;
        if (isset($this->LastName)) $o['LastName'] = $this->LastName;
        if (isset($this->DisplayName)) $o['DisplayName'] = $this->DisplayName;
        return empty($o) ? new class(){} : $o;
    }
}

class GetUsersByRoleIdResponse implements JsonSerializable
{
    public function __construct(
        /** @var array<UserSummary>|null */
        public ?array $Users=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Users'])) $this->Users = JsonConverters::fromArray('UserSummary', $o['Users']);
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Users)) $o['Users'] = JsonConverters::toArray('UserSummary', $this->Users);
        if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

class GetUsersByRoleId 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;
    }
}

PHP GetUsersByRoleId DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /v1/roles/{RoleId}/users HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Users":[{"UserId":"00000000000000000000000000000000","UserName":"String","Email":"String","CreatedUtc":"0001-01-01T00:00:00.0000000","LastActivityUtc":"0001-01-01T00:00:00.0000000","FirstName":"String","LastName":"String","DisplayName":"String String"}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}