<?php
/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio Conversational Intelligence API
 * The Conversational Intelligence API includes resources to create and manage intelligence configurations, define and run language operators, and retrieve processed conversations and operator results.  * Use the Configurations resource to create and manage intelligence configurations and define rules that control how and when language operators analyze and transform conversations.  * Use the Operators resource to create custom language operators or retrieve Twilio-author and custom operators. * Use the Conversations resource to retrieve conversations processed with an intelligence configuration, and the OperatorResults resource to retrieve language operator results for those conversations.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Intelligence\V3;

use Twilio\Values;
abstract class ConfigurationModels
{
    /**
     * @property string $id The unique identifier for the Language Operator to be executed by the Rule. Assigned by Twilio (TTID).
     * @property int $version The specific version of the Language Operator to execute. When provided, the Rule will use this exact version of the Operator. When omitted, the latest active version of the Operator is used at execution time.
     * @property array $parameters Key-value mapping for parameters defined as part of the Operator schema. The key and value passed by the Rule must match the name and data type of the parameter defined in the Operator, respectively. These parameters will customize the behavior of the Operator when executed by the Rule via runtime substitution into the prompt. Note: For parameters of type `knowledge_base_and_source_ids`, the value must be passed in the following format: `knowledge_base_id:knowledge_source_id`.
    */
    public static function createOperator(array $payload = []): Operator
    {
        return new Operator($payload);
    }

    /**
     * @property int $count When `on` is set to `COMMUNICATION`, this value controls how often the Rule should run. A value of `1` executes the Rule for every communication event. Higher values delay execution until the specified number of communications have occurred since the last execution.
    */
    public static function createTriggerParameters(array $payload = []): TriggerParameters
    {
        return new TriggerParameters($payload);
    }

    /**
     * @property string $on The conversational lifecycle event that will activate execution of the Rule. Available values are: - `COMMUNICATION`: Trigger the Rule on each communication within the Conversation. - `CONVERSATION_END`: Trigger the Rule when the Conversation moves to the `closed` state - `CONVERSATION_INACTIVE`: Trigger the Rule when the Conversation moves to `inactive` state
     * @property TriggerParameters $parameters
    */
    public static function createTrigger(array $payload = []): Trigger
    {
        return new Trigger($payload);
    }

    /**
     * @property string $type The type of Action to be performed after the Rule is triggered. Supported Actions are: - `WEBHOOK`: A webhook Action sends an HTTP request to a specified URL with Rule execution results.
     * @property string $method The HTTP method to be used when performing the Action. Must be set to `POST`.
     * @property string $url The URL endpoint where the Action will send the HTTP request containing the Rule execution results.
    */
    public static function createAction(array $payload = []): Action
    {
        return new Action($payload);
    }

    /**
     * @property bool $enabled When set to `true`, allows this Intelligence Configuration Rule to pass the Profile into attached Language Operators. The profile is only passed to Language Operators that have Memory as a context source enabled.
    */
    public static function createContextMemory(array $payload = []): ContextMemory
    {
        return new ContextMemory($payload);
    }

    /**
     * @property string[] $bases Specifies the Knowledge Base(s) and corresponding Source(s) to pass to Language Operators in this Rule as context. Only applied to Language Operators that have Knowledge as a context source enabled.
    */
    public static function createContextKnowledge(array $payload = []): ContextKnowledge
    {
        return new ContextKnowledge($payload);
    }

    /**
     * @property ContextMemory $memory
     * @property ContextKnowledge $knowledge
    */
    public static function createContext(array $payload = []): Context
    {
        return new Context($payload);
    }

    /**
     * @property Operator[] $operators List of Operators to be executed by the Rule. Minimum of one (1) and maximum of five (5) Operators allowed per Rule.
     * @property Trigger[] $triggers List of Triggers that determine when to activate the Rule. Maximum of one (1) Trigger allowed per Rule.
     * @property Action[] $actions List of Actions to be performed after the Rule is triggered. Maximum of two (2) Actions allowed per Rule.
     * @property Context $context
    */
    public static function createRuleCreationRequestPayload(array $payload = []): RuleCreationRequestPayload
    {
        return new RuleCreationRequestPayload($payload);
    }

