Greyhounds.WebApi

<back to all web services

FindRoundStats

The following routes are available for this service:
All Verbs/rounds/stats
<?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 RoundStatus : int
{
    case Pending = 0;
    case InProgress = 1;
    case Ended = 2;
}

class RoundStats implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var DateTime */
        public DateTime $createdAt=new DateTime(),
        /** @var RoundStatus|null */
        public ?RoundStatus $status=null,
        /** @var int */
        public int $canceledCount=0,
        /** @var float */
        public float $canceledAmount=0.0,
        /** @var int */
        public int $betCount=0,
        /** @var float */
        public float $stakeAmount=0.0,
        /** @var float */
        public float $winningsAmount=0.0,
        /** @var float */
        public float $balanceAmount=0.0,
        /** @var float */
        public float $balancePct=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['createdAt'])) $this->createdAt = JsonConverters::from('DateTime', $o['createdAt']);
        if (isset($o['status'])) $this->status = JsonConverters::from('RoundStatus', $o['status']);
        if (isset($o['canceledCount'])) $this->canceledCount = $o['canceledCount'];
        if (isset($o['canceledAmount'])) $this->canceledAmount = $o['canceledAmount'];
        if (isset($o['betCount'])) $this->betCount = $o['betCount'];
        if (isset($o['stakeAmount'])) $this->stakeAmount = $o['stakeAmount'];
        if (isset($o['winningsAmount'])) $this->winningsAmount = $o['winningsAmount'];
        if (isset($o['balanceAmount'])) $this->balanceAmount = $o['balanceAmount'];
        if (isset($o['balancePct'])) $this->balancePct = $o['balancePct'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->createdAt)) $o['createdAt'] = JsonConverters::to('DateTime', $this->createdAt);
        if (isset($this->status)) $o['status'] = JsonConverters::to('RoundStatus', $this->status);
        if (isset($this->canceledCount)) $o['canceledCount'] = $this->canceledCount;
        if (isset($this->canceledAmount)) $o['canceledAmount'] = $this->canceledAmount;
        if (isset($this->betCount)) $o['betCount'] = $this->betCount;
        if (isset($this->stakeAmount)) $o['stakeAmount'] = $this->stakeAmount;
        if (isset($this->winningsAmount)) $o['winningsAmount'] = $this->winningsAmount;
        if (isset($this->balanceAmount)) $o['balanceAmount'] = $this->balanceAmount;
        if (isset($this->balancePct)) $o['balancePct'] = $this->balancePct;
        return empty($o) ? new class(){} : $o;
    }
}

class FindRoundStats implements JsonSerializable
{
    public function __construct(
        /** @var DateTime */
        public DateTime $periodFrom=new DateTime(),
        /** @var DateTime */
        public DateTime $periodTo=new DateTime(),
        /** @var int */
        public int $currentPage=0,
        /** @var int */
        public int $pageSize=0
    ) {
    }

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

/**
 * @template T
 */
class PaginatedResult implements JsonSerializable
{
    public array $genericArgs = [];
    public static function create(array $genericArgs=[]): PaginatedResult {
        $to = new PaginatedResult();
        $to->genericArgs = $genericArgs;
        return $to;
    }

    public function __construct(
        /** @var array<RoundStats>|null */
        public mixed $data=null,
        /** @var int */
        public mixed $currentPage=0,
        /** @var int */
        public mixed $pageSize=0,
        /** @var int */
        public mixed $totalItems=0,
        /** @var int */
        public mixed $totalPages=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['data'])) $this->data = JsonConverters::fromArray('RoundStats', $o['data']);
        if (isset($o['currentPage'])) $this->currentPage = $o['currentPage'];
        if (isset($o['pageSize'])) $this->pageSize = $o['pageSize'];
        if (isset($o['totalItems'])) $this->totalItems = $o['totalItems'];
        if (isset($o['totalPages'])) $this->totalPages = $o['totalPages'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->data)) $o['data'] = JsonConverters::toArray('RoundStats', $this->data);
        if (isset($this->currentPage)) $o['currentPage'] = $this->currentPage;
        if (isset($this->pageSize)) $o['pageSize'] = $this->pageSize;
        if (isset($this->totalItems)) $o['totalItems'] = $this->totalItems;
        if (isset($this->totalPages)) $o['totalPages'] = $this->totalPages;
        return empty($o) ? new class(){} : $o;
    }
}

PHP FindRoundStats DTOs

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

HTTP + XML

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

POST /rounds/stats HTTP/1.1 
Host: grh1.api.bettor.webhop.biz 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<FindRoundStats xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Greyhounds.WebApi.ServiceModel">
  <CurrentPage>0</CurrentPage>
  <PageSize>0</PageSize>
  <PeriodFrom>0001-01-01T00:00:00</PeriodFrom>
  <PeriodTo>0001-01-01T00:00:00</PeriodTo>
</FindRoundStats>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<PaginatedResultOfRoundStatsHTcU5Hwp xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Greyhounds.ReadModel">
  <CurrentPage>0</CurrentPage>
  <Data>
    <RoundStats>
      <BalanceAmount>0</BalanceAmount>
      <BalancePct>0</BalancePct>
      <BetCount>0</BetCount>
      <CanceledAmount>0</CanceledAmount>
      <CanceledCount>0</CanceledCount>
      <CreatedAt>0001-01-01T00:00:00</CreatedAt>
      <Id>String</Id>
      <StakeAmount>0</StakeAmount>
      <Status>Pending</Status>
      <WinningsAmount>0</WinningsAmount>
    </RoundStats>
  </Data>
  <PageSize>0</PageSize>
  <TotalItems>0</TotalItems>
  <TotalPages>0</TotalPages>
</PaginatedResultOfRoundStatsHTcU5Hwp>