POST | /api/SubmitPOSTransaction |
---|
<?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 BaseRequest implements JsonSerializable
{
public function __construct(
/** @description This is your AIM API Key provided by Tri-Tech */
// @DataMember
// @ApiMember(DataType="string", Description="This is your AIM API Key provided by Tri-Tech", IsRequired=true, Name="ApiKey", ParameterType="header")
/** @var string */
public string $ApiKey='',
// @DataMember
// @ApiMember(DataType="string", Name="OAuthToken", ParameterType="header")
/** @var string|null */
public ?string $OAuthToken=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApiKey'])) $this->ApiKey = $o['ApiKey'];
if (isset($o['OAuthToken'])) $this->OAuthToken = $o['OAuthToken'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApiKey)) $o['ApiKey'] = $this->ApiKey;
if (isset($this->OAuthToken)) $o['OAuthToken'] = $this->OAuthToken;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class BaseSecureRequest extends BaseRequest implements JsonSerializable
{
/**
* @param string $ApiKey
* @param string|null $OAuthToken
*/
public function __construct(
string $ApiKey='',
?string $OAuthToken=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="Token", ParameterType="Header")
/** @var string|null */
public ?string $Token=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="DeviceId", ParameterType="Header")
/** @var string|null */
public ?string $DeviceId=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", IsRequired=true, Name="AppId", ParameterType="Header")
/** @var string */
public string $AppId=''
) {
parent::__construct($ApiKey,$OAuthToken);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Token'])) $this->Token = $o['Token'];
if (isset($o['DeviceId'])) $this->DeviceId = $o['DeviceId'];
if (isset($o['AppId'])) $this->AppId = $o['AppId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Token)) $o['Token'] = $this->Token;
if (isset($this->DeviceId)) $o['DeviceId'] = $this->DeviceId;
if (isset($this->AppId)) $o['AppId'] = $this->AppId;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class BaseResponseResult implements JsonSerializable
{
public function __construct(
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="StatusCode", ParameterType="body")
/** @var string|null */
public ?string $StatusCode=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="Login", ParameterType="body")
/** @var string|null */
public ?string $Login=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorCode", ParameterType="body")
/** @var string|null */
public ?string $ErrorCode=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorDisplayText", ParameterType="body")
/** @var string|null */
public ?string $ErrorDisplayText=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", Name="ErrorMessage", ParameterType="body")
/** @var string|null */
public ?string $ErrorMessage=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="DomainName", ParameterType="body")
/** @var string|null */
public ?string $DomainName=null,
/** @description */
// @DataMember
// @ApiMember(DataType="string", Description="", ExcludeInSchema=true, Name="IPAddress", ParameterType="body")
/** @var string|null */
public ?string $IpAddress=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['StatusCode'])) $this->StatusCode = $o['StatusCode'];
if (isset($o['Login'])) $this->Login = $o['Login'];
if (isset($o['ErrorCode'])) $this->ErrorCode = $o['ErrorCode'];
if (isset($o['ErrorDisplayText'])) $this->ErrorDisplayText = $o['ErrorDisplayText'];
if (isset($o['ErrorMessage'])) $this->ErrorMessage = $o['ErrorMessage'];
if (isset($o['DomainName'])) $this->DomainName = $o['DomainName'];
if (isset($o['IpAddress'])) $this->IpAddress = $o['IpAddress'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->StatusCode)) $o['StatusCode'] = $this->StatusCode;
if (isset($this->Login)) $o['Login'] = $this->Login;
if (isset($this->ErrorCode)) $o['ErrorCode'] = $this->ErrorCode;
if (isset($this->ErrorDisplayText)) $o['ErrorDisplayText'] = $this->ErrorDisplayText;
if (isset($this->ErrorMessage)) $o['ErrorMessage'] = $this->ErrorMessage;
if (isset($this->DomainName)) $o['DomainName'] = $this->DomainName;
if (isset($this->IpAddress)) $o['IpAddress'] = $this->IpAddress;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class BaseResponse implements JsonSerializable
{
public function __construct(
/** @description */
// @DataMember
// @ApiMember(DataType="BaseResponseResult", Description="", Name="Status", ParameterType="body")
/** @var BaseResponseResult|null */
public ?BaseResponseResult $Status=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Status'])) $this->Status = JsonConverters::from('BaseResponseResult', $o['Status']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Status)) $o['Status'] = JsonConverters::to('BaseResponseResult', $this->Status);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class ExceptionInfo implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var string|null */
public ?string $Barcode=null,
// @DataMember
/** @var string|null */
public ?string $Description=null,
// @DataMember
/** @var string|null */
public ?string $Base64Image=null,
// @DataMember
/** @var int */
public int $Category=0,
// @DataMember
/** @var int|null */
public ?int $SubCategory=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Barcode'])) $this->Barcode = $o['Barcode'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Base64Image'])) $this->Base64Image = $o['Base64Image'];
if (isset($o['Category'])) $this->Category = $o['Category'];
if (isset($o['SubCategory'])) $this->SubCategory = $o['SubCategory'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Barcode)) $o['Barcode'] = $this->Barcode;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Base64Image)) $o['Base64Image'] = $this->Base64Image;
if (isset($this->Category)) $o['Category'] = $this->Category;
if (isset($this->SubCategory)) $o['SubCategory'] = $this->SubCategory;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class PosLineItem implements IScanItem, JsonSerializable
{
public function __construct(
// @DataMember
/** @var int|null */
public ?int $SkuPk=null,
// @DataMember
/** @var int|null */
public ?int $SasPk=null,
// @DataMember
/** @var string|null */
public ?string $Sku=null,
// @DataMember
/** @var string|null */
public ?string $Serial=null,
// @DataMember
/** @var float */
public float $Quantity=0.0,
// @DataMember
/** @var ExceptionInfo|null */
public ?ExceptionInfo $ExceptionInfo=null,
// @DataMember
/** @var float|null */
public ?float $Discount=null,
// @DataMember
/** @var int|null */
public ?int $NicsCat=null,
// @DataMember
/** @var int|null */
public ?int $NicsSub=null,
// @DataMember
/** @var float|null */
public ?float $PriceOverride=null,
// @DataMember
/** @var bool|null */
public ?bool $AllowPriceOverrideToIgnoreMinPrice=null,
// @DataMember
/** @var string|null */
public ?string $Notes=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['SkuPk'])) $this->SkuPk = $o['SkuPk'];
if (isset($o['SasPk'])) $this->SasPk = $o['SasPk'];
if (isset($o['Sku'])) $this->Sku = $o['Sku'];
if (isset($o['Serial'])) $this->Serial = $o['Serial'];
if (isset($o['Quantity'])) $this->Quantity = $o['Quantity'];
if (isset($o['ExceptionInfo'])) $this->ExceptionInfo = JsonConverters::from('ExceptionInfo', $o['ExceptionInfo']);
if (isset($o['Discount'])) $this->Discount = $o['Discount'];
if (isset($o['NicsCat'])) $this->NicsCat = $o['NicsCat'];
if (isset($o['NicsSub'])) $this->NicsSub = $o['NicsSub'];
if (isset($o['PriceOverride'])) $this->PriceOverride = $o['PriceOverride'];
if (isset($o['AllowPriceOverrideToIgnoreMinPrice'])) $this->AllowPriceOverrideToIgnoreMinPrice = $o['AllowPriceOverrideToIgnoreMinPrice'];
if (isset($o['Notes'])) $this->Notes = $o['Notes'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->SkuPk)) $o['SkuPk'] = $this->SkuPk;
if (isset($this->SasPk)) $o['SasPk'] = $this->SasPk;
if (isset($this->Sku)) $o['Sku'] = $this->Sku;
if (isset($this->Serial)) $o['Serial'] = $this->Serial;
if (isset($this->Quantity)) $o['Quantity'] = $this->Quantity;
if (isset($this->ExceptionInfo)) $o['ExceptionInfo'] = JsonConverters::to('ExceptionInfo', $this->ExceptionInfo);
if (isset($this->Discount)) $o['Discount'] = $this->Discount;
if (isset($this->NicsCat)) $o['NicsCat'] = $this->NicsCat;
if (isset($this->NicsSub)) $o['NicsSub'] = $this->NicsSub;
if (isset($this->PriceOverride)) $o['PriceOverride'] = $this->PriceOverride;
if (isset($this->AllowPriceOverrideToIgnoreMinPrice)) $o['AllowPriceOverrideToIgnoreMinPrice'] = $this->AllowPriceOverrideToIgnoreMinPrice;
if (isset($this->Notes)) $o['Notes'] = $this->Notes;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class PosResponseItem extends PosLineItem implements JsonSerializable
{
/**
* @param int|null $SkuPk
* @param int|null $SasPk
* @param string|null $Sku
* @param string|null $Serial
* @param float $Quantity
* @param ExceptionInfo|null $ExceptionInfo
* @param float|null $Discount
* @param int|null $NicsCat
* @param int|null $NicsSub
* @param float|null $PriceOverride
* @param bool|null $AllowPriceOverrideToIgnoreMinPrice
* @param string|null $Notes
*/
public function __construct(
?int $SkuPk=null,
?int $SasPk=null,
?string $Sku=null,
?string $Serial=null,
float $Quantity=0.0,
?ExceptionInfo $ExceptionInfo=null,
?float $Discount=null,
?int $NicsCat=null,
?int $NicsSub=null,
?float $PriceOverride=null,
?bool $AllowPriceOverrideToIgnoreMinPrice=null,
?string $Notes=null,
// @DataMember
/** @var float */
public float $PriceEach=0.0,
// @DataMember
/** @var float */
public float $Price=0.0,
// @DataMember
/** @var bool|null */
public ?bool $Discountable=null,
// @DataMember
/** @var string|null */
public ?string $ErrorMessage=null
) {
parent::__construct($SkuPk,$SasPk,$Sku,$Serial,$Quantity,$ExceptionInfo,$Discount,$NicsCat,$NicsSub,$PriceOverride,$AllowPriceOverrideToIgnoreMinPrice,$Notes);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['PriceEach'])) $this->PriceEach = $o['PriceEach'];
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['Discountable'])) $this->Discountable = $o['Discountable'];
if (isset($o['ErrorMessage'])) $this->ErrorMessage = $o['ErrorMessage'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->PriceEach)) $o['PriceEach'] = $this->PriceEach;
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->Discountable)) $o['Discountable'] = $this->Discountable;
if (isset($this->ErrorMessage)) $o['ErrorMessage'] = $this->ErrorMessage;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class SubmitPOSTransactionResponse extends BaseResponse implements JsonSerializable
{
/**
* @param BaseResponseResult|null $Status
*/
public function __construct(
?BaseResponseResult $Status=null,
// @DataMember
/** @var string|null */
public ?string $RefNumber=null,
// @DataMember
/** @var array<PosResponseItem>|null */
public ?array $ErrorItems=null
) {
parent::__construct($Status);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['RefNumber'])) $this->RefNumber = $o['RefNumber'];
if (isset($o['ErrorItems'])) $this->ErrorItems = JsonConverters::fromArray('PosResponseItem', $o['ErrorItems']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->RefNumber)) $o['RefNumber'] = $this->RefNumber;
if (isset($this->ErrorItems)) $o['ErrorItems'] = JsonConverters::toArray('PosResponseItem', $this->ErrorItems);
return empty($o) ? new class(){} : $o;
}
}
/** @description In development, not yet for public use. */
// @DataContract
class SubmitPOSTransactionRequest extends BaseSecureRequest implements JsonSerializable
{
/**
* @param string $ApiKey
* @param string|null $OAuthToken
* @param string|null $Token
* @param string|null $DeviceId
* @param string $AppId
*/
public function __construct(
string $ApiKey='',
?string $OAuthToken=null,
?string $Token=null,
?string $DeviceId=null,
string $AppId='',
// @DataMember
/** @var int|null */
public ?int $Acct=null,
// @DataMember
/** @var int|null */
public ?int $LocId=null,
// @DataMember
/** @var int|null */
public ?int $TaxId=null,
// @DataMember
/** @var array<PosLineItem>|null */
public ?array $Items=null,
/** @description Can be CARD, CARD_DEVICE, CASH, CHARGE, SUSPEND, ONFILE, or OTHER */
// @DataMember
// @ApiMember(DataType="string", Description="Can be CARD, CARD_DEVICE, CASH, CHARGE, SUSPEND, ONFILE, or OTHER", Name="TenderType", ParameterType="query")
/** @var string|null */
public ?string $TenderType=null,
/** @description Only applicable for Tender Type of OTHER. Send the Payment Category # */
// @DataMember
// @ApiMember(DataType="string", Description="Only applicable for Tender Type of OTHER. Send the Payment Category #", Name="OtherTenderCategory", ParameterType="query")
/** @var int|null */
public ?int $OtherTenderCategory=null,
// @DataMember
/** @var string|null */
public ?string $CardToken=null,
// @DataMember
/** @var string|null */
public ?string $CardExpiration=null,
// @DataMember
/** @var int|null */
public ?int $TokenPk=null,
// @DataMember
/** @var bool|null */
public ?bool $SaveCard=null,
// @DataMember
/** @var string|null */
public ?string $PONumber=null,
/** @description Can be INVOICE, PROPOSAL, APPROVAL, ORDER, or LOANER. Defaults to INVOICE is not sent. */
// @DataMember
// @ApiMember(DataType="string", Description="Can be INVOICE, PROPOSAL, APPROVAL, ORDER, or LOANER. Defaults to INVOICE is not sent.", Name="TransactionMode", ParameterType="query")
/** @var string|null */
public ?string $TransactionMode=null,
/** @description Only valid for Approvals and Orders. */
// @DataMember
// @ApiMember(DataType="decimal", Description="Only valid for Approvals and Orders.", Name="Deposit", ParameterType="query")
/** @var float */
public float $Deposit=0.0,
// @DataMember
/** @var string|null */
public ?string $Notes=null,
/** @description Do Not Send This Parameter */
// @DataMember
// @ApiMember(Description="Do Not Send This Parameter", Name="OnlineContractRef", ParameterType="query")
/** @var string|null */
public ?string $OnlineContractRef=null,
// @DataMember
/** @var int|null */
public ?int $ShipId=null,
// @DataMember
/** @var string|null */
public ?string $CardTerminalId=null
) {
parent::__construct($ApiKey,$OAuthToken,$Token,$DeviceId,$AppId);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Acct'])) $this->Acct = $o['Acct'];
if (isset($o['LocId'])) $this->LocId = $o['LocId'];
if (isset($o['TaxId'])) $this->TaxId = $o['TaxId'];
if (isset($o['Items'])) $this->Items = JsonConverters::fromArray('PosLineItem', $o['Items']);
if (isset($o['TenderType'])) $this->TenderType = $o['TenderType'];
if (isset($o['OtherTenderCategory'])) $this->OtherTenderCategory = $o['OtherTenderCategory'];
if (isset($o['CardToken'])) $this->CardToken = $o['CardToken'];
if (isset($o['CardExpiration'])) $this->CardExpiration = $o['CardExpiration'];
if (isset($o['TokenPk'])) $this->TokenPk = $o['TokenPk'];
if (isset($o['SaveCard'])) $this->SaveCard = $o['SaveCard'];
if (isset($o['PONumber'])) $this->PONumber = $o['PONumber'];
if (isset($o['TransactionMode'])) $this->TransactionMode = $o['TransactionMode'];
if (isset($o['Deposit'])) $this->Deposit = $o['Deposit'];
if (isset($o['Notes'])) $this->Notes = $o['Notes'];
if (isset($o['OnlineContractRef'])) $this->OnlineContractRef = $o['OnlineContractRef'];
if (isset($o['ShipId'])) $this->ShipId = $o['ShipId'];
if (isset($o['CardTerminalId'])) $this->CardTerminalId = $o['CardTerminalId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Acct)) $o['Acct'] = $this->Acct;
if (isset($this->LocId)) $o['LocId'] = $this->LocId;
if (isset($this->TaxId)) $o['TaxId'] = $this->TaxId;
if (isset($this->Items)) $o['Items'] = JsonConverters::toArray('PosLineItem', $this->Items);
if (isset($this->TenderType)) $o['TenderType'] = $this->TenderType;
if (isset($this->OtherTenderCategory)) $o['OtherTenderCategory'] = $this->OtherTenderCategory;
if (isset($this->CardToken)) $o['CardToken'] = $this->CardToken;
if (isset($this->CardExpiration)) $o['CardExpiration'] = $this->CardExpiration;
if (isset($this->TokenPk)) $o['TokenPk'] = $this->TokenPk;
if (isset($this->SaveCard)) $o['SaveCard'] = $this->SaveCard;
if (isset($this->PONumber)) $o['PONumber'] = $this->PONumber;
if (isset($this->TransactionMode)) $o['TransactionMode'] = $this->TransactionMode;
if (isset($this->Deposit)) $o['Deposit'] = $this->Deposit;
if (isset($this->Notes)) $o['Notes'] = $this->Notes;
if (isset($this->OnlineContractRef)) $o['OnlineContractRef'] = $this->OnlineContractRef;
if (isset($this->ShipId)) $o['ShipId'] = $this->ShipId;
if (isset($this->CardTerminalId)) $o['CardTerminalId'] = $this->CardTerminalId;
return empty($o) ? new class(){} : $o;
}
}
PHP SubmitPOSTransactionRequest DTOs
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.
POST /api/SubmitPOSTransaction HTTP/1.1
Host: active-ewebservice.biz
Accept: application/json
Content-Type: application/json
Content-Length: length
{"Acct":0,"LocId":0,"TaxId":0,"Items":[{"SkuPk":0,"SasPk":0,"Sku":"String","Serial":"String","Quantity":0,"ExceptionInfo":{"Barcode":"String","Description":"String","Base64Image":"String","Category":0,"SubCategory":0},"Discount":0,"NicsCat":0,"NicsSub":0,"PriceOverride":0,"AllowPriceOverrideToIgnoreMinPrice":false,"Notes":"String"}],"TenderType":"String","OtherTenderCategory":0,"CardToken":"String","CardExpiration":"String","TokenPk":0,"SaveCard":false,"PONumber":"String","TransactionMode":"String","Deposit":0,"Notes":"String","OnlineContractRef":"String","ShipId":0,"CardTerminalId":"String","Token":"String","DeviceId":"String","AppId":"String","ApiKey":"String","OAuthToken":"String"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"RefNumber":"String","ErrorItems":[{"PriceEach":0,"Price":0,"Discountable":false,"ErrorMessage":"String","SkuPk":0,"SasPk":0,"Sku":"String","Serial":"String","Quantity":0,"ExceptionInfo":{"Barcode":"String","Description":"String","Base64Image":"String","Category":0,"SubCategory":0},"Discount":0,"NicsCat":0,"NicsSub":0,"PriceOverride":0,"AllowPriceOverrideToIgnoreMinPrice":false,"Notes":"String"}],"Status":{"StatusCode":"String","Login":"String","ErrorCode":"String","ErrorDisplayText":"String","ErrorMessage":"String","DomainName":"String","IpAddress":"String"}}