<?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 OutboundContext extends InstanceContext
    {
    /**
     * Initialize the OutboundContext
     *
     * @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/Outbound';
    }

    /**
     * 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 OutboundInstance
     *
     * @param ?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest
     * @return OutboundInstance Created OutboundInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function create(?InsightsV2CreatePhoneNumbersReportRequest $insightsV2CreatePhoneNumbersReportRequest = null): OutboundInstance
    {
        $response = $this->_create($insightsV2CreatePhoneNumbersReportRequest);
        return new OutboundInstance(
            $this->version,
            $response->getContent()
        );
        
    }

    /**
     * Create the OutboundInstance 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 OutboundInstance(
                        $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.OutboundContext ' . \implode(' ', $context) . ']';
    }
}
