src/ApiConnector.php
protected function updateResource(UriInterface $uri, string $content, string $type): ResponseInterface
    {
        // Verify the content type is allowed
        if (!\in_array($type, ['string', 'file'])) {
            throw new \InvalidArgumentException('The content type must be specified as file or string.');
        }

        $request = $this->createRequest('PUT', $uri);
        $request = $request->withHeader('Content-Type', 'application/json');

        if ($type == 'file') {
            if (!\file_exists($content)) {
                throw new \InvalidArgumentException(
                    \sprintf('The specified file, "%s", does not exist.', $content)
                );
            }

            $request = $request->withBody($this->streamFactory->createStreamFromFile($content));
        } else {
            $data = [
                'content' => $content,
            ];

            $request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
        }

        return $this->client->sendRequest($request);
    }
protected function updateResource(UriInterface $uri, string $content, string $type): ResponseInterface
    {
        // Verify the content type is allowed
        if (!\in_array($type, ['string', 'file'])) {
            throw new \InvalidArgumentException('The content type must be specified as file or string.');
        }

        $request = $this->createRequest('PUT', $uri);
        $request = $request->withHeader('Content-Type', 'application/json');

        if ($type == 'file') {
            if (!\file_exists($content)) {
                throw new \InvalidArgumentException(
                    \sprintf('The specified file, "%s", does not exist.', $content)
                );
            }

            $request = $request->withBody($this->streamFactory->createStreamFromFile($content));
        } else {
            $data = [
                'content' => $content,
            ];

            $request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));
        }

        return $this->client->sendRequest($request);
    }
protected function updateResource ( UriInterface $ uri , string $ content , string $ type ) : ResponseInterface { // Verify the content type is allowed if ( ! \ in_array ( $ type , [ 'string' , 'file' ] ) ) { throw new \ InvalidArgumentException ( 'The content type must be specified as file or string.' ) ; } $ request = $ this -> createRequest ( 'PUT' , $ uri ) ; $ request = $ request -> withHeader ( 'Content-Type' , 'application/json' ) ; if ( $ type == 'file' ) { if ( ! \ file_exists ( $ content ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The specified file, "%s", does not exist.' , $ content ) ) ; } $ request = $ request -> withBody ( $ this -> streamFactory -> createStreamFromFile ( $ content ) ) ; } else { $ data = [ 'content' => $ content , ] ; $ request = $ request -> withBody ( $ this -> streamFactory -> createStream ( \ json_encode ( $ data ) ) ) ; } return $ this -> client -> sendRequest ( $ request ) ; }
Update an API endpoint with resource content.

@param UriInterface $uri     URI object representing the API path to request
@param string       $content The content of the resource, this can either be a string of data or a file path
@param string       $type    The type of content in the $content variable, this should be either string or file

@return ResponseInterface

@throws \InvalidArgumentException
Update an API endpoint with resource content .