<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Sample/reference Twilio API.
 * This is the reference API for the rest-proxy server.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


namespace Twilio\Rest\Insights\V2;

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


class InboundContext extends InstanceContext
    {
    /**
     * Initialize the InboundContext
     *
     * @param Version $version Version that contains the resource
     * @param string $reportId A unique Report Id.
     */
    public function __construct(
        Version $version,
        $reportId
    ) {
        parent::__construct($version);

        // Path Solution
        $this->solution = [
        'reportId' =>
            $reportId,
        ];

        $this->uri = '/Voice/Reports/PhoneNumbers/Inbound';
    }

    /**
     * Helper function for Create
     *
     * @param ?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest
     * @return Response Created Response
     * @throws TwilioException When an HTTP error occurs.
     */
    private function _create(?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest = null): Response
    {
        
        $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/json' ]);
        $data = $insightsV2CreatePhoneNumbersReportRequest ? $insightsV2CreatePhoneNumbersReportRequest->toArray() : [];
        return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
    }

    /**
     * Create the InboundInstance
     *
     * @param ?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest
     * @return InboundInstance Created InboundInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function create(?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest = null): InboundInstance
    {
        $response = $this->_create($insightsV2CreatePhoneNumbersReportRequest);
        return new InboundInstance(
            $this->version,
            $response->getContent()
        );
        
    }

    /**
     * Create the InboundInstance with Metadata
     *
     * @param ?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest
     * @return ResourceMetadata The Created Resource with Metadata
     * @throws TwilioException When an HTTP error occurs.
     */
    public function createWithMetadata(?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest = null): ResourceMetadata
    {
        $response = $this->_create($insightsV2CreatePhoneNumbersReportRequest);
        $resource = new InboundInstance(
                        $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
    {
        $context = [];
        foreach ($this->solution as $key => $value) {
            $context[] = "$key=$value";
        }
        return '[Twilio.Insights.V2.InboundContext ' . \implode(' ', $context) . ']';
    }
}
