<?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 ResponseBase implements JsonSerializable
{
public function __construct(
/** @var bool|null */
public ?bool $Status=null,
/** @var string|null */
public ?string $Message=null,
/** @var array<string,string[]>|null */
public ?array $Errors=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['Message'])) $this->Message = $o['Message'];
if (isset($o['Errors'])) $this->Errors = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','List<String>']), $o['Errors']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->Message)) $o['Message'] = $this->Message;
if (isset($this->Errors)) $o['Errors'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','List<String>']), $this->Errors);
return empty($o) ? new class(){} : $o;
}
}
class InitialisePaymentResponse extends ResponseBase implements JsonSerializable
{
/**
* @param bool|null $Status
* @param string|null $Message
* @param array<string,string[]>|null $Errors
*/
public function __construct(
?bool $Status=null,
?string $Message=null,
?array $Errors=null,
/** @var string|null */
public ?string $TransactionId=null,
/** @var string|null */
public ?string $Signature=null,
/** @var string|null */
public ?string $Url=null
) {
parent::__construct($Status,$Message,$Errors);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['TransactionId'])) $this->TransactionId = $o['TransactionId'];
if (isset($o['Signature'])) $this->Signature = $o['Signature'];
if (isset($o['Url'])) $this->Url = $o['Url'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->TransactionId)) $o['TransactionId'] = $this->TransactionId;
if (isset($this->Signature)) $o['Signature'] = $this->Signature;
if (isset($this->Url)) $o['Url'] = $this->Url;
return empty($o) ? new class(){} : $o;
}
}
enum PaymentTypeEnum : int
{
case OneTime = 1;
case Recurring = 2;
}
enum FrequencyEnum : int
{
case Daily = 1;
case Weekly = 2;
case Monthly = 3;
case Quarterly = 4;
case Biannually = 5;
case Annually = 6;
}
class InitialisePaymentRequest implements JsonSerializable
{
public function __construct(
/** @var PaymentTypeEnum|null */
public ?PaymentTypeEnum $PaymentType=null,
/** @var string */
public string $Uuid='',
/** @var string|null */
public ?string $ReferenceNumber=null,
/** @var float */
public float $Amount=0.0,
/** @var string|null */
public ?string $Currency=null,
/** @var string|null */
public ?string $ItemName=null,
/** @var string|null */
public ?string $ItemDescription=null,
/** @var DateTime */
public DateTime $BillingDate=new DateTime(),
/** @var FrequencyEnum|null */
public ?FrequencyEnum $Frequency=null,
/** @var int */
public int $Cycles=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['PaymentType'])) $this->PaymentType = JsonConverters::from('PaymentTypeEnum', $o['PaymentType']);
if (isset($o['Uuid'])) $this->Uuid = $o['Uuid'];
if (isset($o['ReferenceNumber'])) $this->ReferenceNumber = $o['ReferenceNumber'];
if (isset($o['Amount'])) $this->Amount = $o['Amount'];
if (isset($o['Currency'])) $this->Currency = $o['Currency'];
if (isset($o['ItemName'])) $this->ItemName = $o['ItemName'];
if (isset($o['ItemDescription'])) $this->ItemDescription = $o['ItemDescription'];
if (isset($o['BillingDate'])) $this->BillingDate = JsonConverters::from('DateTime', $o['BillingDate']);
if (isset($o['Frequency'])) $this->Frequency = JsonConverters::from('FrequencyEnum', $o['Frequency']);
if (isset($o['Cycles'])) $this->Cycles = $o['Cycles'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->PaymentType)) $o['PaymentType'] = JsonConverters::to('PaymentTypeEnum', $this->PaymentType);
if (isset($this->Uuid)) $o['Uuid'] = $this->Uuid;
if (isset($this->ReferenceNumber)) $o['ReferenceNumber'] = $this->ReferenceNumber;
if (isset($this->Amount)) $o['Amount'] = $this->Amount;
if (isset($this->Currency)) $o['Currency'] = $this->Currency;
if (isset($this->ItemName)) $o['ItemName'] = $this->ItemName;
if (isset($this->ItemDescription)) $o['ItemDescription'] = $this->ItemDescription;
if (isset($this->BillingDate)) $o['BillingDate'] = JsonConverters::to('DateTime', $this->BillingDate);
if (isset($this->Frequency)) $o['Frequency'] = JsonConverters::to('FrequencyEnum', $this->Frequency);
if (isset($this->Cycles)) $o['Cycles'] = $this->Cycles;
return empty($o) ? new class(){} : $o;
}
}
PHP InitialisePaymentRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsv/reply/InitialisePaymentRequest HTTP/1.1
Host: duengageapi.uat.scadsoftware.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
PaymentType: OneTime,
Uuid: 00000000000000000000000000000000,
ReferenceNumber: String,
Amount: 0,
Currency: String,
ItemName: String,
ItemDescription: String,
BillingDate: 0001-01-01,
Frequency: Daily,
Cycles: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
TransactionId: String,
Signature: String,
Url: String,
Status: False,
Message: String,
Errors:
{
String:
[
String
]
}
}