Evo Voice

<back to all web services

GetAIUsage

Requires Authentication
Required role:SystemAdministrator
The following routes are available for this service:
All Verbs/ai/usage
<?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 AIAccountUsage implements JsonSerializable
{
    public function __construct(
        /** @description The account ID this customer belongs to */
        // @ApiMember(Description="The account ID this customer belongs to")
        /** @var string|null */
        public ?string $accountId=null,

        /** @description The total number of AI minutes used in the date range */
        // @ApiMember(Description="The total number of AI minutes used in the date range")
        /** @var int */
        public int $aiMinutes=0
    ) {
    }

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

class AICustomerUsage implements JsonSerializable
{
    public function __construct(
        /** @description The account ID this customer belongs to */
        // @ApiMember(Description="The account ID this customer belongs to")
        /** @var string|null */
        public ?string $accountId=null,

        /** @description The customer ID for this uage */
        // @ApiMember(Description="The customer ID for this uage")
        /** @var string|null */
        public ?string $customerId=null,

        /** @description The total number of AI minutes used in the date range */
        // @ApiMember(Description="The total number of AI minutes used in the date range")
        /** @var int */
        public int $aiMinutes=0
    ) {
    }

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

class AIUsage implements JsonSerializable
{
    public function __construct(
        /** @var array<AIAccountUsage>|null */
        public ?array $accountUsage=null,
        /** @var array<AICustomerUsage>|null */
        public ?array $customerUsage=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['accountUsage'])) $this->accountUsage = JsonConverters::fromArray('AIAccountUsage', $o['accountUsage']);
        if (isset($o['customerUsage'])) $this->customerUsage = JsonConverters::fromArray('AICustomerUsage', $o['customerUsage']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->accountUsage)) $o['accountUsage'] = JsonConverters::toArray('AIAccountUsage', $this->accountUsage);
        if (isset($this->customerUsage)) $o['customerUsage'] = JsonConverters::toArray('AICustomerUsage', $this->customerUsage);
        return empty($o) ? new class(){} : $o;
    }
}

class GetAIUsage implements IGet, JsonSerializable
{
    public function __construct(
        /** @description Filter by account ID. If not specified will return entries for all customers in all accounts in the date range */
        // @ApiMember(Description="Filter by account ID. If not specified will return entries for all customers in all accounts in the date range")
        /** @var string|null */
        public ?string $accountId=null,

        /** @description Filter by customer ID. If not specified, will return all customers for the accounts considered */
        // @ApiMember(Description="Filter by customer ID. If not specified, will return all customers for the accounts considered")
        /** @var string|null */
        public ?string $customerId=null,

        /** @description The start of the date range to consider */
        // @ApiMember(Description="The start of the date range to consider")
        /** @var string|null */
        public ?string $startDate=null,

        /** @description The end of the date range to consider */
        // @ApiMember(Description="The end of the date range to consider")
        /** @var string|null */
        public ?string $endDate=null
    ) {
    }

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

PHP GetAIUsage 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 /ai/usage HTTP/1.1 
Host: team.evovoice.io 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<GetAIUsage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.AI">
  <AccountId>String</AccountId>
  <CustomerId>String</CustomerId>
  <EndDate>String</EndDate>
  <StartDate>String</StartDate>
</GetAIUsage>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<AIUsage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api.AI">
  <AccountUsage>
    <AIAccountUsage>
      <AIMinutes>0</AIMinutes>
      <AccountId>String</AccountId>
    </AIAccountUsage>
  </AccountUsage>
  <CustomerUsage>
    <AICustomerUsage>
      <AIMinutes>0</AIMinutes>
      <AccountId>String</AccountId>
      <CustomerId>String</CustomerId>
    </AICustomerUsage>
  </CustomerUsage>
</AIUsage>