POST | /v1/login | Process GAS Authentication |
---|
<?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};
enum LoginStatus : string
{
case Authenticated = 'Authenticated';
case NotAuthenticated = 'NotAuthenticated';
case Error = 'Error';
}
class LoginResponse implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $RedirectUrl=null,
/** @var bool|null */
public ?bool $IsAuthenticated=null,
/** @var string|null */
public ?string $UserToken=null,
/** @var string|null */
public ?string $UserId=null,
/** @var array<int>|null */
public ?array $UserRoleId=null,
/** @var string|null */
public ?string $DefaultRetailer=null,
/** @var LoginStatus|null */
public ?LoginStatus $LoginStatus=null,
/** @var string|null */
public ?string $UserRoleRedirect=null,
/** @var string|null */
public ?string $DefaultVehicleType=null,
/** @var array<string>|null */
public ?array $EntitlementGroup=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['RedirectUrl'])) $this->RedirectUrl = $o['RedirectUrl'];
if (isset($o['IsAuthenticated'])) $this->IsAuthenticated = $o['IsAuthenticated'];
if (isset($o['UserToken'])) $this->UserToken = $o['UserToken'];
if (isset($o['UserId'])) $this->UserId = $o['UserId'];
if (isset($o['UserRoleId'])) $this->UserRoleId = JsonConverters::fromArray('int', $o['UserRoleId']);
if (isset($o['DefaultRetailer'])) $this->DefaultRetailer = $o['DefaultRetailer'];
if (isset($o['LoginStatus'])) $this->LoginStatus = JsonConverters::from('LoginStatus', $o['LoginStatus']);
if (isset($o['UserRoleRedirect'])) $this->UserRoleRedirect = $o['UserRoleRedirect'];
if (isset($o['DefaultVehicleType'])) $this->DefaultVehicleType = $o['DefaultVehicleType'];
if (isset($o['EntitlementGroup'])) $this->EntitlementGroup = JsonConverters::fromArray('string', $o['EntitlementGroup']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->RedirectUrl)) $o['RedirectUrl'] = $this->RedirectUrl;
if (isset($this->IsAuthenticated)) $o['IsAuthenticated'] = $this->IsAuthenticated;
if (isset($this->UserToken)) $o['UserToken'] = $this->UserToken;
if (isset($this->UserId)) $o['UserId'] = $this->UserId;
if (isset($this->UserRoleId)) $o['UserRoleId'] = JsonConverters::toArray('int', $this->UserRoleId);
if (isset($this->DefaultRetailer)) $o['DefaultRetailer'] = $this->DefaultRetailer;
if (isset($this->LoginStatus)) $o['LoginStatus'] = JsonConverters::to('LoginStatus', $this->LoginStatus);
if (isset($this->UserRoleRedirect)) $o['UserRoleRedirect'] = $this->UserRoleRedirect;
if (isset($this->DefaultVehicleType)) $o['DefaultVehicleType'] = $this->DefaultVehicleType;
if (isset($this->EntitlementGroup)) $o['EntitlementGroup'] = JsonConverters::toArray('string', $this->EntitlementGroup);
return empty($o) ? new class(){} : $o;
}
}
class LoginRequest implements IPost, JsonSerializable
{
public function __construct(
/** @description GAS AuthCode */
// @ApiMember(Description="GAS AuthCode")
/** @var string|null */
public ?string $AuthCode=null,
/** @description GAS ErrorCode */
// @ApiMember(Description="GAS ErrorCode")
/** @var string|null */
public ?string $ErrorCode=null,
/** @description Client Id */
// @ApiMember(Description="Client Id")
/** @var string|null */
public ?string $ClientId=null,
/** @description Secret */
// @ApiMember(Description="Secret")
/** @var string|null */
public ?string $Secret=null,
/** @description Callback Url */
// @ApiMember(Description="Callback Url")
/** @var string|null */
public ?string $CallbackUrl=null,
/** @description Redirect Url */
// @ApiMember(Description="Redirect Url")
/** @var string|null */
public ?string $RedirectUrl=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['AuthCode'])) $this->AuthCode = $o['AuthCode'];
if (isset($o['ErrorCode'])) $this->ErrorCode = $o['ErrorCode'];
if (isset($o['ClientId'])) $this->ClientId = $o['ClientId'];
if (isset($o['Secret'])) $this->Secret = $o['Secret'];
if (isset($o['CallbackUrl'])) $this->CallbackUrl = $o['CallbackUrl'];
if (isset($o['RedirectUrl'])) $this->RedirectUrl = $o['RedirectUrl'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->AuthCode)) $o['AuthCode'] = $this->AuthCode;
if (isset($this->ErrorCode)) $o['ErrorCode'] = $this->ErrorCode;
if (isset($this->ClientId)) $o['ClientId'] = $this->ClientId;
if (isset($this->Secret)) $o['Secret'] = $this->Secret;
if (isset($this->CallbackUrl)) $o['CallbackUrl'] = $this->CallbackUrl;
if (isset($this->RedirectUrl)) $o['RedirectUrl'] = $this->RedirectUrl;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /v1/login HTTP/1.1
Host: prod-api-auth-mb-dhc.rapp-customers.co.uk
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"AuthCode":"String","ErrorCode":"String","ClientId":"String","Secret":"String","CallbackUrl":"String","RedirectUrl":"String"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"RedirectUrl":"String","IsAuthenticated":false,"UserToken":"String","UserId":"String","UserRoleId":[0],"DefaultRetailer":"String","LoginStatus":"Authenticated","UserRoleRedirect":"String","DefaultVehicleType":"String","EntitlementGroup":["String"]}