GET,POST | /authorizetoken/{Service}/{TokenString} |
---|
<?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 Setting implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $name=null,
/** @var string|null */
public ?string $stringValue=null,
/** @var bool|null */
public ?bool $booleanValue=null,
/** @var string|null */
public ?string $dataType=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['stringValue'])) $this->stringValue = $o['stringValue'];
if (isset($o['booleanValue'])) $this->booleanValue = $o['booleanValue'];
if (isset($o['dataType'])) $this->dataType = $o['dataType'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->stringValue)) $o['stringValue'] = $this->stringValue;
if (isset($this->booleanValue)) $o['booleanValue'] = $this->booleanValue;
if (isset($this->dataType)) $o['dataType'] = $this->dataType;
return empty($o) ? new class(){} : $o;
}
}
class AuthorizeBaseResponse implements JsonSerializable
{
public function __construct(
/** @var bool|null */
public ?bool $isAuthorized=null,
/** @var array<Setting>|null */
public ?array $settings=null,
/** @var int */
public int $suggestedStatusCode=0,
/** @var string|null */
public ?string $suggestedResponseMessage=null,
/** @var string|null */
public ?string $reason=null,
/** @var string|null */
public ?string $customerId=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['isAuthorized'])) $this->isAuthorized = $o['isAuthorized'];
if (isset($o['settings'])) $this->settings = JsonConverters::fromArray('Setting', $o['settings']);
if (isset($o['suggestedStatusCode'])) $this->suggestedStatusCode = $o['suggestedStatusCode'];
if (isset($o['suggestedResponseMessage'])) $this->suggestedResponseMessage = $o['suggestedResponseMessage'];
if (isset($o['reason'])) $this->reason = $o['reason'];
if (isset($o['customerId'])) $this->customerId = $o['customerId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->isAuthorized)) $o['isAuthorized'] = $this->isAuthorized;
if (isset($this->settings)) $o['settings'] = JsonConverters::toArray('Setting', $this->settings);
if (isset($this->suggestedStatusCode)) $o['suggestedStatusCode'] = $this->suggestedStatusCode;
if (isset($this->suggestedResponseMessage)) $o['suggestedResponseMessage'] = $this->suggestedResponseMessage;
if (isset($this->reason)) $o['reason'] = $this->reason;
if (isset($this->customerId)) $o['customerId'] = $this->customerId;
return empty($o) ? new class(){} : $o;
}
}
class AuthorizeTokenResponse extends AuthorizeBaseResponse implements JsonSerializable
{
/**
* @param bool|null $isAuthorized
* @param array<Setting>|null $settings
* @param int $suggestedStatusCode
* @param string|null $suggestedResponseMessage
* @param string|null $reason
* @param string|null $customerId
*/
public function __construct(
?bool $isAuthorized=null,
?array $settings=null,
int $suggestedStatusCode=0,
?string $suggestedResponseMessage=null,
?string $reason=null,
?string $customerId=null
) {
parent::__construct($isAuthorized,$settings,$suggestedStatusCode,$suggestedResponseMessage,$reason,$customerId);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
return empty($o) ? new class(){} : $o;
}
}
class AuthorizeToken implements IAuthorizeToken, JsonSerializable
{
public function __construct(
// @ApiMember(IsRequired=true, ParameterType="path")
/** @var string */
public string $tokenString='',
// @ApiMember(IsRequired=true, ParameterType="path")
/** @var string */
public string $service=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['tokenString'])) $this->tokenString = $o['tokenString'];
if (isset($o['service'])) $this->service = $o['service'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->tokenString)) $o['tokenString'] = $this->tokenString;
if (isset($this->service)) $o['service'] = $this->service;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /authorizetoken/{Service}/{TokenString} HTTP/1.1
Host: nkapi-sgepz3-auth-r1.azurewebsites.net
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
tokenString: String,
service: String
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { isAuthorized: False, settings: [ { name: String, stringValue: String, booleanValue: False, dataType: String } ], suggestedStatusCode: 0, suggestedResponseMessage: String, reason: String }