<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio API definition for public-api voice
 * Powers Twilio public-api voice
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


namespace Twilio\Rest\Voice\V3;

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


/**
 * @property string $status
 * @property string $statusUrl
 * @property string $transcription
 */
class VoiceV3TranscriptionLongRunningOperation202ResponseInstance extends InstanceResource
{
    /**
     * Initialize the VoiceV3TranscriptionLongRunningOperation202ResponseInstance
     *
     * @param Version $version Version that contains the resource
     * @param mixed[] $payload The response payload
     * @param string $transcriptionId The unique identifier of the transcription to fetch
     */
    public function __construct(Version $version, array $payload, ?string $transcriptionId = null)
    {
        $apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
        parent::__construct($apiV1Version);

        // Marshaled Properties
        $this->properties = [
            'status' => Values::array_get($payload, 'status'),
            'statusUrl' => Values::array_get($payload, 'statusUrl'),
            'transcription' => Values::array_get($payload, 'transcription'),
        ];

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

        return $this->context;
    }

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

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

    /**
     * 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.Voice.V3.VoiceV3TranscriptionLongRunningOperation202ResponseInstance ' . \implode(' ', $context) . ']';
    }
}
