Antel API

<back to all web services

CheckPrincipals

Requires Authentication
The following routes are available for this service:
POST/principal/check
<?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 PrincipalAppSync implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $principalId=0,
        /** @var string|null */
        public ?string $lastUpdated=null
    ) {
    }

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

class AuthRuleData implements JsonSerializable
{
    public function __construct(
        /** @var float */
        public float $fromValue=0.0,
        /** @var float */
        public float $toValue=0.0,
        /** @var bool|null */
        public ?bool $allow=null,
        /** @var bool|null */
        public ?bool $delayedAuth=null,
        /** @var bool|null */
        public ?bool $authRequired=null,
        /** @var string|null */
        public ?string $channel=null,
        /** @var string|null */
        public ?string $region=null
    ) {
    }

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

class PrincipalAuthRuleData implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $principalId=0,
        /** @var array<AuthRuleData>|null */
        public ?array $valueAuthRules=null,
        /** @var array<AuthRuleData>|null */
        public ?array $unitAuthRules=null
    ) {
    }

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

class CheckPrincipalsResponse 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 array<int>|null */
        public ?array $principalsToUpdate=null,
        /** @var array<PrincipalAppSync>|null */
        public ?array $principalAppSyncData=null,
        /** @var array<PrincipalAuthRuleData>|null */
        public ?array $authRules=null
    ) {
        parent::__construct($description,$heading,$wasSuccessful,$responseStatus);
    }

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

class CheckPrincipals 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 array<PrincipalAppSync>|null */
        public ?array $principals=null
    ) {
        parent::__construct($apiKey,$latitude,$longitude);
    }

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

PHP CheckPrincipals DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /principal/check HTTP/1.1 
Host: antel.api.dev.86degrees.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	principals: 
	[
		{
			principalId: 0,
			lastUpdated: String
		}
	],
	apiKey: String,
	latitude: 0,
	longitude: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	principalsToUpdate: 
	[
		0
	],
	principalAppSyncData: 
	[
		{
			principalId: 0,
			lastUpdated: String
		}
	],
	authRules: 
	[
		{
			principalId: 0,
			valueAuthRules: 
			[
				{
					
				}
			],
			unitAuthRules: 
			[
				{
					
				}
			]
		}
	],
	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
		}
	}
}