<?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\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\ApiV1Version;


/**
 * @property string $id
 * @property string $displayName
 * @property string $description
 * @property int $version
 * @property string $author
 * @property string $prompt
 * @property string $outputFormat
 * @property array $outputSchema
 * @property string[] $trainingExamples
 * @property string $context
 * @property string $parameters
 */
class CreateOperator201ResponseInstance extends InstanceResource
{
    /**
     * Initialize the CreateOperator201ResponseInstance
     *
     * @param Version $version Version that contains the resource
     * @param mixed[] $payload The response payload
     * @param string $id The unique identifier (TTID) of the Language Operator.
     */
    public function __construct(Version $version, array $payload, ?string $id = null)
    {
        $apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
        parent::__construct($apiV1Version);

        // Marshaled Properties
        $this->properties = [
            'id' => Values::array_get($payload, 'id'),
            'displayName' => Values::array_get($payload, 'displayName'),
            'description' => Values::array_get($payload, 'description'),
            'version' => Values::array_get($payload, 'version'),
            'author' => Values::array_get($payload, 'author'),
            'prompt' => Values::array_get($payload, 'prompt'),
            'outputFormat' => Values::array_get($payload, 'outputFormat'),
            'outputSchema' => Values::array_get($payload, 'outputSchema'),
            'trainingExamples' => Values::array_get($payload, 'trainingExamples'),
            'context' => Values::array_get($payload, 'context'),
            'parameters' => Values::array_get($payload, 'parameters'),
        ];

        $this->solution = ['id' => $id ?: ($this->properties['id'] ?? null), ];
    }

    /**
     * Generate an instance context for the instance, the context is capable of
     * performing various actions.  All instance actions are proxied to the context
     *
     * @return OperatorContext Context for this OperatorInstance
     */
    protected function proxy(): OperatorContext
    {
        if (!$this->context) {
            $this->context = new OperatorContext(
                $this->version,
                $this->solution['id']
            );
        }

        return $this->context;
    }

    /**
     * Delete the Instance
     *
     * @return bool True if delete succeeds, false otherwise
     * @throws TwilioException When an HTTP error occurs.
     */
    public function delete(): bool
    {

        return $this->proxy()->delete();
    }

    /**
     * Fetch the CreateOperator201ResponseInstance
     *
     * @return CreateOperator201ResponseInstance Fetched CreateOperator201ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function fetch(): CreateOperator201ResponseInstance
    {

        return $this->proxy()->fetch();
    }

    /**
     * Update the CreateOperator201ResponseInstance
     *
     * @param LanguageOperator $languageOperator Full replacement of a Language Operator configuration
     * @param array|Options $options Optional Arguments
     * @return CreateOperator201ResponseInstance Updated CreateOperator201ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function update(LanguageOperator $languageOperator, array $options = []): CreateOperator201ResponseInstance
    {

        return $this->proxy()->update($languageOperator, $options);
    }

    /**
     * Magic getter to access properties
     *
     * @param string $name Property to access
     * @return mixed The requested property
     * @throws TwilioException For unknown properties
     */
    public function __get(string $name)
    {
        if (\array_key_exists($name, $this->properties)) {
            return $this->properties[$name];
        }

        if (\property_exists($this, '_' . $name)) {
            $method = 'get' . \ucfirst($name);
            return $this->$method();
        }

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

    /**
     * Provide a friendly representation
     *
     * @return string Machine friendly representation
     */
    public function __toString(): string
    {
        $context = [];
        foreach ($this->solution as $key => $value) {
            $context[] = "$key=$value";
        }
        return '[Twilio.Intelligence.V3.CreateOperator201ResponseInstance ' . \implode(' ', $context) . ']';
    }
}
