Blazor Diffusion

<back to all web services

GetAnalyticsInfo

<?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};


// @DataContract
class AnalyticsLogInfo implements JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var int */
        public int $id=0,

        // @DataMember(Order=2)
        /** @var DateTime */
        public DateTime $dateTime=new DateTime(),

        // @DataMember(Order=3)
        /** @var string|null */
        public ?string $browser=null,

        // @DataMember(Order=4)
        /** @var string|null */
        public ?string $device=null,

        // @DataMember(Order=5)
        /** @var string|null */
        public ?string $bot=null,

        // @DataMember(Order=6)
        /** @var string|null */
        public ?string $op=null,

        // @DataMember(Order=7)
        /** @var string|null */
        public ?string $userId=null,

        // @DataMember(Order=8)
        /** @var string|null */
        public ?string $userName=null,

        // @DataMember(Order=9)
        /** @var string|null */
        public ?string $apiKey=null,

        // @DataMember(Order=10)
        /** @var string|null */
        public ?string $ip=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['dateTime'])) $this->dateTime = JsonConverters::from('DateTime', $o['dateTime']);
        if (isset($o['browser'])) $this->browser = $o['browser'];
        if (isset($o['device'])) $this->device = $o['device'];
        if (isset($o['bot'])) $this->bot = $o['bot'];
        if (isset($o['op'])) $this->op = $o['op'];
        if (isset($o['userId'])) $this->userId = $o['userId'];
        if (isset($o['userName'])) $this->userName = $o['userName'];
        if (isset($o['apiKey'])) $this->apiKey = $o['apiKey'];
        if (isset($o['ip'])) $this->ip = $o['ip'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->dateTime)) $o['dateTime'] = JsonConverters::to('DateTime', $this->dateTime);
        if (isset($this->browser)) $o['browser'] = $this->browser;
        if (isset($this->device)) $o['device'] = $this->device;
        if (isset($this->bot)) $o['bot'] = $this->bot;
        if (isset($this->op)) $o['op'] = $this->op;
        if (isset($this->userId)) $o['userId'] = $this->userId;
        if (isset($this->userName)) $o['userName'] = $this->userName;
        if (isset($this->apiKey)) $o['apiKey'] = $this->apiKey;
        if (isset($this->ip)) $o['ip'] = $this->ip;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class GetAnalyticsInfoResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var array<string>|null */
        public ?array $months=null,

        // @DataMember(Order=2)
        /** @var AnalyticsLogInfo|null */
        public ?AnalyticsLogInfo $result=null,

        // @DataMember(Order=3)
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

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

// @DataContract
class GetAnalyticsInfo implements IGet, JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var DateTime|null */
        public ?DateTime $month=null,

        // @DataMember(Order=2)
        /** @var string|null */
        public ?string $type=null,

        // @DataMember(Order=3)
        /** @var string|null */
        public ?string $op=null,

        // @DataMember(Order=4)
        /** @var string|null */
        public ?string $apiKey=null,

        // @DataMember(Order=5)
        /** @var string|null */
        public ?string $userId=null,

        // @DataMember(Order=6)
        /** @var string|null */
        public ?string $ip=null
    ) {
    }

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

PHP GetAnalyticsInfo 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 /json/reply/GetAnalyticsInfo HTTP/1.1 
Host: blazordiffusion.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"month":"0001-01-01T00:00:00","type":"String","op":"String","apiKey":"String","userId":"String","ip":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"months":["String"],"result":{"id":0,"dateTime":"0001-01-01T00:00:00","browser":"String","device":"String","bot":"String","op":"String","userId":"String","userName":"String","apiKey":"String","ip":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}