Greyhounds.WebApi

<back to all web services

GetRace

The following routes are available for this service:
All Verbs/rounds/race
<?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 Pool implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var string|null */
        public ?string $name=null,
        /** @var float */
        public float $coefficient=0.0,
        /** @var float */
        public float $rtp=0.0,
        /** @var float */
        public float $threshold=0.0,
        /** @var float */
        public float $balance=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['coefficient'])) $this->coefficient = $o['coefficient'];
        if (isset($o['rtp'])) $this->rtp = $o['rtp'];
        if (isset($o['threshold'])) $this->threshold = $o['threshold'];
        if (isset($o['balance'])) $this->balance = $o['balance'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->coefficient)) $o['coefficient'] = $this->coefficient;
        if (isset($this->rtp)) $o['rtp'] = $this->rtp;
        if (isset($this->threshold)) $o['threshold'] = $this->threshold;
        if (isset($this->balance)) $o['balance'] = $this->balance;
        return empty($o) ? new class(){} : $o;
    }
}

class RaceOutcomeRecap implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var float */
        public float $coef=0.0,
        /** @var int */
        public int $winCount=0,
        /** @var float */
        public float $win=0.0,
        /** @var bool|null */
        public ?bool $isWin=null,
        /** @var string|null */
        public ?string $results=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['coef'])) $this->coef = $o['coef'];
        if (isset($o['winCount'])) $this->winCount = $o['winCount'];
        if (isset($o['win'])) $this->win = $o['win'];
        if (isset($o['isWin'])) $this->isWin = $o['isWin'];
        if (isset($o['results'])) $this->results = $o['results'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->coef)) $o['coef'] = $this->coef;
        if (isset($this->winCount)) $o['winCount'] = $this->winCount;
        if (isset($this->win)) $o['win'] = $this->win;
        if (isset($this->isWin)) $o['isWin'] = $this->isWin;
        if (isset($this->results)) $o['results'] = $this->results;
        return empty($o) ? new class(){} : $o;
    }
}

class RoundOutcome implements JsonSerializable
{
    public function __construct(
        /** @var array<RaceOutcomeRecap>|null */
        public ?array $raceOutcomeRecaps=null,
        /** @var float */
        public float $stake=0.0,
        /** @var float */
        public float $winnings=0.0,
        /** @var float */
        public float $balance=0.0,
        /** @var float */
        public float $returnToPlayer=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['raceOutcomeRecaps'])) $this->raceOutcomeRecaps = JsonConverters::fromArray('RaceOutcomeRecap', $o['raceOutcomeRecaps']);
        if (isset($o['stake'])) $this->stake = $o['stake'];
        if (isset($o['winnings'])) $this->winnings = $o['winnings'];
        if (isset($o['balance'])) $this->balance = $o['balance'];
        if (isset($o['returnToPlayer'])) $this->returnToPlayer = $o['returnToPlayer'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->raceOutcomeRecaps)) $o['raceOutcomeRecaps'] = JsonConverters::toArray('RaceOutcomeRecap', $this->raceOutcomeRecaps);
        if (isset($this->stake)) $o['stake'] = $this->stake;
        if (isset($this->winnings)) $o['winnings'] = $this->winnings;
        if (isset($this->balance)) $o['balance'] = $this->balance;
        if (isset($this->returnToPlayer)) $o['returnToPlayer'] = $this->returnToPlayer;
        return empty($o) ? new class(){} : $o;
    }
}

class JackpotInfo implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $isGiven=null,
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $slipId=null,
        /** @var string|null */
        public ?string $jpId=null,
        /** @var float */
        public float $amount=0.0,
        /** @var string|null */
        public ?string $locationId=null,
        /** @var string|null */
        public ?string $locationName=null,
        /** @var string|null */
        public ?string $addressLine=null,
        /** @var float */
        public float $amountAccumulated=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['isGiven'])) $this->isGiven = $o['isGiven'];
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['slipId'])) $this->slipId = $o['slipId'];
        if (isset($o['jpId'])) $this->jpId = $o['jpId'];
        if (isset($o['amount'])) $this->amount = $o['amount'];
        if (isset($o['locationId'])) $this->locationId = $o['locationId'];
        if (isset($o['locationName'])) $this->locationName = $o['locationName'];
        if (isset($o['addressLine'])) $this->addressLine = $o['addressLine'];
        if (isset($o['amountAccumulated'])) $this->amountAccumulated = $o['amountAccumulated'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->isGiven)) $o['isGiven'] = $this->isGiven;
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->slipId)) $o['slipId'] = $this->slipId;
        if (isset($this->jpId)) $o['jpId'] = $this->jpId;
        if (isset($this->amount)) $o['amount'] = $this->amount;
        if (isset($this->locationId)) $o['locationId'] = $this->locationId;
        if (isset($this->locationName)) $o['locationName'] = $this->locationName;
        if (isset($this->addressLine)) $o['addressLine'] = $this->addressLine;
        if (isset($this->amountAccumulated)) $o['amountAccumulated'] = $this->amountAccumulated;
        return empty($o) ? new class(){} : $o;
    }
}

class Race implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $sequence=null,
        /** @var array<Pool>|null */
        public ?array $inputAccumulation=null,
        /** @var array<Pool>|null */
        public ?array $outputAccumulation=null,
        /** @var RoundOutcome|null */
        public ?RoundOutcome $outcome=null,
        /** @var JackpotInfo|null */
        public ?JackpotInfo $jackpotInfo=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['sequence'])) $this->sequence = $o['sequence'];
        if (isset($o['inputAccumulation'])) $this->inputAccumulation = JsonConverters::fromArray('Pool', $o['inputAccumulation']);
        if (isset($o['outputAccumulation'])) $this->outputAccumulation = JsonConverters::fromArray('Pool', $o['outputAccumulation']);
        if (isset($o['outcome'])) $this->outcome = JsonConverters::from('RoundOutcome', $o['outcome']);
        if (isset($o['jackpotInfo'])) $this->jackpotInfo = JsonConverters::from('JackpotInfo', $o['jackpotInfo']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->sequence)) $o['sequence'] = $this->sequence;
        if (isset($this->inputAccumulation)) $o['inputAccumulation'] = JsonConverters::toArray('Pool', $this->inputAccumulation);
        if (isset($this->outputAccumulation)) $o['outputAccumulation'] = JsonConverters::toArray('Pool', $this->outputAccumulation);
        if (isset($this->outcome)) $o['outcome'] = JsonConverters::to('RoundOutcome', $this->outcome);
        if (isset($this->jackpotInfo)) $o['jackpotInfo'] = JsonConverters::to('JackpotInfo', $this->jackpotInfo);
        return empty($o) ? new class(){} : $o;
    }
}

class GetRace implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetRace 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 /rounds/race HTTP/1.1 
Host: grh1.api.bettor.webhop.biz 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	id: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	id: String,
	sequence: String,
	inputAccumulation: 
	[
		{
			id: 0,
			name: String,
			amount: 0
		}
	],
	outputAccumulation: 
	[
		{
			id: 0,
			name: String,
			amount: 0
		}
	],
	outcome: 
	{
		raceOutcomeRecaps: 
		[
			{
				id: 0,
				coef: 0,
				winCount: 0,
				win: 0,
				isWin: False,
				results: String
			}
		],
		stake: 0,
		winnings: 0,
		balance: 0,
		returnToPlayer: 0
	},
	jackpotInfo: 
	{
		isGiven: False,
		id: String,
		slipId: String,
		jpId: String,
		amount: 0,
		locationId: String,
		locationName: String,
		addressLine: String,
		amountAccumulated: 0
	}
}