| GET | /checkaccount | Check account limit and remaining account amount |
|---|
<?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, 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=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApiKey'])) $this->ApiKey = $o['ApiKey'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApiKey)) $o['ApiKey'] = $this->ApiKey;
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
) {
}
/** @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'];
}
/** @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;
return empty($o) ? new class(){} : $o;
}
}
class CheckAccountResponse extends ApiServiceResponse implements JsonSerializable
{
/**
* @param string $Description
* @param string $Heading
* @param bool|null $WasSuccessful
*/
public function __construct(
string $Description='',
string $Heading='',
?bool $WasSuccessful=null,
/** @description The total monthly limit for account payments, will be negative if there is no limit */
// @ApiMember(Description="The total monthly limit for account payments, will be negative if there is no limit")
/** @var float */
public float $AccountLimit=0.0,
/** @description The amount that can still be used this month, will be negative if there is no account limit */
// @ApiMember(Description="The amount that can still be used this month, will be negative if there is no account limit")
/** @var float */
public float $AccountRemaining=0.0,
/** @description Shows if this account is allowed to place real orders or quotes */
// @ApiMember(Description="Shows if this account is allowed to place real orders or quotes")
/** @var bool|null */
public ?bool $AllowDataProcessing=null
) {
parent::__construct($Description,$Heading,$WasSuccessful);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['AccountLimit'])) $this->AccountLimit = $o['AccountLimit'];
if (isset($o['AccountRemaining'])) $this->AccountRemaining = $o['AccountRemaining'];
if (isset($o['AllowDataProcessing'])) $this->AllowDataProcessing = $o['AllowDataProcessing'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->AccountLimit)) $o['AccountLimit'] = $this->AccountLimit;
if (isset($this->AccountRemaining)) $o['AccountRemaining'] = $this->AccountRemaining;
if (isset($this->AllowDataProcessing)) $o['AllowDataProcessing'] = $this->AllowDataProcessing;
return empty($o) ? new class(){} : $o;
}
}
class CheckAccount extends ApiServiceRequest implements ILogRequest, JsonSerializable
{
/**
* @param string $ApiKey
*/
public function __construct(
string $ApiKey=''
) {
parent::__construct($ApiKey);
}
/** @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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /checkaccount HTTP/1.1 Host: api.1fetch.co.za Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"AccountLimit":0,"AccountRemaining":0,"AllowDataProcessing":false,"Description":"String","Heading":"String","WasSuccessful":false}