    /**
     * @property string $displayName The display name of the Intelligence Configuration describing its purpose.
     * @property string $description The description of the Intelligence Configuration further explaining its purpose.
     * @property RuleCreationRequestPayload[] $rules List of Intelligence Configuration Rules that govern when and how Language Operators run. Each Rule represents a bundle of Operators, Triggers, Context, and Actions to be executed by the Intelligence Configuration on a Conversation. A maximum of five (5) Rules are allowed per Intelligence Configuration.  To create an Intelligence Configuration without any Rules configured yet, pass an empty array (`\"rules\": []`). The Configuration will not execute any Language Operators until at least one Rule has been added.
    */
    public static function createCreateConfigurationRequest(array $payload = []): CreateConfigurationRequest
    {
        return new CreateConfigurationRequest($payload);
    }

    /**
     * @property string $id Optional field used when updating an existing Rule within an Intelligence Configuration. When provided, the Rule with this `id` is updated; when omitted, a new Rule is created.
     * @property Operator[] $operators List of Operators to be executed by the Rule. Minimum of one (1) and maximum of five (5) Operators allowed per Rule.
     * @property Trigger[] $triggers List of Triggers that determine when to activate the Rule. Maximum of one (1) Trigger allowed per Rule.
     * @property Action[] $actions List of Actions to be performed after the Rule is triggered. Maximum of two (2) Actions allowed per Rule.
     * @property Context $context
    */
    public static function createRuleUpdateRequestPayload(array $payload = []): RuleUpdateRequestPayload
    {
        return new RuleUpdateRequestPayload($payload);
    }

    /**
     * @property string $displayName The display name of the Intelligence Configuration describing its purpose.
     * @property string $description The description of the Intelligence Configuration further explaining its purpose.
     * @property RuleUpdateRequestPayload[] $rules List of Intelligence Configuration Rules that govern when and how Language Operators run. Each Rule represents a bundle of Operators, Triggers, Context, and Actions to be executed by the Intelligence Configuration on a Conversation. A maximum of five (5) Rules are allowed per Intelligence Configuration.
    */
    public static function createUpdateConfigurationRequest(array $payload = []): UpdateConfigurationRequest
    {
        return new UpdateConfigurationRequest($payload);
    }

}

class Operator implements \JsonSerializable
{
    /**
     * @property string $id The unique identifier for the Language Operator to be executed by the Rule. Assigned by Twilio (TTID).
     * @property int $version The specific version of the Language Operator to execute. When provided, the Rule will use this exact version of the Operator. When omitted, the latest active version of the Operator is used at execution time.
     * @property array $parameters Key-value mapping for parameters defined as part of the Operator schema. The key and value passed by the Rule must match the name and data type of the parameter defined in the Operator, respectively. These parameters will customize the behavior of the Operator when executed by the Rule via runtime substitution into the prompt. Note: For parameters of type `knowledge_base_and_source_ids`, the value must be passed in the following format: `knowledge_base_id:knowledge_source_id`.
    */
        protected $id;
        protected $version;
        protected $parameters;
    public function __construct(array $payload = []) {
        $this->id = Values::array_get($payload, 'id');
        $this->version = Values::array_get($payload, 'version');
        $this->parameters = Values::array_get($payload, 'parameters');
    }

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

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

class TriggerParameters implements \JsonSerializable
{
    /**
     * @property int $count When `on` is set to `COMMUNICATION`, this value controls how often the Rule should run. A value of `1` executes the Rule for every communication event. Higher values delay execution until the specified number of communications have occurred since the last execution.
    */
        protected $count;
    public function __construct(array $payload = []) {
        $this->count = Values::array_get($payload, 'count');
    }

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

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

class Trigger implements \JsonSerializable
{
    /**
     * @property string $on The conversational lifecycle event that will activate execution of the Rule. Available values are: - `COMMUNICATION`: Trigger the Rule on each communication within the Conversation. - `CONVERSATION_END`: Trigger the Rule when the Conversation moves to the `closed` state - `CONVERSATION_INACTIVE`: Trigger the Rule when the Conversation moves to `inactive` state
     * @property TriggerParameters $parameters
    */
        protected $on;
        protected $parameters;
    public function __construct(array $payload = []) {
        $this->on = Values::array_get($payload, 'on');
        $this->parameters = Values::array_get($payload, 'parameters');
    }

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

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

class Action implements \JsonSerializable
{
    /**
     * @property string $type The type of Action to be performed after the Rule is triggered. Supported Actions are: - `WEBHOOK`: A webhook Action sends an HTTP request to a specified URL with Rule execution results.
     * @property string $method The HTTP method to be used when performing the Action. Must be set to `POST`.
     * @property string $url The URL endpoint where the Action will send the HTTP request containing the Rule execution results.
    */
        protected $type;
        protected $method;
        protected $url;
    public function __construct(array $payload = []) {
        $this->type = Values::array_get($payload, 'type');
        $this->method = Values::array_get($payload, 'method');
        $this->url = Values::array_get($payload, 'url');
    }

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

