<?php

/**
 * This code was generated by
 * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
 *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
 *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
 *
 * Conversation Orchestrator
 * Manage configurations, conversations, participants, and communications. Create configurations to define capture rules and channel settings, then use conversations to group related communications.
 *
 * NOTE: This class is auto generated by OpenAPI Generator.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Twilio\Rest\Conversations\V2;

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 ActionList extends ListResource
    {
    /**
     * Construct the ActionList
     *
     * @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 CreateConversationActionRequest $createConversationActionRequest The action to perform.
     
     * @return Response Created Response
     * @throws TwilioException When an HTTP error occurs.
     */
    private function _create(string $conversationId, CreateConversationActionRequest $createConversationActionRequest): Response
    {
        
        $uri = '/Conversations/' . \rawurlencode($conversationId)
        .'/Actions';
        
        $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/json' ]);
        $data = $createConversationActionRequest->toArray();
        return $this->version->handleRequest('POST', $uri, [], $data, $headers, "create");
    }

    /**
     * Create the CreateConversationAction202ResponseInstance
     *
     
     * @param CreateConversationActionRequest $createConversationActionRequest The action to perform.
     
     * @return CreateConversationAction202ResponseInstance Created CreateConversationAction202ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function create(string $conversationId, CreateConversationActionRequest $createConversationActionRequest): CreateConversationAction202ResponseInstance
    {
        $response = $this->_create($conversationId,  $createConversationActionRequest);
        return new CreateConversationAction202ResponseInstance(
            $this->version,
            $response->getContent(),
            $conversationId
        );
        
    }

    /**
     * Create the CreateConversationAction202ResponseInstance with Metadata
     *
     
     * @param CreateConversationActionRequest $createConversationActionRequest The action to perform.
     
     * @return ResourceMetadata The Created Resource with Metadata
     * @throws TwilioException When an HTTP error occurs.
     */
    public function createWithMetadata(string $conversationId, CreateConversationActionRequest $createConversationActionRequest): ResourceMetadata
    {
        $response = $this->_create($conversationId,  $createConversationActionRequest);
        $resource = new CreateConversationAction202ResponseInstance(
                        $this->version,
                        $response->getContent(),
                        $conversationId
                    );
        
        return new ResourceMetadata(
            $resource,
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }


    /**
     * Constructs a ActionContext
     *
     * @param string $conversationId
     *
     * @param string $actionId
     */
    public function getContext(
        string $conversationId
        , string $actionId
        
    ): ActionContext
    {
        return new ActionContext(
            $this->version,
            $conversationId,
            $actionId
        );
    }

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