<?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\Values;
use Twilio\Version;
use Twilio\ApiV1Version;
use Twilio\InstanceContext;
use Twilio\Http\Response;
use Twilio\Metadata\ResourceMetadata;


class BulkContext extends InstanceContext
    {
    /**
     * Initialize the BulkContext
     *
     * @param Version $version Version that contains the resource
     * @param string $storeId A unique Memory Store ID using Twilio Type ID (TTID) format
     */
    public function __construct(
        Version $version,
        $storeId
    ) {
        $apiV1Version = new ApiV1Version($version->getDomain(), $version->version);
        parent::__construct($apiV1Version);

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

        $this->uri = '/Stores/' . \rawurlencode($storeId)
        .'/Profiles/Bulk';
    }

    /**
     * Helper function for Update
     *
     
     * @param UpdateProfilesBulkRequest $updateProfilesBulkRequest
     
     * @return Response Updated Response
     * @throws TwilioException When an HTTP error occurs.
     */
    private function _update(UpdateProfilesBulkRequest $updateProfilesBulkRequest): Response
    {
        
        $headers = Values::of(['Content-Type' => 'application/json', 'Accept' => 'application/json' ]);
        $data = $updateProfilesBulkRequest->toArray();
        return $this->version->handleRequest('PUT', $this->uri, [], $data, $headers, "update");
    }

    /**
     * Update the UpdateProfilesBulk202ResponseInstance
     *
     
     * @param UpdateProfilesBulkRequest $updateProfilesBulkRequest
     
     * @return UpdateProfilesBulk202ResponseInstance Updated UpdateProfilesBulk202ResponseInstance
     * @throws TwilioException When an HTTP error occurs.
     */
    public function update(UpdateProfilesBulkRequest $updateProfilesBulkRequest): UpdateProfilesBulk202ResponseInstance
    {
        $response = $this->_update( $updateProfilesBulkRequest);
        return new UpdateProfilesBulk202ResponseInstance(
            $this->version,
            $response->getContent(),
            $this->solution['storeId']
        );
        
    }

    /**
     * Update the UpdateProfilesBulk202ResponseInstance with Metadata
     *
     
     * @param UpdateProfilesBulkRequest $updateProfilesBulkRequest
     
     * @return ResourceMetadata The Updated Resource with Metadata
     * @throws TwilioException When an HTTP error occurs.
     */
    public function updateWithMetadata(UpdateProfilesBulkRequest $updateProfilesBulkRequest): ResourceMetadata
    {
        $response = $this->_update( $updateProfilesBulkRequest);
        $resource = new UpdateProfilesBulk202ResponseInstance(
                        $this->version,
                        $response->getContent(),
                        $this->solution['storeId']
                    );
        
        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.Memory.V1.BulkContext ' . \implode(' ', $context) . ']';
    }
}
