All Verbs | /user/organizations |
---|
<?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 OrganizationMember implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var int */
public int $organizationId=0,
/** @var int */
public int $userId=0,
/** @var string|null */
public ?string $userName=null,
/** @var bool|null */
public ?bool $isOwner=null,
/** @var bool|null */
public ?bool $isModerator=null,
/** @var bool|null */
public ?bool $denyAll=null,
/** @var bool|null */
public ?bool $denyPosts=null,
/** @var bool|null */
public ?bool $denyComments=null,
/** @var string|null */
public ?string $notes=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['organizationId'])) $this->organizationId = $o['organizationId'];
if (isset($o['userId'])) $this->userId = $o['userId'];
if (isset($o['userName'])) $this->userName = $o['userName'];
if (isset($o['isOwner'])) $this->isOwner = $o['isOwner'];
if (isset($o['isModerator'])) $this->isModerator = $o['isModerator'];
if (isset($o['denyAll'])) $this->denyAll = $o['denyAll'];
if (isset($o['denyPosts'])) $this->denyPosts = $o['denyPosts'];
if (isset($o['denyComments'])) $this->denyComments = $o['denyComments'];
if (isset($o['notes'])) $this->notes = $o['notes'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->organizationId)) $o['organizationId'] = $this->organizationId;
if (isset($this->userId)) $o['userId'] = $this->userId;
if (isset($this->userName)) $o['userName'] = $this->userName;
if (isset($this->isOwner)) $o['isOwner'] = $this->isOwner;
if (isset($this->isModerator)) $o['isModerator'] = $this->isModerator;
if (isset($this->denyAll)) $o['denyAll'] = $this->denyAll;
if (isset($this->denyPosts)) $o['denyPosts'] = $this->denyPosts;
if (isset($this->denyComments)) $o['denyComments'] = $this->denyComments;
if (isset($this->notes)) $o['notes'] = $this->notes;
return empty($o) ? new class(){} : $o;
}
}
class OrganizationMemberInvite implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var int */
public int $organizationId=0,
/** @var int */
public int $userId=0,
/** @var string|null */
public ?string $userName=null,
/** @var DateTime|null */
public ?DateTime $dismissed=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['organizationId'])) $this->organizationId = $o['organizationId'];
if (isset($o['userId'])) $this->userId = $o['userId'];
if (isset($o['userName'])) $this->userName = $o['userName'];
if (isset($o['dismissed'])) $this->dismissed = JsonConverters::from('DateTime', $o['dismissed']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->organizationId)) $o['organizationId'] = $this->organizationId;
if (isset($this->userId)) $o['userId'] = $this->userId;
if (isset($this->userName)) $o['userName'] = $this->userName;
if (isset($this->dismissed)) $o['dismissed'] = JsonConverters::to('DateTime', $this->dismissed);
return empty($o) ? new class(){} : $o;
}
}
class OrganizationSubscription implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var int */
public int $organizationId=0,
/** @var int */
public int $userId=0,
/** @var string|null */
public ?string $userName=null,
/** @var string[]|null */
public ?array $postTypes=null,
/** @var int|null */
public ?int $frequencyDays=null,
/** @var int|null */
public ?int $lastSyncedId=null,
/** @var DateTime|null */
public ?DateTime $lastSynced=null,
/** @var DateTime */
public DateTime $created=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['organizationId'])) $this->organizationId = $o['organizationId'];
if (isset($o['userId'])) $this->userId = $o['userId'];
if (isset($o['userName'])) $this->userName = $o['userName'];
if (isset($o['postTypes'])) $this->postTypes = JsonConverters::fromArray('string', $o['postTypes']);
if (isset($o['frequencyDays'])) $this->frequencyDays = $o['frequencyDays'];
if (isset($o['lastSyncedId'])) $this->lastSyncedId = $o['lastSyncedId'];
if (isset($o['lastSynced'])) $this->lastSynced = JsonConverters::from('DateTime', $o['lastSynced']);
if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->organizationId)) $o['organizationId'] = $this->organizationId;
if (isset($this->userId)) $o['userId'] = $this->userId;
if (isset($this->userName)) $o['userName'] = $this->userName;
if (isset($this->postTypes)) $o['postTypes'] = JsonConverters::toArray('string', $this->postTypes);
if (isset($this->frequencyDays)) $o['frequencyDays'] = $this->frequencyDays;
if (isset($this->lastSyncedId)) $o['lastSyncedId'] = $this->lastSyncedId;
if (isset($this->lastSynced)) $o['lastSynced'] = JsonConverters::to('DateTime', $this->lastSynced);
if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
return empty($o) ? new class(){} : $o;
}
}
class GetUserOrganizationsResponse implements JsonSerializable
{
public function __construct(
/** @var array<OrganizationMember>|null */
public ?array $members=null,
/** @var array<OrganizationMemberInvite>|null */
public ?array $memberInvites=null,
/** @var array<OrganizationSubscription>|null */
public ?array $subscriptions=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['members'])) $this->members = JsonConverters::fromArray('OrganizationMember', $o['members']);
if (isset($o['memberInvites'])) $this->memberInvites = JsonConverters::fromArray('OrganizationMemberInvite', $o['memberInvites']);
if (isset($o['subscriptions'])) $this->subscriptions = JsonConverters::fromArray('OrganizationSubscription', $o['subscriptions']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->members)) $o['members'] = JsonConverters::toArray('OrganizationMember', $this->members);
if (isset($this->memberInvites)) $o['memberInvites'] = JsonConverters::toArray('OrganizationMemberInvite', $this->memberInvites);
if (isset($this->subscriptions)) $o['subscriptions'] = JsonConverters::toArray('OrganizationSubscription', $this->subscriptions);
return empty($o) ? new class(){} : $o;
}
}
class GetUserOrganizations implements IGet, JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
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
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /user/organizations HTTP/1.1
Host: techstacks.io
Accept: application/json
Content-Type: application/json
Content-Length: length
{}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"members":[{"id":0,"organizationId":0,"userId":0,"userName":"String","isOwner":false,"isModerator":false,"denyAll":false,"denyPosts":false,"denyComments":false,"notes":"String"}],"memberInvites":[{"id":0,"organizationId":0,"userId":0,"userName":"String","dismissed":"0001-01-01T00:00:00.0000000"}],"subscriptions":[{"id":0,"organizationId":0,"userId":0,"userName":"String","postTypes":["String"],"frequencyDays":0,"lastSyncedId":0,"lastSynced":"0001-01-01T00:00:00.0000000","created":"0001-01-01T00:00:00.0000000"}]}