<?php
/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio - Insights
 * Insights Domain V3 API.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Insights\V3;

use Twilio\Values;
abstract class QueryModels
{
    /**
     * @property string $op
     * @property string $field
     * @property string[] $values
    */
    public static function createQueryDefinitionFiltersExpressions(array $payload = []): QueryDefinitionFiltersExpressions
    {
        return new QueryDefinitionFiltersExpressions($payload);
    }

    /**
     * @property string $op
     * @property QueryDefinitionFiltersExpressions[] $expressions
    */
    public static function createQueryDefinitionFilters(array $payload = []): QueryDefinitionFilters
    {
        return new QueryDefinitionFilters($payload);
    }

    /**
     * @property string $field Dimension or measure to order by
     * @property string $direction Sort order direction, ascending or descending
    */
    public static function createQueryDefinitionOrderBy(array $payload = []): QueryDefinitionOrderBy
    {
        return new QueryDefinitionOrderBy($payload);
    }

    /**
     * @property string[] $measures Array of measures to retrieve, representing quantitative values or metrics to be calculated
     * @property string[] $dimensions Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data
     * @property QueryDefinitionFilters[] $filters Nested filter conditions. Always use `op` and `expressions`.
     * @property QueryDefinitionOrderBy[] $orderBy Specifications for sorting the query results by specific fields in ascending or descending order
    */
    public static function createQueryDefinition(array $payload = []): QueryDefinition
    {
        return new QueryDefinition($payload);
    }

    /**
     * @property string $domain The business domain to execute the query against
     * @property QueryDefinition $query
    */
    public static function createInsightsQueryRequest(array $payload = []): InsightsQueryRequest
    {
        return new InsightsQueryRequest($payload);
    }

    /**
     * @property string $key The key of the list property contains the actual data items. This enables programmatic iteration over paginated results.
     * @property int $pageSize The actual number of items returned in this response. May be less than the requested pageSize for the last page.
     * @property string $previousToken Token to fetch the previous page of results. Only included if there is a previous page, otherwise omitted.
     * @property string $nextToken Token to fetch the next page of results. Only included if there is a next page, otherwise omitted.
    */
    public static function createPaginationMeta(array $payload = []): PaginationMeta
    {
        return new PaginationMeta($payload);
    }

}

class QueryDefinitionFiltersExpressions implements \JsonSerializable
{
    /**
     * @property string $op
     * @property string $field
     * @property string[] $values
    */
        protected $op;
        protected $field;
        protected $values;
    public function __construct(array $payload = []) {
        $this->op = Values::array_get($payload, 'op');
        $this->field = Values::array_get($payload, 'field');
        $this->values = Values::array_get($payload, 'values');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
            'op' => $this->op,
            'field' => $this->field
        ];
        if (isset($this->values)) {
            $jsonString['values'] = $this->values;
        }
        return $jsonString;
    }
}

class QueryDefinitionFilters implements \JsonSerializable
{
    /**
     * @property string $op
     * @property QueryDefinitionFiltersExpressions[] $expressions
    */
        protected $op;
        protected $expressions;
    public function __construct(array $payload = []) {
        $this->op = Values::array_get($payload, 'op');
        $this->expressions = Values::array_get($payload, 'expressions');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
            'expressions' => $this->expressions
        ];
        if (isset($this->op)) {
            $jsonString['op'] = $this->op;
        }
        return $jsonString;
    }
}

class QueryDefinitionOrderBy implements \JsonSerializable
{
    /**
     * @property string $field Dimension or measure to order by
     * @property string $direction Sort order direction, ascending or descending
    */
        protected $field;
        protected $direction;
    public function __construct(array $payload = []) {
        $this->field = Values::array_get($payload, 'field');
        $this->direction = Values::array_get($payload, 'direction');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
        ];
        if (isset($this->field)) {
            $jsonString['field'] = $this->field;
        }
        if (isset($this->direction)) {
            $jsonString['direction'] = $this->direction;
        }
        return $jsonString;
    }
}

class QueryDefinition implements \JsonSerializable
{
    /**
     * @property string[] $measures Array of measures to retrieve, representing quantitative values or metrics to be calculated
     * @property string[] $dimensions Array of dimensions to retrieve, representing categorical attributes for grouping and organizing data
     * @property QueryDefinitionFilters[] $filters Nested filter conditions. Always use `op` and `expressions`.
     * @property QueryDefinitionOrderBy[] $orderBy Specifications for sorting the query results by specific fields in ascending or descending order
    */
        protected $measures;
        protected $dimensions;
        protected $filters;
        protected $orderBy;
    public function __construct(array $payload = []) {
        $this->measures = Values::array_get($payload, 'measures');
        $this->dimensions = Values::array_get($payload, 'dimensions');
        $this->filters = Values::array_get($payload, 'filters');
        $this->orderBy = Values::array_get($payload, 'orderBy');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
        ];
        if (isset($this->measures)) {
            $jsonString['measures'] = $this->measures;
        }
        if (isset($this->dimensions)) {
            $jsonString['dimensions'] = $this->dimensions;
        }
        if (isset($this->filters)) {
            $jsonString['filters'] = $this->filters;
        }
        if (isset($this->orderBy)) {
            $jsonString['orderBy'] = $this->orderBy;
        }
        return $jsonString;
    }
}

class InsightsQueryRequest implements \JsonSerializable
{
    /**
     * @property string $domain The business domain to execute the query against
     * @property QueryDefinition $query
    */
        protected $domain;
        protected $query;
    public function __construct(array $payload = []) {
        $this->domain = Values::array_get($payload, 'domain');
        $this->query = Values::array_get($payload, 'query');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
            'query' => $this->query
        ];
        if (isset($this->domain)) {
            $jsonString['domain'] = $this->domain;
        }
        return $jsonString;
    }
}

class PaginationMeta implements \JsonSerializable
{
    /**
     * @property string $key The key of the list property contains the actual data items. This enables programmatic iteration over paginated results.
     * @property int $pageSize The actual number of items returned in this response. May be less than the requested pageSize for the last page.
     * @property string $previousToken Token to fetch the previous page of results. Only included if there is a previous page, otherwise omitted.
     * @property string $nextToken Token to fetch the next page of results. Only included if there is a next page, otherwise omitted.
    */
        protected $key;
        protected $pageSize;
        protected $previousToken;
        protected $nextToken;
    public function __construct(array $payload = []) {
        $this->key = Values::array_get($payload, 'key');
        $this->pageSize = Values::array_get($payload, 'pageSize');
        $this->previousToken = Values::array_get($payload, 'previousToken');
        $this->nextToken = Values::array_get($payload, 'nextToken');
    }

    public function toArray(): array
    {
        return $this->jsonSerialize();
    }

    public function jsonSerialize(): array
    {
        $jsonString = [
            'key' => $this->key,
            'pageSize' => $this->pageSize
        ];
        if (isset($this->previousToken)) {
            $jsonString['previousToken'] = $this->previousToken;
        }
        if (isset($this->nextToken)) {
            $jsonString['nextToken'] = $this->nextToken;
        }
        return $jsonString;
    }
}

