<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Conversation Orchestrator
 * Manage configurations, conversations, participants, and communications. Create configurations to define capture rules and channel settings, then use conversations to group related communications.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


namespace Twilio\Rest\Conversations\V2;

use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\ApiV1Version;
use Twilio\Deserialize;


/**
 * @property string $id
 * @property string $displayName
 * @property string $description
 * @property string $conversationGroupingType
 * @property string $memoryStoreId
 * @property string $channelSettings
 * @property string[] $statusCallbacks
 * @property string[] $intelligenceConfigurationIds
 * @property bool $memoryExtractionEnabled
 * @property string $conversationsV1Bridge
 * @property \DateTime $createdAt
 * @property \DateTime $updatedAt
 * @property int $version
 */
class ListConfiguration200ResponseConfigurationsInstance extends InstanceResource
{
    /**
     * Initialize the ListConfiguration200ResponseConfigurationsInstance
     *
     * @param Version $version Version that contains the resource
     * @param mixed[] $payload The response payload
     * @param string $sid
     */
    public function __construct(Version $version, array $payload, ?string $sid = 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'),
            'conversationGroupingType' => Values::array_get($payload, 'conversationGroupingType'),
            'memoryStoreId' => Values::array_get($payload, 'memoryStoreId'),
            'channelSettings' => Values::array_get($payload, 'channelSettings'),
            'statusCallbacks' => Values::array_get($payload, 'statusCallbacks'),
            'intelligenceConfigurationIds' => Values::array_get($payload, 'intelligenceConfigurationIds'),
            'memoryExtractionEnabled' => Values::array_get($payload, 'memoryExtractionEnabled'),
            'conversationsV1Bridge' => Values::array_get($payload, 'conversationsV1Bridge'),
            'createdAt' => Deserialize::dateTime(Values::array_get($payload, 'createdAt')),
            'updatedAt' => Deserialize::dateTime(Values::array_get($payload, 'updatedAt')),
            'version' => Values::array_get($payload, 'version'),
        ];

        $this->solution = ['sid' => $sid ?: ($this->properties['sid'] ?? 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 ConfigurationContext Context for this ConfigurationInstance
     */
    protected function proxy(): ConfigurationContext
    {
        if (!$this->context) {
            $this->context = new ConfigurationContext(
                $this->version,
                $this->solution['sid']
            );
        }

        return $this->context;
    }

    /**
     * Delete the CreateConfiguration202ResponseInstance
     *
     * @param array|Options $options Optional Arguments
     * @return CreateConfiguration202ResponseInstance Deleted CreateConfiguration202ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function delete(array $options = []): CreateConfiguration202ResponseInstance
    {

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

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

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

    /**
     * Update the CreateConfiguration202ResponseInstance
     *
     * @param array|Options $options Optional Arguments
     * @return CreateConfiguration202ResponseInstance Updated CreateConfiguration202ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function update(array $options = []): CreateConfiguration202ResponseInstance
    {

        return $this->proxy()->update($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.Conversations.V2.ListConfiguration200ResponseConfigurationsInstance ' . \implode(' ', $context) . ']';
    }
}
