<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio Knowledge API
 * APIs for managing knowledge bases and knowledge content for AI-powered applications.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


namespace Twilio\Rest\Knowledge\V2;

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


/**
 * @property string $content
 * @property \DateTime $createdAt
 */
class KnowledgeChunkInstance extends InstanceResource
{
    /**
     * Initialize the KnowledgeChunkInstance
     *
     * @param Version $version Version that contains the resource
     * @param mixed[] $payload The response payload
     * @param string $kbId A unique Knowledge Base ID using Twilio Type ID (TTID) format
     * @param string $knowledgeId A unique Knowledge resource ID using Twilio Type ID (TTID) format
     */
    public function __construct(Version $version, array $payload, ?string $kbId = null, ?string $knowledgeId = null)
    {
        $apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
        parent::__construct($apiV1Version);

        // Marshaled Properties
        $this->properties = [
            'content' => Values::array_get($payload, 'content'),
            'createdAt' => Deserialize::dateTime(Values::array_get($payload, 'createdAt')),
        ];

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

    /**
     * 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
    {
        return '[Twilio.Knowledge.V2.KnowledgeChunkInstance]';
    }
}
