<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio - Insights
 * Insights Domain V3 API.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Insights\V3;

use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\ApiV1Version;
use Twilio\Http\Response;
use Twilio\Metadata\ResourceMetadata;


class MetadataList extends ListResource
    {
    /**
     * Construct the MetadataList
     *
     * @param Version $version Version that contains the resource
     */
    public function __construct(
        Version $version
    ) {
        $apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
        parent::__construct($apiV1Version);

        // Path Solution
        $this->solution = [
        ];
    }

    /**
     * Helper function for Fetch
     *
     * @return Response Fetched Response
     * @throws TwilioException When an HTTP error occurs.
     */
    private function _fetch(): Response
    {
        
        $uri = '/InsightsDomains/Conversations/Metadata';
        
        $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
        return $this->version->handleRequest('GET', $uri, [], [], $headers, "fetch");
    }

    /**
     * Fetch the InsightsMetadataResponseInstance
     *
     * @return InsightsMetadataResponseInstance Fetched InsightsMetadataResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function fetch(): InsightsMetadataResponseInstance
    {
        $response = $this->_fetch();
        return new InsightsMetadataResponseInstance(
            $this->version,
            $response->getContent()
        );
        
    }

    /**
     * Fetch the InsightsMetadataResponseInstance with Metadata
     *
     * @return ResourceMetadata The Fetched Resource with Metadata
     * @throws TwilioException When an HTTP error occurs.
     */
    public function fetchWithMetadata(): ResourceMetadata
    {
        $response = $this->_fetch();
        $resource = new InsightsMetadataResponseInstance(
                        $this->version,
                        $response->getContent()
                    );
        
        return new ResourceMetadata(
            $resource,
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }


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