GET,POST | /authorizeuser/{Service}/{Profile} |
---|
<?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 AuthorizeUserResponse extends AuthorizeBaseResponse implements IAuthorizeUserResponse, 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,
/** @var string|null */
public ?string $userObjectId=null,
/** @var string|null */
public ?string $userTenant=null,
/** @var string|null */
public ?string $userTenantId=null
) {
parent::__construct($isAuthorized,$settings,$suggestedStatusCode,$suggestedResponseMessage,$reason,$customerId);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['userObjectId'])) $this->userObjectId = $o['userObjectId'];
if (isset($o['userTenant'])) $this->userTenant = $o['userTenant'];
if (isset($o['userTenantId'])) $this->userTenantId = $o['userTenantId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->userObjectId)) $o['userObjectId'] = $this->userObjectId;
if (isset($this->userTenant)) $o['userTenant'] = $this->userTenant;
if (isset($this->userTenantId)) $o['userTenantId'] = $this->userTenantId;
return empty($o) ? new class(){} : $o;
}
}
class AuthorizeUser implements IAuthorizeUser, JsonSerializable
{
public function __construct(
// @ApiMember(IsRequired=true)
/** @var string */
public string $bearerToken='',
// @ApiMember(IsRequired=true, ParameterType="path")
/** @var string */
public string $profile='',
// @ApiMember(IsRequired=true, ParameterType="path")
/** @var string */
public string $service='',
// @ApiMember(Name="X-WAAPI-CONTEXT", ParameterType="header")
/** @var string|null */
public ?string $customerContext=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['bearerToken'])) $this->bearerToken = $o['bearerToken'];
if (isset($o['profile'])) $this->profile = $o['profile'];
if (isset($o['service'])) $this->service = $o['service'];
if (isset($o['customerContext'])) $this->customerContext = $o['customerContext'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->bearerToken)) $o['bearerToken'] = $this->bearerToken;
if (isset($this->profile)) $o['profile'] = $this->profile;
if (isset($this->service)) $o['service'] = $this->service;
if (isset($this->customerContext)) $o['customerContext'] = $this->customerContext;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /authorizeuser/{Service}/{Profile} HTTP/1.1
Host: nkapi-sgepz3-auth-r1.azurewebsites.net
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<AuthorizeUser xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Norkart.Api.Authorization.ServiceModel">
<BearerToken>String</BearerToken>
<CustomerContext>String</CustomerContext>
<Profile>String</Profile>
<Service>String</Service>
</AuthorizeUser>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <AuthorizeUserResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Norkart.Api.Authorization.ServiceModel"> <CustomerId i:nil="true" /> <IsAuthorized>false</IsAuthorized> <Reason>String</Reason> <Settings> <Setting> <BooleanValue>false</BooleanValue> <DataType>String</DataType> <Name>String</Name> <StringValue>String</StringValue> </Setting> </Settings> <SuggestedResponseMessage>String</SuggestedResponseMessage> <SuggestedStatusCode>0</SuggestedStatusCode> <UserObjectId i:nil="true" /> <UserTenant>String</UserTenant> <UserTenantId>String</UserTenantId> </AuthorizeUserResponse>