    public function jsonSerialize(): array
    {
        $jsonString = [
            'type' => $this->type,
            'method' => $this->method,
            'url' => $this->url
        ];
        return $jsonString;
    }
}

class ContextMemory implements \JsonSerializable
{
    /**
     * @property bool $enabled When set to `true`, allows this Intelligence Configuration Rule to pass the Profile into attached Language Operators. The profile is only passed to Language Operators that have Memory as a context source enabled.
    */
        protected $enabled;
    public function __construct(array $payload = []) {
        $this->enabled = Values::array_get($payload, 'enabled');
    }

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

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

class ContextKnowledge implements \JsonSerializable
{
    /**
     * @property string[] $bases Specifies the Knowledge Base(s) and corresponding Source(s) to pass to Language Operators in this Rule as context. Only applied to Language Operators that have Knowledge as a context source enabled.
    */
        protected $bases;
    public function __construct(array $payload = []) {
        $this->bases = Values::array_get($payload, 'bases');
    }

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

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

class Context implements \JsonSerializable
{
    /**
     * @property ContextMemory $memory
     * @property ContextKnowledge $knowledge
    */
        protected $memory;
        protected $knowledge;
    public function __construct(array $payload = []) {
        $this->memory = Values::array_get($payload, 'memory');
        $this->knowledge = Values::array_get($payload, 'knowledge');
    }

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

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

class RuleCreationRequestPayload implements \JsonSerializable
{
    /**
     * @property Operator[] $operators List of Operators to be executed by the Rule. Minimum of one (1) and maximum of five (5) Operators allowed per Rule.
     * @property Trigger[] $triggers List of Triggers that determine when to activate the Rule. Maximum of one (1) Trigger allowed per Rule.
     * @property Action[] $actions List of Actions to be performed after the Rule is triggered. Maximum of two (2) Actions allowed per Rule.
     * @property Context $context
    */
        protected $operators;
        protected $triggers;
        protected $actions;
        protected $context;
    public function __construct(array $payload = []) {
        $this->operators = Values::array_get($payload, 'operators');
        $this->triggers = Values::array_get($payload, 'triggers');
        $this->actions = Values::array_get($payload, 'actions');
        $this->context = Values::array_get($payload, 'context');
    }

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

