Starnet.MontenegroTaxationAuthority.WebApi

<back to all web services

ReportBetPayouts

The following routes are available for this service:
POST/bets/payout
<?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;
    }
}

enum WinType : int
{
    case Regular = 0;
    case Cashback = 1;
    case Cashout = 2;
}

interface IBetEvent
{
}

class WinDto 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 string|null */
        public ?string $bet_transaction_id=null,
        /** @var string|null */
        public ?string $ticket_id=null,
        /** @var float */
        public float $win_odds=0.0,
        /** @var WinType|null */
        public ?WinType $win_type=null,
        /** @var float */
        public float $bonus=0.0,
        /** @var bool|null */
        public ?bool $cancel=null,
        /** @var RecordList<IBetEvent>|null */
        public ?RecordList $canceled_events=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['bet_transaction_id'])) $this->bet_transaction_id = $o['bet_transaction_id'];
        if (isset($o['ticket_id'])) $this->ticket_id = $o['ticket_id'];
        if (isset($o['win_odds'])) $this->win_odds = $o['win_odds'];
        if (isset($o['win_type'])) $this->win_type = JsonConverters::from('WinType', $o['win_type']);
        if (isset($o['bonus'])) $this->bonus = $o['bonus'];
        if (isset($o['cancel'])) $this->cancel = $o['cancel'];
        if (isset($o['canceled_events'])) $this->canceled_events = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['IBetEvent']), $o['canceled_events']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->bet_transaction_id)) $o['bet_transaction_id'] = $this->bet_transaction_id;
        if (isset($this->ticket_id)) $o['ticket_id'] = $this->ticket_id;
        if (isset($this->win_odds)) $o['win_odds'] = $this->win_odds;
        if (isset($this->win_type)) $o['win_type'] = JsonConverters::to('WinType', $this->win_type);
        if (isset($this->bonus)) $o['bonus'] = $this->bonus;
        if (isset($this->cancel)) $o['cancel'] = $this->cancel;
        if (isset($this->canceled_events)) $o['canceled_events'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['IBetEvent']), $this->canceled_events);
        return empty($o) ? new class(){} : $o;
    }
}

class ReportBetPayouts implements JsonSerializable
{
    public function __construct(
        /** @var RecordList<WinDto>|null */
        public ?RecordList $betPayouts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['betPayouts'])) $this->betPayouts = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['WinDto']), $o['betPayouts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->betPayouts)) $o['betPayouts'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['WinDto']), $this->betPayouts);
        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();
    }
}

PHP ReportBetPayouts DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /bets/payout HTTP/1.1 
Host: api.sbbet-prod-mnta.webhop.biz 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	betPayouts: 
	[
		{
			bet_transaction_id: String,
			ticket_id: String,
			win_odds: 0,
			win_type: 0,
			bonus: 0,
			cancel: False,
			canceled_events: 
			[
				{
					
				}
			],
			transaction_id: String,
			transaction_time: 0001-01-01,
			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/jsv
Content-Length: length

{
	errorCode: String,
	message: String,
	stackTrace: String,
	errors: 
	[
		{
			errorCode: String,
			fieldName: String,
			message: String,
			meta: 
			{
				String: String
			}
		}
	],
	meta: 
	{
		String: String
	}
}