Betting.WebApi

<back to all web services

InstallProductInstance

Requires Authentication
The following routes are available for this service:
POST/cmd/products/instances
<?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 Ref implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $id='',
        /** @var string */
        public string $val=''
    ) {
    }

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

class ProductReference implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $value=null,
        /** @var string|null */
        public ?string $category=null,
        /** @var Ref|null */
        public ?Ref $productProvider=null
    ) {
    }

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

enum PayinConstraintType : int
{
    case SingleBet = 0;
    case MultiBet = 1;
    case SystemBet = 2;
}

class Money implements JsonSerializable
{
    public function __construct(
        /** @var float */
        public float $amount=0.0,
        /** @var string */
        public string $currency=''
    ) {
    }

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

class PayinConstraint implements JsonSerializable
{
    public function __construct(
        /** @var PayinConstraintType|null */
        public ?PayinConstraintType $type=null,
        /** @var Money|null */
        public ?Money $min=null,
        /** @var Money|null */
        public ?Money $default=null,
        /** @var Money|null */
        public ?Money $warningThreshold=null,
        /** @var Money|null */
        public ?Money $max=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['type'])) $this->type = JsonConverters::from('PayinConstraintType', $o['type']);
        if (isset($o['min'])) $this->min = JsonConverters::from('Money', $o['min']);
        if (isset($o['default'])) $this->default = JsonConverters::from('Money', $o['default']);
        if (isset($o['warningThreshold'])) $this->warningThreshold = JsonConverters::from('Money', $o['warningThreshold']);
        if (isset($o['max'])) $this->max = JsonConverters::from('Money', $o['max']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->type)) $o['type'] = JsonConverters::to('PayinConstraintType', $this->type);
        if (isset($this->min)) $o['min'] = JsonConverters::to('Money', $this->min);
        if (isset($this->default)) $o['default'] = JsonConverters::to('Money', $this->default);
        if (isset($this->warningThreshold)) $o['warningThreshold'] = JsonConverters::to('Money', $this->warningThreshold);
        if (isset($this->max)) $o['max'] = JsonConverters::to('Money', $this->max);
        return empty($o) ? new class(){} : $o;
    }
}

enum WinningsCapType : int
{
    case SingleBet = 0;
    case MultiBet = 1;
    case SystemBet = 2;
}

class WinningsCap implements JsonSerializable
{
    public function __construct(
        /** @var WinningsCapType|null */
        public ?WinningsCapType $type=null,
        /** @var Money|null */
        public ?Money $cap=null
    ) {
    }

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

class BettingPolicies implements JsonSerializable
{
    public function __construct(
        /** @var RecordList<PayinConstraint>|null */
        public ?RecordList $payinConstraints=null,
        /** @var string|null */
        public ?string $payinTaxationPolicyId=null,
        /** @var RecordList<WinningsCap>|null */
        public ?RecordList $winningsCaps=null,
        /** @var string|null */
        public ?string $winningsTaxationPolicyId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['payinConstraints'])) $this->payinConstraints = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['PayinConstraint']), $o['payinConstraints']);
        if (isset($o['payinTaxationPolicyId'])) $this->payinTaxationPolicyId = $o['payinTaxationPolicyId'];
        if (isset($o['winningsCaps'])) $this->winningsCaps = JsonConverters::from(JsonConverters::context('RecordList',genericArgs:['WinningsCap']), $o['winningsCaps']);
        if (isset($o['winningsTaxationPolicyId'])) $this->winningsTaxationPolicyId = $o['winningsTaxationPolicyId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->payinConstraints)) $o['payinConstraints'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['PayinConstraint']), $this->payinConstraints);
        if (isset($this->payinTaxationPolicyId)) $o['payinTaxationPolicyId'] = $this->payinTaxationPolicyId;
        if (isset($this->winningsCaps)) $o['winningsCaps'] = JsonConverters::to(JsonConverters::context('RecordList',genericArgs:['WinningsCap']), $this->winningsCaps);
        if (isset($this->winningsTaxationPolicyId)) $o['winningsTaxationPolicyId'] = $this->winningsTaxationPolicyId;
        return empty($o) ? new class(){} : $o;
    }
}

class InstallProductInstance implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $name=null,
        /** @var string|null */
        public ?string $title=null,
        /** @var ProductReference|null */
        public ?ProductReference $product=null,
        /** @var Ref|null */
        public ?Ref $currency=null,
        /** @var BettingPolicies|null */
        public ?BettingPolicies $bettingPolicies=null,
        /** @var string|null */
        public ?string $apiUrl=null,
        /** @var string|null */
        public ?string $backOfficeUrl=null,
        /** @var string|null */
        public ?string $instanceUrl=null,
        /** @var string|null */
        public ?string $feedPlayerUrl=null
    ) {
    }

    /** @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['title'])) $this->title = $o['title'];
        if (isset($o['product'])) $this->product = JsonConverters::from('ProductReference', $o['product']);
        if (isset($o['currency'])) $this->currency = JsonConverters::from('Ref', $o['currency']);
        if (isset($o['bettingPolicies'])) $this->bettingPolicies = JsonConverters::from('BettingPolicies', $o['bettingPolicies']);
        if (isset($o['apiUrl'])) $this->apiUrl = $o['apiUrl'];
        if (isset($o['backOfficeUrl'])) $this->backOfficeUrl = $o['backOfficeUrl'];
        if (isset($o['instanceUrl'])) $this->instanceUrl = $o['instanceUrl'];
        if (isset($o['feedPlayerUrl'])) $this->feedPlayerUrl = $o['feedPlayerUrl'];
    }
    
    /** @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->title)) $o['title'] = $this->title;
        if (isset($this->product)) $o['product'] = JsonConverters::to('ProductReference', $this->product);
        if (isset($this->currency)) $o['currency'] = JsonConverters::to('Ref', $this->currency);
        if (isset($this->bettingPolicies)) $o['bettingPolicies'] = JsonConverters::to('BettingPolicies', $this->bettingPolicies);
        if (isset($this->apiUrl)) $o['apiUrl'] = $this->apiUrl;
        if (isset($this->backOfficeUrl)) $o['backOfficeUrl'] = $this->backOfficeUrl;
        if (isset($this->instanceUrl)) $o['instanceUrl'] = $this->instanceUrl;
        if (isset($this->feedPlayerUrl)) $o['feedPlayerUrl'] = $this->feedPlayerUrl;
        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 InstallProductInstance DTOs

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

HTTP + OTHER

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

POST /cmd/products/instances HTTP/1.1 
Host: api.sbbet.ath.cx 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"id":"String","name":"String","title":"String","product":{"id":"String","value":"String","category":"String","productProvider":{"id":"String","val":"String"}},"currency":{"id":"String","val":"String"},"bettingPolicies":{"payinConstraints":[{"type":0,"min":{"amount":0,"currency":"String"},"default":{"amount":0,"currency":"String"},"warningThreshold":{"amount":0,"currency":"String"},"max":{"amount":0,"currency":"String"}}],"payinTaxationPolicyId":"String","winningsCaps":[{"type":0,"cap":{"amount":0,"currency":"String"}}],"winningsTaxationPolicyId":"String"},"apiUrl":"String","backOfficeUrl":"String","instanceUrl":"String","feedPlayerUrl":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

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