TechStacks!

<back to all web services

DummyTypes

<?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 DummyTypes implements JsonSerializable
{
    public function __construct(
        /** @var array<Post>|null */
        public ?array $post=null
    ) {
    }

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

PHP DummyTypes DTOs

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

HTTP + XML

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

POST /xml/oneway/DummyTypes HTTP/1.1 
Host: techstacks.io 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<DummyTypes xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/TechStacks.ServiceInterface.Admin">
  <Post xmlns:d2p1="http://schemas.datacontract.org/2004/07/TechStacks.ServiceModel.Types">
    <d2p1:Post>
      <d2p1:Approved>false</d2p1:Approved>
      <d2p1:Archived>false</d2p1:Archived>
      <d2p1:Bumped>0001-01-01T00:00:00</d2p1:Bumped>
      <d2p1:CategoryId>0</d2p1:CategoryId>
      <d2p1:CommentsCount>0</d2p1:CommentsCount>
      <d2p1:Content>String</d2p1:Content>
      <d2p1:ContentHtml>String</d2p1:ContentHtml>
      <d2p1:Created>0001-01-01T00:00:00</d2p1:Created>
      <d2p1:CreatedBy>String</d2p1:CreatedBy>
      <d2p1:Deleted>0001-01-01T00:00:00</d2p1:Deleted>
      <d2p1:DeletedBy>String</d2p1:DeletedBy>
      <d2p1:DownVotes>0</d2p1:DownVotes>
      <d2p1:Favorites>0</d2p1:Favorites>
      <d2p1:FromDate>0001-01-01T00:00:00</d2p1:FromDate>
      <d2p1:Hidden>0001-01-01T00:00:00</d2p1:Hidden>
      <d2p1:HiddenBy>String</d2p1:HiddenBy>
      <d2p1:Id>0</d2p1:Id>
      <d2p1:ImageUrl>String</d2p1:ImageUrl>
      <d2p1:Labels xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:string>String</d4p1:string>
      </d2p1:Labels>
      <d2p1:LastCommentDate>0001-01-01T00:00:00</d2p1:LastCommentDate>
      <d2p1:LastCommentId>0</d2p1:LastCommentId>
      <d2p1:LastCommentUserId>0</d2p1:LastCommentUserId>
      <d2p1:LinkedToCount>0</d2p1:LinkedToCount>
      <d2p1:LinksCount>0</d2p1:LinksCount>
      <d2p1:Location>String</d2p1:Location>
      <d2p1:Locked>0001-01-01T00:00:00</d2p1:Locked>
      <d2p1:LockedBy>String</d2p1:LockedBy>
      <d2p1:Meta>String</d2p1:Meta>
      <d2p1:MetaType>String</d2p1:MetaType>
      <d2p1:Modified>0001-01-01T00:00:00</d2p1:Modified>
      <d2p1:ModifiedBy>String</d2p1:ModifiedBy>
      <d2p1:MuteUserIds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:int>0</d4p1:int>
      </d2p1:MuteUserIds>
      <d2p1:OrganizationId>0</d2p1:OrganizationId>
      <d2p1:PinCommentId>0</d2p1:PinCommentId>
      <d2p1:Points>0</d2p1:Points>
      <d2p1:Rank>0</d2p1:Rank>
      <d2p1:RefId>0</d2p1:RefId>
      <d2p1:RefLinks xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:string>String</d4p1:string>
      </d2p1:RefLinks>
      <d2p1:RefSource>String</d2p1:RefSource>
      <d2p1:RefUrn>String</d2p1:RefUrn>
      <d2p1:RefUserIds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:int>0</d4p1:int>
      </d2p1:RefUserIds>
      <d2p1:ReplyCount>0</d2p1:ReplyCount>
      <d2p1:ReportCount>0</d2p1:ReportCount>
      <d2p1:Score>0</d2p1:Score>
      <d2p1:Slug>String</d2p1:Slug>
      <d2p1:Status>String</d2p1:Status>
      <d2p1:StatusBy>String</d2p1:StatusBy>
      <d2p1:StatusDate>0001-01-01T00:00:00</d2p1:StatusDate>
      <d2p1:Subscribers>0</d2p1:Subscribers>
      <d2p1:TechnologyIds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:int>0</d4p1:int>
      </d2p1:TechnologyIds>
      <d2p1:Title>String</d2p1:Title>
      <d2p1:ToDate>0001-01-01T00:00:00</d2p1:ToDate>
      <d2p1:Type>Announcement</d2p1:Type>
      <d2p1:UpVotes>0</d2p1:UpVotes>
      <d2p1:Url>String</d2p1:Url>
      <d2p1:UserId>0</d2p1:UserId>
      <d2p1:Views>0</d2p1:Views>
      <d2p1:WordCount>0</d2p1:WordCount>
    </d2p1:Post>
  </Post>
</DummyTypes>