Trendsic Platform Service

<back to all web services

ChatRequest

Requires Authentication
Requires any of the roles:Agent, Administrator, Agent, Administrator, Agent, Administrator
The following routes are available for this service:
PUT,OPTIONS/v1/Chat/{ChatId}
GET,POST,OPTIONS/v1/Chat
<?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 ChatMember implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $ChatMemberId='',
        /** @var string */
        public string $ChatId='',
        /** @var string */
        public string $UserId='',
        /** @var bool|null */
        public ?bool $IsActive=null,
        /** @var bool|null */
        public ?bool $IsArchived=null,
        /** @var string */
        public string $LastChatMessageId='',
        /** @var string|null */
        public ?string $ChatMemberName=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ChatMemberId'])) $this->ChatMemberId = $o['ChatMemberId'];
        if (isset($o['ChatId'])) $this->ChatId = $o['ChatId'];
        if (isset($o['UserId'])) $this->UserId = $o['UserId'];
        if (isset($o['IsActive'])) $this->IsActive = $o['IsActive'];
        if (isset($o['IsArchived'])) $this->IsArchived = $o['IsArchived'];
        if (isset($o['LastChatMessageId'])) $this->LastChatMessageId = $o['LastChatMessageId'];
        if (isset($o['ChatMemberName'])) $this->ChatMemberName = $o['ChatMemberName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ChatMemberId)) $o['ChatMemberId'] = $this->ChatMemberId;
        if (isset($this->ChatId)) $o['ChatId'] = $this->ChatId;
        if (isset($this->UserId)) $o['UserId'] = $this->UserId;
        if (isset($this->IsActive)) $o['IsActive'] = $this->IsActive;
        if (isset($this->IsArchived)) $o['IsArchived'] = $this->IsArchived;
        if (isset($this->LastChatMessageId)) $o['LastChatMessageId'] = $this->LastChatMessageId;
        if (isset($this->ChatMemberName)) $o['ChatMemberName'] = $this->ChatMemberName;
        return empty($o) ? new class(){} : $o;
    }
}

class Chat implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $ChatId='',
        /** @var string|null */
        public ?string $ChatName=null,
        /** @var string */
        public string $CreatedBy='',
        /** @var DateTime */
        public DateTime $DateCreated=new DateTime(),
        /** @var array<ChatMember>|null */
        public ?array $ChatMembers=null,
        /** @var bool|null */
        public ?bool $IsArchived=null,
        /** @var int */
        public int $MemberCount=0,
        /** @var int */
        public int $MessageCount=0,
        /** @var int */
        public int $UnreadCount=0,
        /** @var string|null */
        public ?string $CreatedByName=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ChatId'])) $this->ChatId = $o['ChatId'];
        if (isset($o['ChatName'])) $this->ChatName = $o['ChatName'];
        if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
        if (isset($o['DateCreated'])) $this->DateCreated = JsonConverters::from('DateTime', $o['DateCreated']);
        if (isset($o['ChatMembers'])) $this->ChatMembers = JsonConverters::fromArray('ChatMember', $o['ChatMembers']);
        if (isset($o['IsArchived'])) $this->IsArchived = $o['IsArchived'];
        if (isset($o['MemberCount'])) $this->MemberCount = $o['MemberCount'];
        if (isset($o['MessageCount'])) $this->MessageCount = $o['MessageCount'];
        if (isset($o['UnreadCount'])) $this->UnreadCount = $o['UnreadCount'];
        if (isset($o['CreatedByName'])) $this->CreatedByName = $o['CreatedByName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ChatId)) $o['ChatId'] = $this->ChatId;
        if (isset($this->ChatName)) $o['ChatName'] = $this->ChatName;
        if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
        if (isset($this->DateCreated)) $o['DateCreated'] = JsonConverters::to('DateTime', $this->DateCreated);
        if (isset($this->ChatMembers)) $o['ChatMembers'] = JsonConverters::toArray('ChatMember', $this->ChatMembers);
        if (isset($this->IsArchived)) $o['IsArchived'] = $this->IsArchived;
        if (isset($this->MemberCount)) $o['MemberCount'] = $this->MemberCount;
        if (isset($this->MessageCount)) $o['MessageCount'] = $this->MessageCount;
        if (isset($this->UnreadCount)) $o['UnreadCount'] = $this->UnreadCount;
        if (isset($this->CreatedByName)) $o['CreatedByName'] = $this->CreatedByName;
        return empty($o) ? new class(){} : $o;
    }
}

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

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

class ChatRequest implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $ChatId='',
        /** @var Chat|null */
        public ?Chat $Chat=null
    ) {
    }

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

PHP ChatRequest DTOs

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

HTTP + JSV

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

POST /v1/Chat HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	ChatId: 00000000000000000000000000000000,
	Chat: 
	{
		ChatId: 00000000000000000000000000000000,
		ChatName: String,
		CreatedBy: 00000000000000000000000000000000,
		DateCreated: 0001-01-01,
		ChatMembers: 
		[
			{
				ChatMemberId: 00000000000000000000000000000000,
				ChatId: 00000000000000000000000000000000,
				UserId: 00000000000000000000000000000000,
				IsActive: False,
				IsArchived: False,
				LastChatMessageId: 00000000000000000000000000000000,
				ChatMemberName: String
			}
		],
		IsArchived: False,
		MemberCount: 0,
		MessageCount: 0,
		UnreadCount: 0,
		CreatedByName: String
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	},
	Chat: 
	[
		{
			ChatId: 00000000000000000000000000000000,
			ChatName: String,
			CreatedBy: 00000000000000000000000000000000,
			DateCreated: 0001-01-01,
			ChatMembers: 
			[
				{
					ChatMemberId: 00000000000000000000000000000000,
					ChatId: 00000000000000000000000000000000,
					UserId: 00000000000000000000000000000000,
					IsActive: False,
					IsArchived: False,
					LastChatMessageId: 00000000000000000000000000000000,
					ChatMemberName: String
				}
			],
			IsArchived: False,
			MemberCount: 0,
			MessageCount: 0,
			UnreadCount: 0,
			CreatedByName: String
		}
	]
}