<?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;

use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Intelligence\V3\ConfigurationList;
use Twilio\Rest\Intelligence\V3\ConversationList;
use Twilio\Rest\Intelligence\V3\OperatorList;
use Twilio\Rest\Intelligence\V3\OperatorResultList;
use Twilio\Rest\Intelligence\V3\VersionList;
use Twilio\Version;

/**
 * @property ConfigurationList $configurations
 * @property ConversationList $conversations
 * @property OperatorList $operators
 * @property OperatorResultList $operatorResults
 * @property VersionList $versions
 * @method \Twilio\Rest\Intelligence\V3\ConfigurationContext configurations(string $id)
 * @method \Twilio\Rest\Intelligence\V3\OperatorContext operators(string $id)
 * @method \Twilio\Rest\Intelligence\V3\VersionContext versions(string $id, string $version)
 * @method \Twilio\Rest\Intelligence\V3\OperatorResultContext operatorResults(string $operatorResultId)
 * @method \Twilio\Rest\Intelligence\V3\ConversationContext conversations(string $id)
 */
class V3 extends Version
{
    protected $_configurations;
    protected $_conversations;
    protected $_operators;
    protected $_operatorResults;
    protected $_versions;

    /**
     * Construct the V3 version of Intelligence
     *
     * @param Domain $domain Domain that contains the version
     */
    public function __construct(Domain $domain)
    {
        parent::__construct($domain);
        $this->version = 'v3';
    }

    protected function getConfigurations(): ConfigurationList
    {
        if (!$this->_configurations) {
            $this->_configurations = new ConfigurationList($this);
        }
        return $this->_configurations;
    }

    protected function getConversations(): ConversationList
    {
        if (!$this->_conversations) {
            $this->_conversations = new ConversationList($this);
        }
        return $this->_conversations;
    }

    protected function getOperators(): OperatorList
    {
        if (!$this->_operators) {
            $this->_operators = new OperatorList($this);
        }
        return $this->_operators;
    }

    protected function getOperatorResults(): OperatorResultList
    {
        if (!$this->_operatorResults) {
            $this->_operatorResults = new OperatorResultList($this);
        }
        return $this->_operatorResults;
    }

    protected function getVersions(): VersionList
    {
        if (!$this->_versions) {
            $this->_versions = new VersionList($this);
        }
        return $this->_versions;
    }

    /**
     * Magic getter to lazy load root resources
     *
     * @param string $name Resource to return
     * @return \Twilio\ListResource The requested resource
     * @throws TwilioException For unknown resource
     */
    public function __get(string $name)
    {
        $method = 'get' . \ucfirst($name);
        if (\method_exists($this, $method)) {
            return $this->$method();
        }

        throw new TwilioException('Unknown resource ' . $name);
    }

    /**
     * Magic caller to get resource contexts
     *
     * @param string $name Resource to return
     * @param array $arguments Context parameters
     * @return InstanceContext The requested resource context
     * @throws TwilioException For unknown resource
     */
    public function __call(string $name, array $arguments): InstanceContext
    {
        $property = $this->$name;
        if (\method_exists($property, 'getContext')) {
            return \call_user_func_array(array($property, 'getContext'), $arguments);
        }

        throw new TwilioException('Resource does not have a context');
    }

    /**
     * Provide a friendly representation
     *
     * @return string Machine friendly representation
     */
    public function __toString(): string
    {
        return '[Twilio.Intelligence.V3]';
    }
}
