GET,POST | /auth/{provider} | ||
---|---|---|---|
GET,POST | /auth |
<?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 AuthenticateResponse 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 $displayName=null,
// @DataMember(Order=5)
/** @var string|null */
public ?string $referrerUrl=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $bearerToken=null,
// @DataMember(Order=7)
/** @var string|null */
public ?string $refreshToken=null,
// @DataMember(Order=8)
/** @var DateTime|null */
public ?DateTime $refreshTokenExpiry=null,
// @DataMember(Order=9)
/** @var string|null */
public ?string $profileUrl=null,
// @DataMember(Order=10)
/** @var array<string>|null */
public ?array $roles=null,
// @DataMember(Order=11)
/** @var array<string>|null */
public ?array $permissions=null,
// @DataMember(Order=12)
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null,
// @DataMember(Order=13)
/** @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['displayName'])) $this->displayName = $o['displayName'];
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['profileUrl'])) $this->profileUrl = $o['profileUrl'];
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->displayName)) $o['displayName'] = $this->displayName;
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->profileUrl)) $o['profileUrl'] = $this->profileUrl;
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 In */
// @Api(Description="Sign In")
// @DataContract
class Authenticate implements IPost, IMeta, JsonSerializable
{
public function __construct(
/** @description AuthProvider, e.g. credentials */
// @DataMember(Order=1)
/** @var string|null */
public ?string $provider=null,
// @DataMember(Order=2)
/** @var string|null */
public ?string $userName=null,
// @DataMember(Order=3)
/** @var string|null */
public ?string $password=null,
// @DataMember(Order=4)
/** @var bool|null */
public ?bool $rememberMe=null,
// @DataMember(Order=5)
/** @var string|null */
public ?string $accessToken=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $accessTokenSecret=null,
// @DataMember(Order=7)
/** @var string|null */
public ?string $returnUrl=null,
// @DataMember(Order=8)
/** @var string|null */
public ?string $errorView=null,
// @DataMember(Order=9)
/** @var array<string,string>|null */
public ?array $meta=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['provider'])) $this->provider = $o['provider'];
if (isset($o['userName'])) $this->userName = $o['userName'];
if (isset($o['password'])) $this->password = $o['password'];
if (isset($o['rememberMe'])) $this->rememberMe = $o['rememberMe'];
if (isset($o['accessToken'])) $this->accessToken = $o['accessToken'];
if (isset($o['accessTokenSecret'])) $this->accessTokenSecret = $o['accessTokenSecret'];
if (isset($o['returnUrl'])) $this->returnUrl = $o['returnUrl'];
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->provider)) $o['provider'] = $this->provider;
if (isset($this->userName)) $o['userName'] = $this->userName;
if (isset($this->password)) $o['password'] = $this->password;
if (isset($this->rememberMe)) $o['rememberMe'] = $this->rememberMe;
if (isset($this->accessToken)) $o['accessToken'] = $this->accessToken;
if (isset($this->accessTokenSecret)) $o['accessTokenSecret'] = $this->accessTokenSecret;
if (isset($this->returnUrl)) $o['returnUrl'] = $this->returnUrl;
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;
}
}
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 /auth/{provider} HTTP/1.1
Host: taxfiling.pwc.de
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<Authenticate xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
<provider>String</provider>
<UserName>String</UserName>
<Password>String</Password>
<RememberMe>false</RememberMe>
<AccessToken>String</AccessToken>
<AccessTokenSecret>String</AccessTokenSecret>
<ReturnUrl>String</ReturnUrl>
<ErrorView>String</ErrorView>
<Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:KeyValueOfstringstring>
<d2p1:Key>String</d2p1:Key>
<d2p1:Value>String</d2p1:Value>
</d2p1:KeyValueOfstringstring>
</Meta>
</Authenticate>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <AuthenticateResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types"> <UserId>String</UserId> <SessionId>String</SessionId> <UserName>String</UserName> <DisplayName>String</DisplayName> <ReferrerUrl>String</ReferrerUrl> <BearerToken>String</BearerToken> <RefreshToken>String</RefreshToken> <RefreshTokenExpiry>0001-01-01T00:00:00</RefreshTokenExpiry> <ProfileUrl>String</ProfileUrl> <Roles xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d2p1:string>String</d2p1:string> </Roles> <Permissions xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d2p1:string>String</d2p1:string> </Permissions> <ResponseStatus> <ErrorCode>String</ErrorCode> <Message>String</Message> <StackTrace>String</StackTrace> <Errors> <ResponseError> <ErrorCode>String</ErrorCode> <FieldName>String</FieldName> <Message>String</Message> <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d5p1:KeyValueOfstringstring> <d5p1:Key>String</d5p1:Key> <d5p1:Value>String</d5p1:Value> </d5p1:KeyValueOfstringstring> </Meta> </ResponseError> </Errors> <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d3p1:KeyValueOfstringstring> <d3p1:Key>String</d3p1:Key> <d3p1:Value>String</d3p1:Value> </d3p1:KeyValueOfstringstring> </Meta> </ResponseStatus> <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d2p1:KeyValueOfstringstring> <d2p1:Key>String</d2p1:Key> <d2p1:Value>String</d2p1:Value> </d2p1:KeyValueOfstringstring> </Meta> </AuthenticateResponse>