Trendsic Platform Service

<back to all web services

SiteContentRequest

The following routes are available for this service:
GET,PUT,POST,DELETE,OPTIONS/v1/SiteContent/{Category}
GET,PUT,POST,DELETE,OPTIONS/v1/SiteContent
GET,PUT,DELETE,POST,OPTIONS/v1/SiteContent/{Category}/{SortOrder}
<?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 SiteContent implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $ContentHeader=null,
        /** @var string|null */
        public ?string $ContentBody=null,
        /** @var DateTime */
        public DateTime $BeginDate=new DateTime(),
        /** @var DateTime */
        public DateTime $EndDate=new DateTime(),
        /** @var int */
        public int $SortOrder=0,
        /** @var string|null */
        public ?string $Category=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['ContentHeader'])) $this->ContentHeader = $o['ContentHeader'];
        if (isset($o['ContentBody'])) $this->ContentBody = $o['ContentBody'];
        if (isset($o['BeginDate'])) $this->BeginDate = JsonConverters::from('DateTime', $o['BeginDate']);
        if (isset($o['EndDate'])) $this->EndDate = JsonConverters::from('DateTime', $o['EndDate']);
        if (isset($o['SortOrder'])) $this->SortOrder = $o['SortOrder'];
        if (isset($o['Category'])) $this->Category = $o['Category'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->ContentHeader)) $o['ContentHeader'] = $this->ContentHeader;
        if (isset($this->ContentBody)) $o['ContentBody'] = $this->ContentBody;
        if (isset($this->BeginDate)) $o['BeginDate'] = JsonConverters::to('DateTime', $this->BeginDate);
        if (isset($this->EndDate)) $o['EndDate'] = JsonConverters::to('DateTime', $this->EndDate);
        if (isset($this->SortOrder)) $o['SortOrder'] = $this->SortOrder;
        if (isset($this->Category)) $o['Category'] = $this->Category;
        return empty($o) ? new class(){} : $o;
    }
}

class SiteContentRequest implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Category=null,
        /** @var string|null */
        public ?string $SortOrder=null,
        /** @var SiteContent|null */
        public ?SiteContent $SiteContent=null
    ) {
    }

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

PHP SiteContentRequest 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.

POST /v1/SiteContent/{Category} HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"Category":"String","SortOrder":"String","SiteContent":{"Id":0,"ContentHeader":"String","ContentBody":"String","BeginDate":"0001-01-01T00:00:00.0000000","EndDate":"0001-01-01T00:00:00.0000000","SortOrder":0,"Category":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Id":0,"ContentHeader":"String","ContentBody":"String","BeginDate":"0001-01-01T00:00:00.0000000","EndDate":"0001-01-01T00:00:00.0000000","SortOrder":0,"Category":"String"}