Greyhounds.WebApi

<back to all web services

ConfigureAccumulator

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

enum LocationOptimizationLevel : int
{
    case None = 0;
    case Low = 1;
    case Medium = 2;
    case High = 3;
}

class ThresholdInterval implements JsonSerializable
{
    public function __construct(
        /** @var float */
        public float $start=0.0,
        /** @var float */
        public float $end=0.0
    ) {
    }

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

class AccumulatorConfiguration implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var array<Pool>|null */
        public ?array $pools=null,
        /** @var float */
        public float $prevalentStake=0.0,
        /** @var LocationOptimizationLevel|null */
        public ?LocationOptimizationLevel $locationOptimizationLevel=null,
        /** @var ThresholdInterval|null */
        public ?ThresholdInterval $jackPotThresholdInterval=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['pools'])) $this->pools = JsonConverters::fromArray('Pool', $o['pools']);
        if (isset($o['prevalentStake'])) $this->prevalentStake = $o['prevalentStake'];
        if (isset($o['locationOptimizationLevel'])) $this->locationOptimizationLevel = JsonConverters::from('LocationOptimizationLevel', $o['locationOptimizationLevel']);
        if (isset($o['jackPotThresholdInterval'])) $this->jackPotThresholdInterval = JsonConverters::from('ThresholdInterval', $o['jackPotThresholdInterval']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->pools)) $o['pools'] = JsonConverters::toArray('Pool', $this->pools);
        if (isset($this->prevalentStake)) $o['prevalentStake'] = $this->prevalentStake;
        if (isset($this->locationOptimizationLevel)) $o['locationOptimizationLevel'] = JsonConverters::to('LocationOptimizationLevel', $this->locationOptimizationLevel);
        if (isset($this->jackPotThresholdInterval)) $o['jackPotThresholdInterval'] = JsonConverters::to('ThresholdInterval', $this->jackPotThresholdInterval);
        return empty($o) ? new class(){} : $o;
    }
}

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

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

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

{
	id: String,
	configuration: 
	{
		pools: 
		[
			{
				id: 0,
				name: String,
				rtp: 0
			}
		],
		prevalentStake: 0,
		locationOptimizationLevel: 0,
		jackPotThresholdInterval: 
		{
			start: 0,
			end: 0
		}
	}
}
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
	}
}