<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Twilio Memory API
 * APIs for managing memory stores, profiles, events, and conversational intelligence capabilities.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Memory\V1;

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 EventList extends ListResource
    {
    /**
     * Construct the EventList
     *
     * @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 Create
     *
     
     
     * @param ?ProfileEventRequest $profileEventRequest
     * @return Response Created Response
     * @throws TwilioException When an HTTP error occurs.
     */
    private function _create(string $storeId, string $profileId, ?ProfileEventRequest $profileEventRequest = null): Response
    {
        
        $uri = '/Stores/' . \rawurlencode($storeId)
        .'/Profiles/' . \rawurlencode($profileId)
        .'/Events';
        
        $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/json' ]);
        $data = $profileEventRequest ? $profileEventRequest->toArray() : [];
        return $this->version->handleRequest('POST', $uri, [], $data, $headers, "create");
    }

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

    /**
     * Create the CreateProfileEvents202ResponseInstance with Metadata
     *
     
     
     * @param ?ProfileEventRequest $profileEventRequest
     * @return ResourceMetadata The Created Resource with Metadata
     * @throws TwilioException When an HTTP error occurs.
     */
    public function createWithMetadata(string $storeId, string $profileId, ?ProfileEventRequest $profileEventRequest = null): ResourceMetadata
    {
        $response = $this->_create($storeId, $profileId, $profileEventRequest);
        $resource = new CreateProfileEvents202ResponseInstance(
                        $this->version,
                        $response->getContent(),
                        $storeId,
                        $profileId
                    );
        
        return new ResourceMetadata(
            $resource,
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }


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