File manager - Edit - /var/www/payraty/helpdesk/vendor/muxinc/mux-php/MuxPhp/Api/AssetsApi.php
Back
<?php /** * AssetsApi * PHP version 7.2 * * @category Class * @package MuxPhp * @author Mux API team * @link https://docs.mux.com */ /** * Mux API * * Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before. * * The version of the OpenAPI document: v1 * Contact: devex@mux.com * Generated by: https://openapi-generator.tech * OpenAPI Generator version: 5.0.1 */ /** * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ namespace MuxPhp\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use MuxPhp\ApiException; use MuxPhp\Configuration; use MuxPhp\HeaderSelector; use MuxPhp\ObjectSerializer; /** * AssetsApi Class Doc Comment * * @category Class * @package MuxPhp * @author Mux API team * @link https://docs.mux.com */ class AssetsApi { /** * @var ClientInterface */ protected $client; /** * @var Configuration */ protected $config; /** * @var HeaderSelector */ protected $headerSelector; /** * @var int Host index */ protected $hostIndex; /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, HeaderSelector $selector = null, $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } /** * Set the host index * * @param int $hostIndex Host index (required) */ public function setHostIndex($hostIndex) { $this->hostIndex = $hostIndex; } /** * Get the host index * * @return int Host index */ public function getHostIndex() { return $this->hostIndex; } /** * @return Configuration */ public function getConfig() { return $this->config; } /** * Operation createAsset * * Create an asset * * @param \MuxPhp\Models\CreateAssetRequest $create_asset_request create_asset_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\AssetResponse */ public function createAsset($create_asset_request) { list($response) = $this->createAssetWithHttpInfo($create_asset_request); return $response; } /** * Operation createAssetWithHttpInfo * * Create an asset * * @param \MuxPhp\Models\CreateAssetRequest $create_asset_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\AssetResponse, HTTP status code, HTTP response headers (array of strings) */ public function createAssetWithHttpInfo($create_asset_request) { $request = $this->createAssetRequest($create_asset_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 201: if ('\MuxPhp\Models\AssetResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\AssetResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\AssetResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 201: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\AssetResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation createAssetAsync * * Create an asset * * @param \MuxPhp\Models\CreateAssetRequest $create_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetAsync($create_asset_request) { return $this->createAssetAsyncWithHttpInfo($create_asset_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation createAssetAsyncWithHttpInfo * * Create an asset * * @param \MuxPhp\Models\CreateAssetRequest $create_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetAsyncWithHttpInfo($create_asset_request) { $returnType = '\MuxPhp\Models\AssetResponse'; $request = $this->createAssetRequest($create_asset_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'createAsset' * * @param \MuxPhp\Models\CreateAssetRequest $create_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function createAssetRequest($create_asset_request) { // verify the required parameter 'create_asset_request' is set if ($create_asset_request === null || (is_array($create_asset_request) && count($create_asset_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $create_asset_request when calling createAsset' ); } $resourcePath = '/video/v1/assets'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($create_asset_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_asset_request)); } else { $httpBody = $create_asset_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation createAssetPlaybackId * * Create a playback ID * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreatePlaybackIDRequest $create_playback_id_request create_playback_id_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\CreatePlaybackIDResponse */ public function createAssetPlaybackId($asset_id, $create_playback_id_request) { list($response) = $this->createAssetPlaybackIdWithHttpInfo($asset_id, $create_playback_id_request); return $response; } /** * Operation createAssetPlaybackIdWithHttpInfo * * Create a playback ID * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreatePlaybackIDRequest $create_playback_id_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\CreatePlaybackIDResponse, HTTP status code, HTTP response headers (array of strings) */ public function createAssetPlaybackIdWithHttpInfo($asset_id, $create_playback_id_request) { $request = $this->createAssetPlaybackIdRequest($asset_id, $create_playback_id_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 201: if ('\MuxPhp\Models\CreatePlaybackIDResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\CreatePlaybackIDResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\CreatePlaybackIDResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 201: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\CreatePlaybackIDResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation createAssetPlaybackIdAsync * * Create a playback ID * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreatePlaybackIDRequest $create_playback_id_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetPlaybackIdAsync($asset_id, $create_playback_id_request) { return $this->createAssetPlaybackIdAsyncWithHttpInfo($asset_id, $create_playback_id_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation createAssetPlaybackIdAsyncWithHttpInfo * * Create a playback ID * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreatePlaybackIDRequest $create_playback_id_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetPlaybackIdAsyncWithHttpInfo($asset_id, $create_playback_id_request) { $returnType = '\MuxPhp\Models\CreatePlaybackIDResponse'; $request = $this->createAssetPlaybackIdRequest($asset_id, $create_playback_id_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'createAssetPlaybackId' * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreatePlaybackIDRequest $create_playback_id_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function createAssetPlaybackIdRequest($asset_id, $create_playback_id_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling createAssetPlaybackId' ); } // verify the required parameter 'create_playback_id_request' is set if ($create_playback_id_request === null || (is_array($create_playback_id_request) && count($create_playback_id_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $create_playback_id_request when calling createAssetPlaybackId' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/playback-ids'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($create_playback_id_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_playback_id_request)); } else { $httpBody = $create_playback_id_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation createAssetTrack * * Create an asset track * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreateTrackRequest $create_track_request create_track_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\CreateTrackResponse */ public function createAssetTrack($asset_id, $create_track_request) { list($response) = $this->createAssetTrackWithHttpInfo($asset_id, $create_track_request); return $response; } /** * Operation createAssetTrackWithHttpInfo * * Create an asset track * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreateTrackRequest $create_track_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\CreateTrackResponse, HTTP status code, HTTP response headers (array of strings) */ public function createAssetTrackWithHttpInfo($asset_id, $create_track_request) { $request = $this->createAssetTrackRequest($asset_id, $create_track_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 201: if ('\MuxPhp\Models\CreateTrackResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\CreateTrackResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\CreateTrackResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 201: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\CreateTrackResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation createAssetTrackAsync * * Create an asset track * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreateTrackRequest $create_track_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetTrackAsync($asset_id, $create_track_request) { return $this->createAssetTrackAsyncWithHttpInfo($asset_id, $create_track_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation createAssetTrackAsyncWithHttpInfo * * Create an asset track * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreateTrackRequest $create_track_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createAssetTrackAsyncWithHttpInfo($asset_id, $create_track_request) { $returnType = '\MuxPhp\Models\CreateTrackResponse'; $request = $this->createAssetTrackRequest($asset_id, $create_track_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'createAssetTrack' * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\CreateTrackRequest $create_track_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function createAssetTrackRequest($asset_id, $create_track_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling createAssetTrack' ); } // verify the required parameter 'create_track_request' is set if ($create_track_request === null || (is_array($create_track_request) && count($create_track_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $create_track_request when calling createAssetTrack' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/tracks'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($create_track_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_track_request)); } else { $httpBody = $create_track_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation deleteAsset * * Delete an asset * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ public function deleteAsset($asset_id) { $this->deleteAssetWithHttpInfo($asset_id); } /** * Operation deleteAssetWithHttpInfo * * Delete an asset * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteAssetWithHttpInfo($asset_id) { $request = $this->deleteAssetRequest($asset_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { switch ($e->getCode()) { } throw $e; } } /** * Operation deleteAssetAsync * * Delete an asset * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetAsync($asset_id) { return $this->deleteAssetAsyncWithHttpInfo($asset_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation deleteAssetAsyncWithHttpInfo * * Delete an asset * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetAsyncWithHttpInfo($asset_id) { $returnType = ''; $request = $this->deleteAssetRequest($asset_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'deleteAsset' * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function deleteAssetRequest($asset_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling deleteAsset' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( [] ); } else { $headers = $this->headerSelector->selectHeaders( [], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation deleteAssetPlaybackId * * Delete a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ public function deleteAssetPlaybackId($asset_id, $playback_id) { $this->deleteAssetPlaybackIdWithHttpInfo($asset_id, $playback_id); } /** * Operation deleteAssetPlaybackIdWithHttpInfo * * Delete a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteAssetPlaybackIdWithHttpInfo($asset_id, $playback_id) { $request = $this->deleteAssetPlaybackIdRequest($asset_id, $playback_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { switch ($e->getCode()) { } throw $e; } } /** * Operation deleteAssetPlaybackIdAsync * * Delete a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetPlaybackIdAsync($asset_id, $playback_id) { return $this->deleteAssetPlaybackIdAsyncWithHttpInfo($asset_id, $playback_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation deleteAssetPlaybackIdAsyncWithHttpInfo * * Delete a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetPlaybackIdAsyncWithHttpInfo($asset_id, $playback_id) { $returnType = ''; $request = $this->deleteAssetPlaybackIdRequest($asset_id, $playback_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'deleteAssetPlaybackId' * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function deleteAssetPlaybackIdRequest($asset_id, $playback_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling deleteAssetPlaybackId' ); } // verify the required parameter 'playback_id' is set if ($playback_id === null || (is_array($playback_id) && count($playback_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_id when calling deleteAssetPlaybackId' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/playback-ids/{PLAYBACK_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } // path params if ($playback_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_ID' . '}', ObjectSerializer::toPathValue($playback_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( [] ); } else { $headers = $this->headerSelector->selectHeaders( [], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation deleteAssetTrack * * Delete an asset track * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ public function deleteAssetTrack($asset_id, $track_id) { $this->deleteAssetTrackWithHttpInfo($asset_id, $track_id); } /** * Operation deleteAssetTrackWithHttpInfo * * Delete an asset track * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteAssetTrackWithHttpInfo($asset_id, $track_id) { $request = $this->deleteAssetTrackRequest($asset_id, $track_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } return [null, $statusCode, $response->getHeaders()]; } catch (ApiException $e) { switch ($e->getCode()) { } throw $e; } } /** * Operation deleteAssetTrackAsync * * Delete an asset track * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetTrackAsync($asset_id, $track_id) { return $this->deleteAssetTrackAsyncWithHttpInfo($asset_id, $track_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation deleteAssetTrackAsyncWithHttpInfo * * Delete an asset track * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteAssetTrackAsyncWithHttpInfo($asset_id, $track_id) { $returnType = ''; $request = $this->deleteAssetTrackRequest($asset_id, $track_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'deleteAssetTrack' * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function deleteAssetTrackRequest($asset_id, $track_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling deleteAssetTrack' ); } // verify the required parameter 'track_id' is set if ($track_id === null || (is_array($track_id) && count($track_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $track_id when calling deleteAssetTrack' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/tracks/{TRACK_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } // path params if ($track_id !== null) { $resourcePath = str_replace( '{' . 'TRACK_ID' . '}', ObjectSerializer::toPathValue($track_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( [] ); } else { $headers = $this->headerSelector->selectHeaders( [], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation generateAssetTrackSubtitles * * Generate track subtitles * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * @param \MuxPhp\Models\GenerateTrackSubtitlesRequest $generate_track_subtitles_request generate_track_subtitles_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GenerateTrackSubtitlesResponse */ public function generateAssetTrackSubtitles($asset_id, $track_id, $generate_track_subtitles_request) { list($response) = $this->generateAssetTrackSubtitlesWithHttpInfo($asset_id, $track_id, $generate_track_subtitles_request); return $response; } /** * Operation generateAssetTrackSubtitlesWithHttpInfo * * Generate track subtitles * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * @param \MuxPhp\Models\GenerateTrackSubtitlesRequest $generate_track_subtitles_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GenerateTrackSubtitlesResponse, HTTP status code, HTTP response headers (array of strings) */ public function generateAssetTrackSubtitlesWithHttpInfo($asset_id, $track_id, $generate_track_subtitles_request) { $request = $this->generateAssetTrackSubtitlesRequest($asset_id, $track_id, $generate_track_subtitles_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 201: if ('\MuxPhp\Models\GenerateTrackSubtitlesResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GenerateTrackSubtitlesResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GenerateTrackSubtitlesResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 201: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GenerateTrackSubtitlesResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation generateAssetTrackSubtitlesAsync * * Generate track subtitles * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * @param \MuxPhp\Models\GenerateTrackSubtitlesRequest $generate_track_subtitles_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function generateAssetTrackSubtitlesAsync($asset_id, $track_id, $generate_track_subtitles_request) { return $this->generateAssetTrackSubtitlesAsyncWithHttpInfo($asset_id, $track_id, $generate_track_subtitles_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation generateAssetTrackSubtitlesAsyncWithHttpInfo * * Generate track subtitles * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * @param \MuxPhp\Models\GenerateTrackSubtitlesRequest $generate_track_subtitles_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function generateAssetTrackSubtitlesAsyncWithHttpInfo($asset_id, $track_id, $generate_track_subtitles_request) { $returnType = '\MuxPhp\Models\GenerateTrackSubtitlesResponse'; $request = $this->generateAssetTrackSubtitlesRequest($asset_id, $track_id, $generate_track_subtitles_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'generateAssetTrackSubtitles' * * @param string $asset_id The asset ID. (required) * @param string $track_id The track ID. (required) * @param \MuxPhp\Models\GenerateTrackSubtitlesRequest $generate_track_subtitles_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function generateAssetTrackSubtitlesRequest($asset_id, $track_id, $generate_track_subtitles_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling generateAssetTrackSubtitles' ); } // verify the required parameter 'track_id' is set if ($track_id === null || (is_array($track_id) && count($track_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $track_id when calling generateAssetTrackSubtitles' ); } // verify the required parameter 'generate_track_subtitles_request' is set if ($generate_track_subtitles_request === null || (is_array($generate_track_subtitles_request) && count($generate_track_subtitles_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $generate_track_subtitles_request when calling generateAssetTrackSubtitles' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/tracks/{TRACK_ID}/generate-subtitles'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } // path params if ($track_id !== null) { $resourcePath = str_replace( '{' . 'TRACK_ID' . '}', ObjectSerializer::toPathValue($track_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($generate_track_subtitles_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($generate_track_subtitles_request)); } else { $httpBody = $generate_track_subtitles_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getAsset * * Retrieve an asset * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\AssetResponse */ public function getAsset($asset_id) { list($response) = $this->getAssetWithHttpInfo($asset_id); return $response; } /** * Operation getAssetWithHttpInfo * * Retrieve an asset * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\AssetResponse, HTTP status code, HTTP response headers (array of strings) */ public function getAssetWithHttpInfo($asset_id) { $request = $this->getAssetRequest($asset_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\AssetResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\AssetResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\AssetResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\AssetResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getAssetAsync * * Retrieve an asset * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetAsync($asset_id) { return $this->getAssetAsyncWithHttpInfo($asset_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation getAssetAsyncWithHttpInfo * * Retrieve an asset * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetAsyncWithHttpInfo($asset_id) { $returnType = '\MuxPhp\Models\AssetResponse'; $request = $this->getAssetRequest($asset_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getAsset' * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getAssetRequest($asset_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling getAsset' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getAssetInputInfo * * Retrieve asset input info * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GetAssetInputInfoResponse */ public function getAssetInputInfo($asset_id) { list($response) = $this->getAssetInputInfoWithHttpInfo($asset_id); return $response; } /** * Operation getAssetInputInfoWithHttpInfo * * Retrieve asset input info * * @param string $asset_id The asset ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GetAssetInputInfoResponse, HTTP status code, HTTP response headers (array of strings) */ public function getAssetInputInfoWithHttpInfo($asset_id) { $request = $this->getAssetInputInfoRequest($asset_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\GetAssetInputInfoResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GetAssetInputInfoResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GetAssetInputInfoResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GetAssetInputInfoResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getAssetInputInfoAsync * * Retrieve asset input info * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetInputInfoAsync($asset_id) { return $this->getAssetInputInfoAsyncWithHttpInfo($asset_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation getAssetInputInfoAsyncWithHttpInfo * * Retrieve asset input info * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetInputInfoAsyncWithHttpInfo($asset_id) { $returnType = '\MuxPhp\Models\GetAssetInputInfoResponse'; $request = $this->getAssetInputInfoRequest($asset_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getAssetInputInfo' * * @param string $asset_id The asset ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getAssetInputInfoRequest($asset_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling getAssetInputInfo' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/input-info'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getAssetPlaybackId * * Retrieve a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GetAssetPlaybackIDResponse */ public function getAssetPlaybackId($asset_id, $playback_id) { list($response) = $this->getAssetPlaybackIdWithHttpInfo($asset_id, $playback_id); return $response; } /** * Operation getAssetPlaybackIdWithHttpInfo * * Retrieve a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GetAssetPlaybackIDResponse, HTTP status code, HTTP response headers (array of strings) */ public function getAssetPlaybackIdWithHttpInfo($asset_id, $playback_id) { $request = $this->getAssetPlaybackIdRequest($asset_id, $playback_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\GetAssetPlaybackIDResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GetAssetPlaybackIDResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GetAssetPlaybackIDResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GetAssetPlaybackIDResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getAssetPlaybackIdAsync * * Retrieve a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetPlaybackIdAsync($asset_id, $playback_id) { return $this->getAssetPlaybackIdAsyncWithHttpInfo($asset_id, $playback_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation getAssetPlaybackIdAsyncWithHttpInfo * * Retrieve a playback ID * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getAssetPlaybackIdAsyncWithHttpInfo($asset_id, $playback_id) { $returnType = '\MuxPhp\Models\GetAssetPlaybackIDResponse'; $request = $this->getAssetPlaybackIdRequest($asset_id, $playback_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getAssetPlaybackId' * * @param string $asset_id The asset ID. (required) * @param string $playback_id The live stream's playback ID. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getAssetPlaybackIdRequest($asset_id, $playback_id) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling getAssetPlaybackId' ); } // verify the required parameter 'playback_id' is set if ($playback_id === null || (is_array($playback_id) && count($playback_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_id when calling getAssetPlaybackId' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/playback-ids/{PLAYBACK_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } // path params if ($playback_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_ID' . '}', ObjectSerializer::toPathValue($playback_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation listAssets * * List assets * * @param int $limit Number of items to include in the response (optional, default to 25) * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param string $live_stream_id Filter response to return all the assets for this live stream only (optional) * @param string $upload_id Filter response to return an asset created from this direct upload only (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\ListAssetsResponse */ public function listAssets($limit = 25, $page = 1, $live_stream_id = null, $upload_id = null) { list($response) = $this->listAssetsWithHttpInfo($limit, $page, $live_stream_id, $upload_id); return $response; } /** * Operation listAssetsWithHttpInfo * * List assets * * @param int $limit Number of items to include in the response (optional, default to 25) * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param string $live_stream_id Filter response to return all the assets for this live stream only (optional) * @param string $upload_id Filter response to return an asset created from this direct upload only (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\ListAssetsResponse, HTTP status code, HTTP response headers (array of strings) */ public function listAssetsWithHttpInfo($limit = 25, $page = 1, $live_stream_id = null, $upload_id = null) { $request = $this->listAssetsRequest($limit, $page, $live_stream_id, $upload_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\ListAssetsResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\ListAssetsResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\ListAssetsResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\ListAssetsResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation listAssetsAsync * * List assets * * @param int $limit Number of items to include in the response (optional, default to 25) * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param string $live_stream_id Filter response to return all the assets for this live stream only (optional) * @param string $upload_id Filter response to return an asset created from this direct upload only (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listAssetsAsync($limit = 25, $page = 1, $live_stream_id = null, $upload_id = null) { return $this->listAssetsAsyncWithHttpInfo($limit, $page, $live_stream_id, $upload_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation listAssetsAsyncWithHttpInfo * * List assets * * @param int $limit Number of items to include in the response (optional, default to 25) * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param string $live_stream_id Filter response to return all the assets for this live stream only (optional) * @param string $upload_id Filter response to return an asset created from this direct upload only (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listAssetsAsyncWithHttpInfo($limit = 25, $page = 1, $live_stream_id = null, $upload_id = null) { $returnType = '\MuxPhp\Models\ListAssetsResponse'; $request = $this->listAssetsRequest($limit, $page, $live_stream_id, $upload_id); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'listAssets' * * @param int $limit Number of items to include in the response (optional, default to 25) * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param string $live_stream_id Filter response to return all the assets for this live stream only (optional) * @param string $upload_id Filter response to return an asset created from this direct upload only (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function listAssetsRequest($limit = 25, $page = 1, $live_stream_id = null, $upload_id = null) { $resourcePath = '/video/v1/assets'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($limit !== null) { if('form' === 'form' && is_array($limit)) { foreach($limit as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['limit'] = $limit; } } // query params if ($page !== null) { if('form' === 'form' && is_array($page)) { foreach($page as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['page'] = $page; } } // query params if ($live_stream_id !== null) { if('form' === 'form' && is_array($live_stream_id)) { foreach($live_stream_id as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['live_stream_id'] = $live_stream_id; } } // query params if ($upload_id !== null) { if('form' === 'form' && is_array($upload_id)) { foreach($upload_id as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['upload_id'] = $upload_id; } } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation updateAsset * * Update an asset * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetRequest $update_asset_request update_asset_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\AssetResponse */ public function updateAsset($asset_id, $update_asset_request) { list($response) = $this->updateAssetWithHttpInfo($asset_id, $update_asset_request); return $response; } /** * Operation updateAssetWithHttpInfo * * Update an asset * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetRequest $update_asset_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\AssetResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateAssetWithHttpInfo($asset_id, $update_asset_request) { $request = $this->updateAssetRequest($asset_id, $update_asset_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\AssetResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\AssetResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\AssetResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\AssetResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateAssetAsync * * Update an asset * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetRequest $update_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetAsync($asset_id, $update_asset_request) { return $this->updateAssetAsyncWithHttpInfo($asset_id, $update_asset_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation updateAssetAsyncWithHttpInfo * * Update an asset * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetRequest $update_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetAsyncWithHttpInfo($asset_id, $update_asset_request) { $returnType = '\MuxPhp\Models\AssetResponse'; $request = $this->updateAssetRequest($asset_id, $update_asset_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'updateAsset' * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetRequest $update_asset_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function updateAssetRequest($asset_id, $update_asset_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling updateAsset' ); } // verify the required parameter 'update_asset_request' is set if ($update_asset_request === null || (is_array($update_asset_request) && count($update_asset_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $update_asset_request when calling updateAsset' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($update_asset_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_asset_request)); } else { $httpBody = $update_asset_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation updateAssetMasterAccess * * Update master access * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMasterAccessRequest $update_asset_master_access_request update_asset_master_access_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\AssetResponse */ public function updateAssetMasterAccess($asset_id, $update_asset_master_access_request) { list($response) = $this->updateAssetMasterAccessWithHttpInfo($asset_id, $update_asset_master_access_request); return $response; } /** * Operation updateAssetMasterAccessWithHttpInfo * * Update master access * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMasterAccessRequest $update_asset_master_access_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\AssetResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateAssetMasterAccessWithHttpInfo($asset_id, $update_asset_master_access_request) { $request = $this->updateAssetMasterAccessRequest($asset_id, $update_asset_master_access_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\AssetResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\AssetResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\AssetResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\AssetResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateAssetMasterAccessAsync * * Update master access * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMasterAccessRequest $update_asset_master_access_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetMasterAccessAsync($asset_id, $update_asset_master_access_request) { return $this->updateAssetMasterAccessAsyncWithHttpInfo($asset_id, $update_asset_master_access_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation updateAssetMasterAccessAsyncWithHttpInfo * * Update master access * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMasterAccessRequest $update_asset_master_access_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetMasterAccessAsyncWithHttpInfo($asset_id, $update_asset_master_access_request) { $returnType = '\MuxPhp\Models\AssetResponse'; $request = $this->updateAssetMasterAccessRequest($asset_id, $update_asset_master_access_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'updateAssetMasterAccess' * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMasterAccessRequest $update_asset_master_access_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function updateAssetMasterAccessRequest($asset_id, $update_asset_master_access_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling updateAssetMasterAccess' ); } // verify the required parameter 'update_asset_master_access_request' is set if ($update_asset_master_access_request === null || (is_array($update_asset_master_access_request) && count($update_asset_master_access_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $update_asset_master_access_request when calling updateAssetMasterAccess' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/master-access'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($update_asset_master_access_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_asset_master_access_request)); } else { $httpBody = $update_asset_master_access_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation updateAssetMp4Support * * Update MP4 support * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMP4SupportRequest $update_asset_mp4_support_request update_asset_mp4_support_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\AssetResponse */ public function updateAssetMp4Support($asset_id, $update_asset_mp4_support_request) { list($response) = $this->updateAssetMp4SupportWithHttpInfo($asset_id, $update_asset_mp4_support_request); return $response; } /** * Operation updateAssetMp4SupportWithHttpInfo * * Update MP4 support * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMP4SupportRequest $update_asset_mp4_support_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\AssetResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateAssetMp4SupportWithHttpInfo($asset_id, $update_asset_mp4_support_request) { $request = $this->updateAssetMp4SupportRequest($asset_id, $update_asset_mp4_support_request); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\AssetResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\AssetResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\AssetResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\AssetResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateAssetMp4SupportAsync * * Update MP4 support * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMP4SupportRequest $update_asset_mp4_support_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetMp4SupportAsync($asset_id, $update_asset_mp4_support_request) { return $this->updateAssetMp4SupportAsyncWithHttpInfo($asset_id, $update_asset_mp4_support_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation updateAssetMp4SupportAsyncWithHttpInfo * * Update MP4 support * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMP4SupportRequest $update_asset_mp4_support_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateAssetMp4SupportAsyncWithHttpInfo($asset_id, $update_asset_mp4_support_request) { $returnType = '\MuxPhp\Models\AssetResponse'; $request = $this->updateAssetMp4SupportRequest($asset_id, $update_asset_mp4_support_request); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'updateAssetMp4Support' * * @param string $asset_id The asset ID. (required) * @param \MuxPhp\Models\UpdateAssetMP4SupportRequest $update_asset_mp4_support_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function updateAssetMp4SupportRequest($asset_id, $update_asset_mp4_support_request) { // verify the required parameter 'asset_id' is set if ($asset_id === null || (is_array($asset_id) && count($asset_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $asset_id when calling updateAssetMp4Support' ); } // verify the required parameter 'update_asset_mp4_support_request' is set if ($update_asset_mp4_support_request === null || (is_array($update_asset_mp4_support_request) && count($update_asset_mp4_support_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $update_asset_mp4_support_request when calling updateAssetMp4Support' ); } $resourcePath = '/video/v1/assets/{ASSET_ID}/mp4-support'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($asset_id !== null) { $resourcePath = str_replace( '{' . 'ASSET_ID' . '}', ObjectSerializer::toPathValue($asset_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], ['application/json'] ); } // for model (json/xml) if (isset($update_asset_mp4_support_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_asset_mp4_support_request)); } else { $httpBody = $update_asset_mp4_support_request; } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Create http client option * * @throws \RuntimeException on file opening failure * @return array of http client options */ protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } return $options; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings