MyApp

<back to all web services

Register

auth

Sign Up

The following routes are available for this service:
PUT,POST/register
<?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 RegisterResponse implements IMeta, IHasSessionId, IHasBearerToken, JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var string|null */
        public ?string $userId=null,

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

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

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

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

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

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

        // @DataMember(Order=8)
        /** @var array<string>|null */
        public ?array $roles=null,

        // @DataMember(Order=9)
        /** @var array<string>|null */
        public ?array $permissions=null,

        // @DataMember(Order=10)
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null,

        // @DataMember(Order=11)
        /** @var array<string,string>|null */
        public ?array $meta=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['userId'])) $this->userId = $o['userId'];
        if (isset($o['sessionId'])) $this->sessionId = $o['sessionId'];
        if (isset($o['userName'])) $this->userName = $o['userName'];
        if (isset($o['referrerUrl'])) $this->referrerUrl = $o['referrerUrl'];
        if (isset($o['bearerToken'])) $this->bearerToken = $o['bearerToken'];
        if (isset($o['refreshToken'])) $this->refreshToken = $o['refreshToken'];
        if (isset($o['refreshTokenExpiry'])) $this->refreshTokenExpiry = JsonConverters::from('DateTime', $o['refreshTokenExpiry']);
        if (isset($o['roles'])) $this->roles = JsonConverters::fromArray('string', $o['roles']);
        if (isset($o['permissions'])) $this->permissions = JsonConverters::fromArray('string', $o['permissions']);
        if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
        if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->userId)) $o['userId'] = $this->userId;
        if (isset($this->sessionId)) $o['sessionId'] = $this->sessionId;
        if (isset($this->userName)) $o['userName'] = $this->userName;
        if (isset($this->referrerUrl)) $o['referrerUrl'] = $this->referrerUrl;
        if (isset($this->bearerToken)) $o['bearerToken'] = $this->bearerToken;
        if (isset($this->refreshToken)) $o['refreshToken'] = $this->refreshToken;
        if (isset($this->refreshTokenExpiry)) $o['refreshTokenExpiry'] = JsonConverters::to('DateTime', $this->refreshTokenExpiry);
        if (isset($this->roles)) $o['roles'] = JsonConverters::toArray('string', $this->roles);
        if (isset($this->permissions)) $o['permissions'] = JsonConverters::toArray('string', $this->permissions);
        if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
        if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Sign Up */
// @Api(Description="Sign Up")
// @DataContract
class Register implements IPost, IMeta, JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var string|null */
        public ?string $userName=null,

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

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

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

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

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

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

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

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

        // @DataMember(Order=11)
        /** @var array<string,string>|null */
        public ?array $meta=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['userName'])) $this->userName = $o['userName'];
        if (isset($o['firstName'])) $this->firstName = $o['firstName'];
        if (isset($o['lastName'])) $this->lastName = $o['lastName'];
        if (isset($o['displayName'])) $this->displayName = $o['displayName'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['password'])) $this->password = $o['password'];
        if (isset($o['confirmPassword'])) $this->confirmPassword = $o['confirmPassword'];
        if (isset($o['autoLogin'])) $this->autoLogin = $o['autoLogin'];
        if (isset($o['errorView'])) $this->errorView = $o['errorView'];
        if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->userName)) $o['userName'] = $this->userName;
        if (isset($this->firstName)) $o['firstName'] = $this->firstName;
        if (isset($this->lastName)) $o['lastName'] = $this->lastName;
        if (isset($this->displayName)) $o['displayName'] = $this->displayName;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->password)) $o['password'] = $this->password;
        if (isset($this->confirmPassword)) $o['confirmPassword'] = $this->confirmPassword;
        if (isset($this->autoLogin)) $o['autoLogin'] = $this->autoLogin;
        if (isset($this->errorView)) $o['errorView'] = $this->errorView;
        if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
        return empty($o) ? new class(){} : $o;
    }
}

PHP Register 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 /register HTTP/1.1 
Host: vue-vite-api.jamstacks.net 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"userName":"String","firstName":"String","lastName":"String","displayName":"String","email":"String","password":"String","confirmPassword":"String","autoLogin":false,"errorView":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"userId":"String","sessionId":"String","userName":"String","referrerUrl":"String","bearerToken":"String","refreshToken":"String","refreshTokenExpiry":"\/Date(-62135596800000-0000)\/","roles":["String"],"permissions":["String"],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}},"meta":{"String":"String"}}