    public function jsonSerialize(): array
    {
        $jsonString = [
            'operators' => $this->operators,
            'actions' => $this->actions
        ];
        if (isset($this->triggers)) {
            $jsonString['triggers'] = $this->triggers;
        }
        if (isset($this->context)) {
            $jsonString['context'] = $this->context;
        }
        return $jsonString;
    }
}

class CreateConfigurationRequest implements \JsonSerializable
{
    /**
     * @property string $displayName The display name of the Intelligence Configuration describing its purpose.
     * @property string $description The description of the Intelligence Configuration further explaining its purpose.
     * @property RuleCreationRequestPayload[] $rules List of Intelligence Configuration Rules that govern when and how Language Operators run. Each Rule represents a bundle of Operators, Triggers, Context, and Actions to be executed by the Intelligence Configuration on a Conversation. A maximum of five (5) Rules are allowed per Intelligence Configuration.  To create an Intelligence Configuration without any Rules configured yet, pass an empty array (`\"rules\": []`). The Configuration will not execute any Language Operators until at least one Rule has been added.
    */
        protected $displayName;
        protected $description;
        protected $rules;
    public function __construct(array $payload = []) {
        $this->displayName = Values::array_get($payload, 'displayName');
        $this->description = Values::array_get($payload, 'description');
        $this->rules = Values::array_get($payload, 'rules');
    }

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

    public function jsonSerialize(): array
    {
        $jsonString = [
            'displayName' => $this->displayName,
            'rules' => $this->rules
        ];
        if (isset($this->description)) {
            $jsonString['description'] = $this->description;
        }
        return $jsonString;
    }
}

class RuleUpdateRequestPayload implements \JsonSerializable
{
    /**
     * @property string $id Optional field used when updating an existing Rule within an Intelligence Configuration. When provided, the Rule with this `id` is updated; when omitted, a new Rule is created.
     * @property Operator[] $operators List of Operators to be executed by the Rule. Minimum of one (1) and maximum of five (5) Operators allowed per Rule.
     * @property Trigger[] $triggers List of Triggers that determine when to activate the Rule. Maximum of one (1) Trigger allowed per Rule.
     * @property Action[] $actions List of Actions to be performed after the Rule is triggered. Maximum of two (2) Actions allowed per Rule.
     * @property Context $context
    */
        protected $id;
        protected $operators;
        protected $triggers;
        protected $actions;
        protected $context;
    public function __construct(array $payload = []) {
        $this->id = Values::array_get($payload, 'id');
        $this->operators = Values::array_get($payload, 'operators');
        $this->triggers = Values::array_get($payload, 'triggers');
        $this->actions = Values::array_get($payload, 'actions');
        $this->context = Values::array_get($payload, 'context');
    }

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

    public function jsonSerialize(): array
    {
        $jsonString = [
            'operators' => $this->operators,
            'actions' => $this->actions
        ];
        if (isset($this->id)) {
            $jsonString['id'] = $this->id;
        }
        if (isset($this->triggers)) {
            $jsonString['triggers'] = $this->triggers;
        }
        if (isset($this->context)) {
            $jsonString['context'] = $this->context;
        }
        return $jsonString;
    }
}

class UpdateConfigurationRequest implements \JsonSerializable
{
    /**
     * @property string $displayName The display name of the Intelligence Configuration describing its purpose.
     * @property string $description The description of the Intelligence Configuration further explaining its purpose.
     * @property RuleUpdateRequestPayload[] $rules List of Intelligence Configuration Rules that govern when and how Language Operators run. Each Rule represents a bundle of Operators, Triggers, Context, and Actions to be executed by the Intelligence Configuration on a Conversation. A maximum of five (5) Rules are allowed per Intelligence Configuration.
    */
        protected $displayName;
        protected $description;
        protected $rules;
    public function __construct(array $payload = []) {
        $this->displayName = Values::array_get($payload, 'displayName');
        $this->description = Values::array_get($payload, 'description');
        $this->rules = Values::array_get($payload, 'rules');
    }

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

    public function jsonSerialize(): array
    {
        $jsonString = [
            'displayName' => $this->displayName,
            'rules' => $this->rules
        ];
        if (isset($this->description)) {
            $jsonString['description'] = $this->description;
        }
        return $jsonString;
    }
}

