Blazor Diffusion

<back to all web services

GetUserInfo

User
<?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 Likes implements JsonSerializable
{
    public function __construct(
        /** @var array<int>|null */
        public ?array $artifactIds=null,
        /** @var array<int>|null */
        public ?array $albumIds=null
    ) {
    }

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

class AlbumResult implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var string */
        public string $name='',
        /** @var string */
        public string $slug='',
        /** @var string */
        public string $albumRef='',
        /** @var string */
        public string $ownerRef='',
        /** @var int|null */
        public ?int $primaryArtifactId=null,
        /** @var int */
        public int $score=0,
        /** @var array<int>|null */
        public ?array $artifactIds=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['slug'])) $this->slug = $o['slug'];
        if (isset($o['albumRef'])) $this->albumRef = $o['albumRef'];
        if (isset($o['ownerRef'])) $this->ownerRef = $o['ownerRef'];
        if (isset($o['primaryArtifactId'])) $this->primaryArtifactId = $o['primaryArtifactId'];
        if (isset($o['score'])) $this->score = $o['score'];
        if (isset($o['artifactIds'])) $this->artifactIds = JsonConverters::fromArray('int', $o['artifactIds']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->slug)) $o['slug'] = $this->slug;
        if (isset($this->albumRef)) $o['albumRef'] = $this->albumRef;
        if (isset($this->ownerRef)) $o['ownerRef'] = $this->ownerRef;
        if (isset($this->primaryArtifactId)) $o['primaryArtifactId'] = $this->primaryArtifactId;
        if (isset($this->score)) $o['score'] = $this->score;
        if (isset($this->artifactIds)) $o['artifactIds'] = JsonConverters::toArray('int', $this->artifactIds);
        return empty($o) ? new class(){} : $o;
    }
}

class UserResult implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $refId='',
        /** @var string|null */
        public ?string $handle=null,
        /** @var string|null */
        public ?string $avatar=null,
        /** @var string|null */
        public ?string $profileUrl=null,
        /** @var Likes|null */
        public ?Likes $likes=null,
        /** @var array<AlbumResult>|null */
        public ?array $albums=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['refId'])) $this->refId = $o['refId'];
        if (isset($o['handle'])) $this->handle = $o['handle'];
        if (isset($o['avatar'])) $this->avatar = $o['avatar'];
        if (isset($o['profileUrl'])) $this->profileUrl = $o['profileUrl'];
        if (isset($o['likes'])) $this->likes = JsonConverters::from('Likes', $o['likes']);
        if (isset($o['albums'])) $this->albums = JsonConverters::fromArray('AlbumResult', $o['albums']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->refId)) $o['refId'] = $this->refId;
        if (isset($this->handle)) $o['handle'] = $this->handle;
        if (isset($this->avatar)) $o['avatar'] = $this->avatar;
        if (isset($this->profileUrl)) $o['profileUrl'] = $this->profileUrl;
        if (isset($this->likes)) $o['likes'] = JsonConverters::to('Likes', $this->likes);
        if (isset($this->albums)) $o['albums'] = JsonConverters::toArray('AlbumResult', $this->albums);
        return empty($o) ? new class(){} : $o;
    }
}

class GetUserInfoResponse implements JsonSerializable
{
    public function __construct(
        /** @var UserResult|null */
        public ?UserResult $result=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

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

class GetUserInfo implements IGet, JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $refId=''
    ) {
    }

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

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

POST /csv/reply/GetUserInfo HTTP/1.1 
Host: blazordiffusion.com 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"refId":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"result":{"refId":"String","handle":"String","avatar":"String","profileUrl":"String","likes":{"artifactIds":[0],"albumIds":[0]},"albums":[{"id":0,"name":"String","slug":"String","albumRef":"String","ownerRef":"String","primaryArtifactId":0,"score":0,"artifactIds":[0]}]},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}