Insure Guard App API

<back to all web services

ConfirmOtp

<?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 ApiServiceRequest implements IServiceRequest, IHasApiKey, IHasDeviceInfo, JsonSerializable
{
    public function __construct(
        /** @description The API Key required for authentication */
        // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
        /** @var string */
        public string $apiKey='',

        /** @description Latitude of the user making this request */
        // @ApiMember(DataType="double", Description="Latitude of the user making this request")
        /** @var float */
        public float $latitude=0.0,

        /** @description Longitude of the user making this request */
        // @ApiMember(DataType="double", Description="Longitude of the user making this request")
        /** @var float */
        public float $longitude=0.0
    ) {
    }

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

class ApiServiceResponse implements IServiceResponse, JsonSerializable
{
    public function __construct(
        /** @description Information about the response. */
        // @ApiMember(Description="Information about the response.", IsRequired=true)
        /** @var string */
        public string $description='',

        /** @description Heading or summary of the response. */
        // @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
        /** @var string */
        public string $heading='',

        /** @description Did the intended operation for this response complete successfully? */
        // @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
        /** @var bool|null */
        public ?bool $wasSuccessful=null,

        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

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

class ClientData implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $firstName=null,
        /** @var string|null */
        public ?string $surname=null,
        /** @var string|null */
        public ?string $email=null,
        /** @var string|null */
        public ?string $mobileNumber=null,
        /** @var string|null */
        public ?string $address1=null,
        /** @var string|null */
        public ?string $address2=null,
        /** @var string|null */
        public ?string $city=null,
        /** @var string|null */
        public ?string $dateOfBirth=null,
        /** @var string|null */
        public ?string $sourceOfIncome=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['firstName'])) $this->firstName = $o['firstName'];
        if (isset($o['surname'])) $this->surname = $o['surname'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['mobileNumber'])) $this->mobileNumber = $o['mobileNumber'];
        if (isset($o['address1'])) $this->address1 = $o['address1'];
        if (isset($o['address2'])) $this->address2 = $o['address2'];
        if (isset($o['city'])) $this->city = $o['city'];
        if (isset($o['dateOfBirth'])) $this->dateOfBirth = $o['dateOfBirth'];
        if (isset($o['sourceOfIncome'])) $this->sourceOfIncome = $o['sourceOfIncome'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->firstName)) $o['firstName'] = $this->firstName;
        if (isset($this->surname)) $o['surname'] = $this->surname;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->mobileNumber)) $o['mobileNumber'] = $this->mobileNumber;
        if (isset($this->address1)) $o['address1'] = $this->address1;
        if (isset($this->address2)) $o['address2'] = $this->address2;
        if (isset($this->city)) $o['city'] = $this->city;
        if (isset($this->dateOfBirth)) $o['dateOfBirth'] = $this->dateOfBirth;
        if (isset($this->sourceOfIncome)) $o['sourceOfIncome'] = $this->sourceOfIncome;
        return empty($o) ? new class(){} : $o;
    }
}

class LoginData implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $systemUserId=0,
        /** @var string|null */
        public ?string $refreshToken=null,
        /** @var bool|null */
        public ?bool $hasActivePanicCover=null,
        /** @var bool|null */
        public ?bool $accountInArrears=null,
        /** @var bool|null */
        public ?bool $updateClientInformation=null,
        /** @var string|null */
        public ?string $nextPanicDate=null,
        /** @var string|null */
        public ?string $panicReference=null,
        /** @var ClientData|null */
        public ?ClientData $clientData=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['systemUserId'])) $this->systemUserId = $o['systemUserId'];
        if (isset($o['refreshToken'])) $this->refreshToken = $o['refreshToken'];
        if (isset($o['hasActivePanicCover'])) $this->hasActivePanicCover = $o['hasActivePanicCover'];
        if (isset($o['accountInArrears'])) $this->accountInArrears = $o['accountInArrears'];
        if (isset($o['updateClientInformation'])) $this->updateClientInformation = $o['updateClientInformation'];
        if (isset($o['nextPanicDate'])) $this->nextPanicDate = $o['nextPanicDate'];
        if (isset($o['panicReference'])) $this->panicReference = $o['panicReference'];
        if (isset($o['clientData'])) $this->clientData = JsonConverters::from('ClientData', $o['clientData']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->systemUserId)) $o['systemUserId'] = $this->systemUserId;
        if (isset($this->refreshToken)) $o['refreshToken'] = $this->refreshToken;
        if (isset($this->hasActivePanicCover)) $o['hasActivePanicCover'] = $this->hasActivePanicCover;
        if (isset($this->accountInArrears)) $o['accountInArrears'] = $this->accountInArrears;
        if (isset($this->updateClientInformation)) $o['updateClientInformation'] = $this->updateClientInformation;
        if (isset($this->nextPanicDate)) $o['nextPanicDate'] = $this->nextPanicDate;
        if (isset($this->panicReference)) $o['panicReference'] = $this->panicReference;
        if (isset($this->clientData)) $o['clientData'] = JsonConverters::to('ClientData', $this->clientData);
        return empty($o) ? new class(){} : $o;
    }
}

class ConfirmOtpResponse extends ApiServiceResponse implements JsonSerializable
{
    /**
     * @param string $description
     * @param string $heading
     * @param bool|null $wasSuccessful
     * @param ResponseStatus|null $responseStatus
     */
    public function __construct(
        string $description='',
        string $heading='',
        ?bool $wasSuccessful=null,
        ?ResponseStatus $responseStatus=null,
        /** @var LoginData|null */
        public ?LoginData $data=null
    ) {
        parent::__construct($description,$heading,$wasSuccessful,$responseStatus);
    }

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

class ConfirmOtp extends ApiServiceRequest implements JsonSerializable
{
    /**
     * @param string $apiKey
     * @param float $latitude
     * @param float $longitude
     */
    public function __construct(
        string $apiKey='',
        float $latitude=0.0,
        float $longitude=0.0,
        /** @var int */
        public int $systemUserId=0,
        /** @var string|null */
        public ?string $otp=null,
        /** @var int */
        public int $utcOffset=0,
        /** @description The user's push token - used for push messages. */
        // @ApiMember(Description="The user's push token - used for push messages.")
        /** @var string|null */
        public ?string $pushPlayerId=null
    ) {
        parent::__construct($apiKey,$latitude,$longitude);
    }

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

PHP ConfirmOtp 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/ConfirmOtp HTTP/1.1 
Host: legalguard-api-dev.happen.zone 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"systemUserId":0,"otp":"String","utcOffset":0,"pushPlayerId":"String","apiKey":"String","latitude":0,"longitude":0}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"data":{"systemUserId":0,"refreshToken":"String","hasActivePanicCover":false,"accountInArrears":false,"updateClientInformation":false,"nextPanicDate":"String","panicReference":"String","clientData":{"firstName":"String","surname":"String","email":"String","mobileNumber":"String","address1":"String","address2":"String","city":"String","dateOfBirth":"String","sourceOfIncome":"String"}},"description":"String","heading":"String","wasSuccessful":false,"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}