| POST | /bets/place |
|---|
<?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 BetSource : int
{
case Landbase = 0;
case Web = 1;
}
class TransactionDtoBase implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $transaction_id=null,
/** @var DateTime */
public DateTime $transaction_time=new DateTime(),
/** @var float */
public float $transaction_amount=0.0,
/** @var string|null */
public ?string $game_name=null,
/** @var string|null */
public ?string $betting_place_id=null,
/** @var string|null */
public ?string $betting_terminal_id=null,
/** @var string|null */
public ?string $jmbg=null,
/** @var string|null */
public ?string $passport_number=null,
/** @var BetSource|null */
public ?BetSource $source=null,
/** @var string|null */
public ?string $identification_document_country=null,
/** @var string|null */
public ?string $identification_document_type=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['transaction_id'])) $this->transaction_id = $o['transaction_id'];
if (isset($o['transaction_time'])) $this->transaction_time = JsonConverters::from('DateTime', $o['transaction_time']);
if (isset($o['transaction_amount'])) $this->transaction_amount = $o['transaction_amount'];
if (isset($o['game_name'])) $this->game_name = $o['game_name'];
if (isset($o['betting_place_id'])) $this->betting_place_id = $o['betting_place_id'];
if (isset($o['betting_terminal_id'])) $this->betting_terminal_id = $o['betting_terminal_id'];
if (isset($o['jmbg'])) $this->jmbg = $o['jmbg'];
if (isset($o['passport_number'])) $this->passport_number = $o['passport_number'];
if (isset($o['source'])) $this->source = JsonConverters::from('BetSource', $o['source']);
if (isset($o['identification_document_country'])) $this->identification_document_country = $o['identification_document_country'];
if (isset($o['identification_document_type'])) $this->identification_document_type = $o['identification_document_type'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->transaction_id)) $o['transaction_id'] = $this->transaction_id;
if (isset($this->transaction_time)) $o['transaction_time'] = JsonConverters::to('DateTime', $this->transaction_time);
if (isset($this->transaction_amount)) $o['transaction_amount'] = $this->transaction_amount;
if (isset($this->game_name)) $o['game_name'] = $this->game_name;
if (isset($this->betting_place_id)) $o['betting_place_id'] = $this->betting_place_id;
if (isset($this->betting_terminal_id)) $o['betting_terminal_id'] = $this->betting_terminal_id;
if (isset($this->jmbg)) $o['jmbg'] = $this->jmbg;
if (isset($this->passport_number)) $o['passport_number'] = $this->passport_number;
if (isset($this->source)) $o['source'] = JsonConverters::to('BetSource', $this->source);
if (isset($this->identification_document_country)) $o['identification_document_country'] = $this->identification_document_country;
if (isset($this->identification_document_type)) $o['identification_document_type'] = $this->identification_document_type;
return empty($o) ? new class(){} : $o;
}
}
class TicketDto implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $sy=null,
/** @var int */
public int $nc=0,
/** @var float */
public float $ac=0.0,
/** @var RecordList<RecordList<IBetEvent>>|null */
public ?RecordList $e=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['sy'])) $this->sy = $o['sy'];
if (isset($o['nc'])) $this->nc = $o['nc'];
if (isset($o['ac'])) $this->ac = $o['ac'];
if (isset($o['e'])) $this->e = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['RecordList<IBetEvent>']), $o['e']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->sy)) $o['sy'] = $this->sy;
if (isset($this->nc)) $o['nc'] = $this->nc;
if (isset($this->ac)) $o['ac'] = $this->ac;
if (isset($this->e)) $o['e'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['RecordList<IBetEvent>']), $this->e);
return empty($o) ? new class(){} : $o;
}
}
enum BetType : int
{
case Real = 0;
case Promo = 1;
}
class BetDto extends TransactionDtoBase implements JsonSerializable
{
/**
* @param string|null $transaction_id
* @param DateTime $transaction_time
* @param float $transaction_amount
* @param string|null $game_name
* @param string|null $betting_place_id
* @param string|null $betting_terminal_id
* @param string|null $jmbg
* @param string|null $passport_number
* @param BetSource|null $source
* @param string|null $identification_document_country
* @param string|null $identification_document_type
*/
public function __construct(
?string $transaction_id=null,
DateTime $transaction_time=new DateTime(),
float $transaction_amount=0.0,
?string $game_name=null,
?string $betting_place_id=null,
?string $betting_terminal_id=null,
?string $jmbg=null,
?string $passport_number=null,
?BetSource $source=null,
?string $identification_document_country=null,
?string $identification_document_type=null,
/** @var float */
public float $min_odds=0.0,
/** @var float */
public float $max_odds=0.0,
/** @var float */
public float $min_win=0.0,
/** @var float */
public float $max_win=0.0,
/** @var float */
public float $min_bonus=0.0,
/** @var float */
public float $max_bonus=0.0,
/** @var float */
public float $max_payout=0.0,
/** @var float */
public float $promo_amount=0.0,
/** @var string|null */
public ?string $ticket_id=null,
/** @var TicketDto|null */
public ?TicketDto $ticket=null,
/** @var BetType|null */
public ?BetType $bet_type=null
) {
parent::__construct($transaction_id,$transaction_time,$transaction_amount,$game_name,$betting_place_id,$betting_terminal_id,$jmbg,$passport_number,$source,$identification_document_country,$identification_document_type);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['min_odds'])) $this->min_odds = $o['min_odds'];
if (isset($o['max_odds'])) $this->max_odds = $o['max_odds'];
if (isset($o['min_win'])) $this->min_win = $o['min_win'];
if (isset($o['max_win'])) $this->max_win = $o['max_win'];
if (isset($o['min_bonus'])) $this->min_bonus = $o['min_bonus'];
if (isset($o['max_bonus'])) $this->max_bonus = $o['max_bonus'];
if (isset($o['max_payout'])) $this->max_payout = $o['max_payout'];
if (isset($o['promo_amount'])) $this->promo_amount = $o['promo_amount'];
if (isset($o['ticket_id'])) $this->ticket_id = $o['ticket_id'];
if (isset($o['ticket'])) $this->ticket = JsonConverters::from('TicketDto', $o['ticket']);
if (isset($o['bet_type'])) $this->bet_type = JsonConverters::from('BetType', $o['bet_type']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->min_odds)) $o['min_odds'] = $this->min_odds;
if (isset($this->max_odds)) $o['max_odds'] = $this->max_odds;
if (isset($this->min_win)) $o['min_win'] = $this->min_win;
if (isset($this->max_win)) $o['max_win'] = $this->max_win;
if (isset($this->min_bonus)) $o['min_bonus'] = $this->min_bonus;
if (isset($this->max_bonus)) $o['max_bonus'] = $this->max_bonus;
if (isset($this->max_payout)) $o['max_payout'] = $this->max_payout;
if (isset($this->promo_amount)) $o['promo_amount'] = $this->promo_amount;
if (isset($this->ticket_id)) $o['ticket_id'] = $this->ticket_id;
if (isset($this->ticket)) $o['ticket'] = JsonConverters::to('TicketDto', $this->ticket);
if (isset($this->bet_type)) $o['bet_type'] = JsonConverters::to('BetType', $this->bet_type);
return empty($o) ? new class(){} : $o;
}
}
class ReportBetPlacements implements JsonSerializable
{
public function __construct(
/** @var RecordList<BetDto>|null */
public ?RecordList $betPlacements=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['betPlacements'])) $this->betPlacements = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['BetDto']), $o['betPlacements']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->betPlacements)) $o['betPlacements'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['BetDto']), $this->betPlacements);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template T
* @template array of T
*/
class RecordList extends \ArrayObject implements JsonSerializable
{
public function __construct(T ...$items) {
parent::__construct($items, \ArrayObject::STD_PROP_LIST);
}
/** @throws \Exception */
public function append($value): void {
if ($value instanceof T)
parent::append($value);
else
throw new \Exception("Can only append a T to " . __CLASS__);
}
/** @throws Exception */
public function fromMap($o): void {
foreach ($o as $item) {
$el = new T();
$el->fromMap($item);
$this->append($el);
}
}
/** @throws Exception */
public function jsonSerialize(): array {
return parent::getArrayCopy();
}
}
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 /bets/place HTTP/1.1
Host: api.sbbet-prod-mnta.webhop.biz
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"betPlacements":[{"min_odds":0,"max_odds":0,"min_win":0,"max_win":0,"min_bonus":0,"max_bonus":0,"max_payout":0,"promo_amount":0,"ticket_id":"String","ticket":{"sy":"String","nc":0,"ac":0,"e":[[{}]]},"bet_type":0,"transaction_id":"String","transaction_time":"0001-01-01T00:00:00.0000000Z","transaction_amount":0,"game_name":"String","betting_place_id":"String","betting_terminal_id":"String","jmbg":"String","passport_number":"String","source":0,"identification_document_country":"String","identification_document_type":"String"}]}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}