TechStacks!

<back to all web services

GetPost

Posts
The following routes are available for this service:
GET/posts/{Id}
<?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};


enum PostType : string
{
    case Announcement = 'Announcement';
    case Post = 'Post';
    case Showcase = 'Showcase';
    case Question = 'Question';
    case Request = 'Request';
}

class Post implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var int */
        public int $organizationId=0,
        /** @var int */
        public int $userId=0,
        /** @var PostType|null */
        public ?PostType $type=null,
        /** @var int */
        public int $categoryId=0,
        /** @var string|null */
        public ?string $title=null,
        /** @var string|null */
        public ?string $slug=null,
        /** @var string|null */
        public ?string $url=null,
        /** @var string|null */
        public ?string $imageUrl=null,
        // @StringLength(2147483647)
        /** @var string|null */
        public ?string $content=null,

        // @StringLength(2147483647)
        /** @var string|null */
        public ?string $contentHtml=null,

        /** @var int|null */
        public ?int $pinCommentId=null,
        /** @var int[]|null */
        public ?array $technologyIds=null,
        /** @var DateTime|null */
        public ?DateTime $fromDate=null,
        /** @var DateTime|null */
        public ?DateTime $toDate=null,
        /** @var string|null */
        public ?string $location=null,
        /** @var string|null */
        public ?string $metaType=null,
        /** @var string|null */
        public ?string $meta=null,
        /** @var bool|null */
        public ?bool $approved=null,
        /** @var int */
        public int $upVotes=0,
        /** @var int */
        public int $downVotes=0,
        /** @var int */
        public int $points=0,
        /** @var int */
        public int $views=0,
        /** @var int */
        public int $favorites=0,
        /** @var int */
        public int $subscribers=0,
        /** @var int */
        public int $replyCount=0,
        /** @var int */
        public int $commentsCount=0,
        /** @var int */
        public int $wordCount=0,
        /** @var int */
        public int $reportCount=0,
        /** @var int */
        public int $linksCount=0,
        /** @var int */
        public int $linkedToCount=0,
        /** @var int */
        public int $score=0,
        /** @var int */
        public int $rank=0,
        /** @var string[]|null */
        public ?array $labels=null,
        /** @var int[]|null */
        public ?array $refUserIds=null,
        /** @var string[]|null */
        public ?array $refLinks=null,
        /** @var int[]|null */
        public ?array $muteUserIds=null,
        /** @var DateTime|null */
        public ?DateTime $lastCommentDate=null,
        /** @var int|null */
        public ?int $lastCommentId=null,
        /** @var int|null */
        public ?int $lastCommentUserId=null,
        /** @var DateTime|null */
        public ?DateTime $deleted=null,
        /** @var string|null */
        public ?string $deletedBy=null,
        /** @var DateTime|null */
        public ?DateTime $locked=null,
        /** @var string|null */
        public ?string $lockedBy=null,
        /** @var DateTime|null */
        public ?DateTime $hidden=null,
        /** @var string|null */
        public ?string $hiddenBy=null,
        /** @var string|null */
        public ?string $status=null,
        /** @var DateTime|null */
        public ?DateTime $statusDate=null,
        /** @var string|null */
        public ?string $statusBy=null,
        /** @var bool|null */
        public ?bool $archived=null,
        /** @var DateTime|null */
        public ?DateTime $bumped=null,
        /** @var DateTime */
        public DateTime $created=new DateTime(),
        /** @var string|null */
        public ?string $createdBy=null,
        /** @var DateTime */
        public DateTime $modified=new DateTime(),
        /** @var string|null */
        public ?string $modifiedBy=null,
        /** @var int|null */
        public ?int $refId=null,
        /** @var string|null */
        public ?string $refSource=null,
        /** @var string|null */
        public ?string $refUrn=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['type'])) $this->type = JsonConverters::from('PostType', $o['type']);
        if (isset($o['categoryId'])) $this->categoryId = $o['categoryId'];
        if (isset($o['title'])) $this->title = $o['title'];
        if (isset($o['slug'])) $this->slug = $o['slug'];
        if (isset($o['url'])) $this->url = $o['url'];
        if (isset($o['imageUrl'])) $this->imageUrl = $o['imageUrl'];
        if (isset($o['content'])) $this->content = $o['content'];
        if (isset($o['contentHtml'])) $this->contentHtml = $o['contentHtml'];
        if (isset($o['pinCommentId'])) $this->pinCommentId = $o['pinCommentId'];
        if (isset($o['technologyIds'])) $this->technologyIds = JsonConverters::fromArray('int', $o['technologyIds']);
        if (isset($o['fromDate'])) $this->fromDate = JsonConverters::from('DateTime', $o['fromDate']);
        if (isset($o['toDate'])) $this->toDate = JsonConverters::from('DateTime', $o['toDate']);
        if (isset($o['location'])) $this->location = $o['location'];
        if (isset($o['metaType'])) $this->metaType = $o['metaType'];
        if (isset($o['meta'])) $this->meta = $o['meta'];
        if (isset($o['approved'])) $this->approved = $o['approved'];
        if (isset($o['upVotes'])) $this->upVotes = $o['upVotes'];
        if (isset($o['downVotes'])) $this->downVotes = $o['downVotes'];
        if (isset($o['points'])) $this->points = $o['points'];
        if (isset($o['views'])) $this->views = $o['views'];
        if (isset($o['favorites'])) $this->favorites = $o['favorites'];
        if (isset($o['subscribers'])) $this->subscribers = $o['subscribers'];
        if (isset($o['replyCount'])) $this->replyCount = $o['replyCount'];
        if (isset($o['commentsCount'])) $this->commentsCount = $o['commentsCount'];
        if (isset($o['wordCount'])) $this->wordCount = $o['wordCount'];
        if (isset($o['reportCount'])) $this->reportCount = $o['reportCount'];
        if (isset($o['linksCount'])) $this->linksCount = $o['linksCount'];
        if (isset($o['linkedToCount'])) $this->linkedToCount = $o['linkedToCount'];
        if (isset($o['score'])) $this->score = $o['score'];
        if (isset($o['rank'])) $this->rank = $o['rank'];
        if (isset($o['labels'])) $this->labels = JsonConverters::fromArray('string', $o['labels']);
        if (isset($o['refUserIds'])) $this->refUserIds = JsonConverters::fromArray('int', $o['refUserIds']);
        if (isset($o['refLinks'])) $this->refLinks = JsonConverters::fromArray('string', $o['refLinks']);
        if (isset($o['muteUserIds'])) $this->muteUserIds = JsonConverters::fromArray('int', $o['muteUserIds']);
        if (isset($o['lastCommentDate'])) $this->lastCommentDate = JsonConverters::from('DateTime', $o['lastCommentDate']);
        if (isset($o['lastCommentId'])) $this->lastCommentId = $o['lastCommentId'];
        if (isset($o['lastCommentUserId'])) $this->lastCommentUserId = $o['lastCommentUserId'];
        if (isset($o['deleted'])) $this->deleted = JsonConverters::from('DateTime', $o['deleted']);
        if (isset($o['deletedBy'])) $this->deletedBy = $o['deletedBy'];
        if (isset($o['locked'])) $this->locked = JsonConverters::from('DateTime', $o['locked']);
        if (isset($o['lockedBy'])) $this->lockedBy = $o['lockedBy'];
        if (isset($o['hidden'])) $this->hidden = JsonConverters::from('DateTime', $o['hidden']);
        if (isset($o['hiddenBy'])) $this->hiddenBy = $o['hiddenBy'];
        if (isset($o['status'])) $this->status = $o['status'];
        if (isset($o['statusDate'])) $this->statusDate = JsonConverters::from('DateTime', $o['statusDate']);
        if (isset($o['statusBy'])) $this->statusBy = $o['statusBy'];
        if (isset($o['archived'])) $this->archived = $o['archived'];
        if (isset($o['bumped'])) $this->bumped = JsonConverters::from('DateTime', $o['bumped']);
        if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
        if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
        if (isset($o['modified'])) $this->modified = JsonConverters::from('DateTime', $o['modified']);
        if (isset($o['modifiedBy'])) $this->modifiedBy = $o['modifiedBy'];
        if (isset($o['refId'])) $this->refId = $o['refId'];
        if (isset($o['refSource'])) $this->refSource = $o['refSource'];
        if (isset($o['refUrn'])) $this->refUrn = $o['refUrn'];
    }
    
    /** @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->type)) $o['type'] = JsonConverters::to('PostType', $this->type);
        if (isset($this->categoryId)) $o['categoryId'] = $this->categoryId;
        if (isset($this->title)) $o['title'] = $this->title;
        if (isset($this->slug)) $o['slug'] = $this->slug;
        if (isset($this->url)) $o['url'] = $this->url;
        if (isset($this->imageUrl)) $o['imageUrl'] = $this->imageUrl;
        if (isset($this->content)) $o['content'] = $this->content;
        if (isset($this->contentHtml)) $o['contentHtml'] = $this->contentHtml;
        if (isset($this->pinCommentId)) $o['pinCommentId'] = $this->pinCommentId;
        if (isset($this->technologyIds)) $o['technologyIds'] = JsonConverters::toArray('int', $this->technologyIds);
        if (isset($this->fromDate)) $o['fromDate'] = JsonConverters::to('DateTime', $this->fromDate);
        if (isset($this->toDate)) $o['toDate'] = JsonConverters::to('DateTime', $this->toDate);
        if (isset($this->location)) $o['location'] = $this->location;
        if (isset($this->metaType)) $o['metaType'] = $this->metaType;
        if (isset($this->meta)) $o['meta'] = $this->meta;
        if (isset($this->approved)) $o['approved'] = $this->approved;
        if (isset($this->upVotes)) $o['upVotes'] = $this->upVotes;
        if (isset($this->downVotes)) $o['downVotes'] = $this->downVotes;
        if (isset($this->points)) $o['points'] = $this->points;
        if (isset($this->views)) $o['views'] = $this->views;
        if (isset($this->favorites)) $o['favorites'] = $this->favorites;
        if (isset($this->subscribers)) $o['subscribers'] = $this->subscribers;
        if (isset($this->replyCount)) $o['replyCount'] = $this->replyCount;
        if (isset($this->commentsCount)) $o['commentsCount'] = $this->commentsCount;
        if (isset($this->wordCount)) $o['wordCount'] = $this->wordCount;
        if (isset($this->reportCount)) $o['reportCount'] = $this->reportCount;
        if (isset($this->linksCount)) $o['linksCount'] = $this->linksCount;
        if (isset($this->linkedToCount)) $o['linkedToCount'] = $this->linkedToCount;
        if (isset($this->score)) $o['score'] = $this->score;
        if (isset($this->rank)) $o['rank'] = $this->rank;
        if (isset($this->labels)) $o['labels'] = JsonConverters::toArray('string', $this->labels);
        if (isset($this->refUserIds)) $o['refUserIds'] = JsonConverters::toArray('int', $this->refUserIds);
        if (isset($this->refLinks)) $o['refLinks'] = JsonConverters::toArray('string', $this->refLinks);
        if (isset($this->muteUserIds)) $o['muteUserIds'] = JsonConverters::toArray('int', $this->muteUserIds);
        if (isset($this->lastCommentDate)) $o['lastCommentDate'] = JsonConverters::to('DateTime', $this->lastCommentDate);
        if (isset($this->lastCommentId)) $o['lastCommentId'] = $this->lastCommentId;
        if (isset($this->lastCommentUserId)) $o['lastCommentUserId'] = $this->lastCommentUserId;
        if (isset($this->deleted)) $o['deleted'] = JsonConverters::to('DateTime', $this->deleted);
        if (isset($this->deletedBy)) $o['deletedBy'] = $this->deletedBy;
        if (isset($this->locked)) $o['locked'] = JsonConverters::to('DateTime', $this->locked);
        if (isset($this->lockedBy)) $o['lockedBy'] = $this->lockedBy;
        if (isset($this->hidden)) $o['hidden'] = JsonConverters::to('DateTime', $this->hidden);
        if (isset($this->hiddenBy)) $o['hiddenBy'] = $this->hiddenBy;
        if (isset($this->status)) $o['status'] = $this->status;
        if (isset($this->statusDate)) $o['statusDate'] = JsonConverters::to('DateTime', $this->statusDate);
        if (isset($this->statusBy)) $o['statusBy'] = $this->statusBy;
        if (isset($this->archived)) $o['archived'] = $this->archived;
        if (isset($this->bumped)) $o['bumped'] = JsonConverters::to('DateTime', $this->bumped);
        if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
        if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
        if (isset($this->modified)) $o['modified'] = JsonConverters::to('DateTime', $this->modified);
        if (isset($this->modifiedBy)) $o['modifiedBy'] = $this->modifiedBy;
        if (isset($this->refId)) $o['refId'] = $this->refId;
        if (isset($this->refSource)) $o['refSource'] = $this->refSource;
        if (isset($this->refUrn)) $o['refUrn'] = $this->refUrn;
        return empty($o) ? new class(){} : $o;
    }
}

class PostComment implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var int */
        public int $postId=0,
        /** @var int */
        public int $userId=0,
        /** @var int|null */
        public ?int $replyId=null,
        // @StringLength(2147483647)
        /** @var string|null */
        public ?string $content=null,

        // @StringLength(2147483647)
        /** @var string|null */
        public ?string $contentHtml=null,

        /** @var int */
        public int $score=0,
        /** @var int */
        public int $rank=0,
        /** @var int */
        public int $upVotes=0,
        /** @var int */
        public int $downVotes=0,
        /** @var int */
        public int $favorites=0,
        /** @var int */
        public int $wordCount=0,
        /** @var int */
        public int $reportCount=0,
        /** @var DateTime|null */
        public ?DateTime $deleted=null,
        /** @var DateTime|null */
        public ?DateTime $hidden=null,
        /** @var DateTime */
        public DateTime $modified=new DateTime(),
        /** @var DateTime */
        public DateTime $created=new DateTime(),
        /** @var string|null */
        public ?string $createdBy=null,
        /** @var int|null */
        public ?int $refId=null,
        /** @var string|null */
        public ?string $refSource=null,
        /** @var string|null */
        public ?string $refUrn=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['postId'])) $this->postId = $o['postId'];
        if (isset($o['userId'])) $this->userId = $o['userId'];
        if (isset($o['replyId'])) $this->replyId = $o['replyId'];
        if (isset($o['content'])) $this->content = $o['content'];
        if (isset($o['contentHtml'])) $this->contentHtml = $o['contentHtml'];
        if (isset($o['score'])) $this->score = $o['score'];
        if (isset($o['rank'])) $this->rank = $o['rank'];
        if (isset($o['upVotes'])) $this->upVotes = $o['upVotes'];
        if (isset($o['downVotes'])) $this->downVotes = $o['downVotes'];
        if (isset($o['favorites'])) $this->favorites = $o['favorites'];
        if (isset($o['wordCount'])) $this->wordCount = $o['wordCount'];
        if (isset($o['reportCount'])) $this->reportCount = $o['reportCount'];
        if (isset($o['deleted'])) $this->deleted = JsonConverters::from('DateTime', $o['deleted']);
        if (isset($o['hidden'])) $this->hidden = JsonConverters::from('DateTime', $o['hidden']);
        if (isset($o['modified'])) $this->modified = JsonConverters::from('DateTime', $o['modified']);
        if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
        if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
        if (isset($o['refId'])) $this->refId = $o['refId'];
        if (isset($o['refSource'])) $this->refSource = $o['refSource'];
        if (isset($o['refUrn'])) $this->refUrn = $o['refUrn'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->postId)) $o['postId'] = $this->postId;
        if (isset($this->userId)) $o['userId'] = $this->userId;
        if (isset($this->replyId)) $o['replyId'] = $this->replyId;
        if (isset($this->content)) $o['content'] = $this->content;
        if (isset($this->contentHtml)) $o['contentHtml'] = $this->contentHtml;
        if (isset($this->score)) $o['score'] = $this->score;
        if (isset($this->rank)) $o['rank'] = $this->rank;
        if (isset($this->upVotes)) $o['upVotes'] = $this->upVotes;
        if (isset($this->downVotes)) $o['downVotes'] = $this->downVotes;
        if (isset($this->favorites)) $o['favorites'] = $this->favorites;
        if (isset($this->wordCount)) $o['wordCount'] = $this->wordCount;
        if (isset($this->reportCount)) $o['reportCount'] = $this->reportCount;
        if (isset($this->deleted)) $o['deleted'] = JsonConverters::to('DateTime', $this->deleted);
        if (isset($this->hidden)) $o['hidden'] = JsonConverters::to('DateTime', $this->hidden);
        if (isset($this->modified)) $o['modified'] = JsonConverters::to('DateTime', $this->modified);
        if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
        if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
        if (isset($this->refId)) $o['refId'] = $this->refId;
        if (isset($this->refSource)) $o['refSource'] = $this->refSource;
        if (isset($this->refUrn)) $o['refUrn'] = $this->refUrn;
        return empty($o) ? new class(){} : $o;
    }
}

class GetPostResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $cache=0,
        /** @var Post|null */
        public ?Post $post=null,
        /** @var array<PostComment>|null */
        public ?array $comments=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

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

class GetPost implements IGet, JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var string|null */
        public ?string $include=null
    ) {
    }

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

PHP GetPost DTOs

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

HTTP + CSV

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

GET /posts/{Id} HTTP/1.1 
Host: techstacks.io 
Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"cache":0,"post":{"id":0,"organizationId":0,"userId":0,"type":"Announcement","categoryId":0,"title":"String","slug":"String","url":"String","imageUrl":"String","content":"String","contentHtml":"String","pinCommentId":0,"technologyIds":[0],"fromDate":"0001-01-01T00:00:00.0000000","toDate":"0001-01-01T00:00:00.0000000","location":"String","metaType":"String","meta":"String","approved":false,"upVotes":0,"downVotes":0,"points":0,"views":0,"favorites":0,"subscribers":0,"replyCount":0,"commentsCount":0,"wordCount":0,"reportCount":0,"linksCount":0,"linkedToCount":0,"score":0,"rank":0,"labels":["String"],"refUserIds":[0],"refLinks":["String"],"muteUserIds":[0],"lastCommentDate":"0001-01-01T00:00:00.0000000","lastCommentId":0,"lastCommentUserId":0,"deleted":"0001-01-01T00:00:00.0000000","deletedBy":"String","locked":"0001-01-01T00:00:00.0000000","lockedBy":"String","hidden":"0001-01-01T00:00:00.0000000","hiddenBy":"String","status":"String","statusDate":"0001-01-01T00:00:00.0000000","statusBy":"String","archived":false,"bumped":"0001-01-01T00:00:00.0000000","created":"0001-01-01T00:00:00.0000000","createdBy":"String","modified":"0001-01-01T00:00:00.0000000","modifiedBy":"String","refId":0,"refSource":"String","refUrn":"String"},"comments":[{"id":0,"postId":0,"userId":0,"replyId":0,"content":"String","contentHtml":"String","score":0,"rank":0,"upVotes":0,"downVotes":0,"favorites":0,"wordCount":0,"reportCount":0,"deleted":"0001-01-01T00:00:00.0000000","hidden":"0001-01-01T00:00:00.0000000","modified":"0001-01-01T00:00:00.0000000","created":"0001-01-01T00:00:00.0000000","createdBy":"String","refId":0,"refSource":"String","refUrn":"String"}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}