File manager - Edit - /var/www/payraty/helpdesk/vendor/muxinc/mux-php/MuxPhp/Api/PlaybackRestrictionsApi.php
Back
<?php /** * PlaybackRestrictionsApi * 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; /** * PlaybackRestrictionsApi Class Doc Comment * * @category Class * @package MuxPhp * @author Mux API team * @link https://docs.mux.com */ class PlaybackRestrictionsApi { /** * @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 createPlaybackRestriction * * Create a Playback Restriction * * @param \MuxPhp\Models\CreatePlaybackRestrictionRequest $create_playback_restriction_request create_playback_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\PlaybackRestrictionResponse */ public function createPlaybackRestriction($create_playback_restriction_request) { list($response) = $this->createPlaybackRestrictionWithHttpInfo($create_playback_restriction_request); return $response; } /** * Operation createPlaybackRestrictionWithHttpInfo * * Create a Playback Restriction * * @param \MuxPhp\Models\CreatePlaybackRestrictionRequest $create_playback_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\PlaybackRestrictionResponse, HTTP status code, HTTP response headers (array of strings) */ public function createPlaybackRestrictionWithHttpInfo($create_playback_restriction_request) { $request = $this->createPlaybackRestrictionRequest($create_playback_restriction_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\PlaybackRestrictionResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\PlaybackRestrictionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $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\PlaybackRestrictionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation createPlaybackRestrictionAsync * * Create a Playback Restriction * * @param \MuxPhp\Models\CreatePlaybackRestrictionRequest $create_playback_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createPlaybackRestrictionAsync($create_playback_restriction_request) { return $this->createPlaybackRestrictionAsyncWithHttpInfo($create_playback_restriction_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation createPlaybackRestrictionAsyncWithHttpInfo * * Create a Playback Restriction * * @param \MuxPhp\Models\CreatePlaybackRestrictionRequest $create_playback_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createPlaybackRestrictionAsyncWithHttpInfo($create_playback_restriction_request) { $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $request = $this->createPlaybackRestrictionRequest($create_playback_restriction_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 'createPlaybackRestriction' * * @param \MuxPhp\Models\CreatePlaybackRestrictionRequest $create_playback_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function createPlaybackRestrictionRequest($create_playback_restriction_request) { // verify the required parameter 'create_playback_restriction_request' is set if ($create_playback_restriction_request === null || (is_array($create_playback_restriction_request) && count($create_playback_restriction_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $create_playback_restriction_request when calling createPlaybackRestriction' ); } $resourcePath = '/video/v1/playback-restrictions'; $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_playback_restriction_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($create_playback_restriction_request)); } else { $httpBody = $create_playback_restriction_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 deletePlaybackRestriction * * Delete a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ public function deletePlaybackRestriction($playback_restriction_id) { $this->deletePlaybackRestrictionWithHttpInfo($playback_restriction_id); } /** * Operation deletePlaybackRestrictionWithHttpInfo * * Delete a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (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 deletePlaybackRestrictionWithHttpInfo($playback_restriction_id) { $request = $this->deletePlaybackRestrictionRequest($playback_restriction_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 deletePlaybackRestrictionAsync * * Delete a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deletePlaybackRestrictionAsync($playback_restriction_id) { return $this->deletePlaybackRestrictionAsyncWithHttpInfo($playback_restriction_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation deletePlaybackRestrictionAsyncWithHttpInfo * * Delete a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deletePlaybackRestrictionAsyncWithHttpInfo($playback_restriction_id) { $returnType = ''; $request = $this->deletePlaybackRestrictionRequest($playback_restriction_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 'deletePlaybackRestriction' * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function deletePlaybackRestrictionRequest($playback_restriction_id) { // verify the required parameter 'playback_restriction_id' is set if ($playback_restriction_id === null || (is_array($playback_restriction_id) && count($playback_restriction_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_restriction_id when calling deletePlaybackRestriction' ); } $resourcePath = '/video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($playback_restriction_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_RESTRICTION_ID' . '}', ObjectSerializer::toPathValue($playback_restriction_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 getPlaybackRestriction * * Retrieve a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\PlaybackRestrictionResponse */ public function getPlaybackRestriction($playback_restriction_id) { list($response) = $this->getPlaybackRestrictionWithHttpInfo($playback_restriction_id); return $response; } /** * Operation getPlaybackRestrictionWithHttpInfo * * Retrieve a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\PlaybackRestrictionResponse, HTTP status code, HTTP response headers (array of strings) */ public function getPlaybackRestrictionWithHttpInfo($playback_restriction_id) { $request = $this->getPlaybackRestrictionRequest($playback_restriction_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\PlaybackRestrictionResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\PlaybackRestrictionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $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\PlaybackRestrictionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getPlaybackRestrictionAsync * * Retrieve a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getPlaybackRestrictionAsync($playback_restriction_id) { return $this->getPlaybackRestrictionAsyncWithHttpInfo($playback_restriction_id) ->then( function ($response) { return $response[0]; } ); } /** * Operation getPlaybackRestrictionAsyncWithHttpInfo * * Retrieve a Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getPlaybackRestrictionAsyncWithHttpInfo($playback_restriction_id) { $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $request = $this->getPlaybackRestrictionRequest($playback_restriction_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 'getPlaybackRestriction' * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getPlaybackRestrictionRequest($playback_restriction_id) { // verify the required parameter 'playback_restriction_id' is set if ($playback_restriction_id === null || (is_array($playback_restriction_id) && count($playback_restriction_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_restriction_id when calling getPlaybackRestriction' ); } $resourcePath = '/video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($playback_restriction_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_RESTRICTION_ID' . '}', ObjectSerializer::toPathValue($playback_restriction_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 listPlaybackRestrictions * * List Playback Restrictions * * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param int $limit Number of items to include in the response (optional, default to 25) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\ListPlaybackRestrictionsResponse */ public function listPlaybackRestrictions($page = 1, $limit = 25) { list($response) = $this->listPlaybackRestrictionsWithHttpInfo($page, $limit); return $response; } /** * Operation listPlaybackRestrictionsWithHttpInfo * * List Playback Restrictions * * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param int $limit Number of items to include in the response (optional, default to 25) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\ListPlaybackRestrictionsResponse, HTTP status code, HTTP response headers (array of strings) */ public function listPlaybackRestrictionsWithHttpInfo($page = 1, $limit = 25) { $request = $this->listPlaybackRestrictionsRequest($page, $limit); 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\ListPlaybackRestrictionsResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\ListPlaybackRestrictionsResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\ListPlaybackRestrictionsResponse'; $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\ListPlaybackRestrictionsResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation listPlaybackRestrictionsAsync * * List Playback Restrictions * * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param int $limit Number of items to include in the response (optional, default to 25) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listPlaybackRestrictionsAsync($page = 1, $limit = 25) { return $this->listPlaybackRestrictionsAsyncWithHttpInfo($page, $limit) ->then( function ($response) { return $response[0]; } ); } /** * Operation listPlaybackRestrictionsAsyncWithHttpInfo * * List Playback Restrictions * * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param int $limit Number of items to include in the response (optional, default to 25) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listPlaybackRestrictionsAsyncWithHttpInfo($page = 1, $limit = 25) { $returnType = '\MuxPhp\Models\ListPlaybackRestrictionsResponse'; $request = $this->listPlaybackRestrictionsRequest($page, $limit); 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 'listPlaybackRestrictions' * * @param int $page Offset by this many pages, of the size of `limit` (optional, default to 1) * @param int $limit Number of items to include in the response (optional, default to 25) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function listPlaybackRestrictionsRequest($page = 1, $limit = 25) { $resourcePath = '/video/v1/playback-restrictions'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // 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 ($limit !== null) { if('form' === 'form' && is_array($limit)) { foreach($limit as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['limit'] = $limit; } } 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 updateReferrerDomainRestriction * * Update the Referrer Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateReferrerDomainRestrictionRequest $update_referrer_domain_restriction_request update_referrer_domain_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\PlaybackRestrictionResponse */ public function updateReferrerDomainRestriction($playback_restriction_id, $update_referrer_domain_restriction_request) { list($response) = $this->updateReferrerDomainRestrictionWithHttpInfo($playback_restriction_id, $update_referrer_domain_restriction_request); return $response; } /** * Operation updateReferrerDomainRestrictionWithHttpInfo * * Update the Referrer Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateReferrerDomainRestrictionRequest $update_referrer_domain_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\PlaybackRestrictionResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateReferrerDomainRestrictionWithHttpInfo($playback_restriction_id, $update_referrer_domain_restriction_request) { $request = $this->updateReferrerDomainRestrictionRequest($playback_restriction_id, $update_referrer_domain_restriction_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\PlaybackRestrictionResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\PlaybackRestrictionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $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\PlaybackRestrictionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateReferrerDomainRestrictionAsync * * Update the Referrer Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateReferrerDomainRestrictionRequest $update_referrer_domain_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateReferrerDomainRestrictionAsync($playback_restriction_id, $update_referrer_domain_restriction_request) { return $this->updateReferrerDomainRestrictionAsyncWithHttpInfo($playback_restriction_id, $update_referrer_domain_restriction_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation updateReferrerDomainRestrictionAsyncWithHttpInfo * * Update the Referrer Playback Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateReferrerDomainRestrictionRequest $update_referrer_domain_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateReferrerDomainRestrictionAsyncWithHttpInfo($playback_restriction_id, $update_referrer_domain_restriction_request) { $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $request = $this->updateReferrerDomainRestrictionRequest($playback_restriction_id, $update_referrer_domain_restriction_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 'updateReferrerDomainRestriction' * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateReferrerDomainRestrictionRequest $update_referrer_domain_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function updateReferrerDomainRestrictionRequest($playback_restriction_id, $update_referrer_domain_restriction_request) { // verify the required parameter 'playback_restriction_id' is set if ($playback_restriction_id === null || (is_array($playback_restriction_id) && count($playback_restriction_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_restriction_id when calling updateReferrerDomainRestriction' ); } // verify the required parameter 'update_referrer_domain_restriction_request' is set if ($update_referrer_domain_restriction_request === null || (is_array($update_referrer_domain_restriction_request) && count($update_referrer_domain_restriction_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $update_referrer_domain_restriction_request when calling updateReferrerDomainRestriction' ); } $resourcePath = '/video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}/referrer'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($playback_restriction_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_RESTRICTION_ID' . '}', ObjectSerializer::toPathValue($playback_restriction_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_referrer_domain_restriction_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_referrer_domain_restriction_request)); } else { $httpBody = $update_referrer_domain_restriction_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 updateUserAgentRestriction * * Update the User Agent Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request update_user_agent_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\PlaybackRestrictionResponse */ public function updateUserAgentRestriction($playback_restriction_id, $update_user_agent_restriction_request) { list($response) = $this->updateUserAgentRestrictionWithHttpInfo($playback_restriction_id, $update_user_agent_restriction_request); return $response; } /** * Operation updateUserAgentRestrictionWithHttpInfo * * Update the User Agent Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\PlaybackRestrictionResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateUserAgentRestrictionWithHttpInfo($playback_restriction_id, $update_user_agent_restriction_request) { $request = $this->updateUserAgentRestrictionRequest($playback_restriction_id, $update_user_agent_restriction_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\PlaybackRestrictionResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\PlaybackRestrictionResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $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\PlaybackRestrictionResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateUserAgentRestrictionAsync * * Update the User Agent Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateUserAgentRestrictionAsync($playback_restriction_id, $update_user_agent_restriction_request) { return $this->updateUserAgentRestrictionAsyncWithHttpInfo($playback_restriction_id, $update_user_agent_restriction_request) ->then( function ($response) { return $response[0]; } ); } /** * Operation updateUserAgentRestrictionAsyncWithHttpInfo * * Update the User Agent Restriction * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateUserAgentRestrictionAsyncWithHttpInfo($playback_restriction_id, $update_user_agent_restriction_request) { $returnType = '\MuxPhp\Models\PlaybackRestrictionResponse'; $request = $this->updateUserAgentRestrictionRequest($playback_restriction_id, $update_user_agent_restriction_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 'updateUserAgentRestriction' * * @param string $playback_restriction_id ID of the Playback Restriction. (required) * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function updateUserAgentRestrictionRequest($playback_restriction_id, $update_user_agent_restriction_request) { // verify the required parameter 'playback_restriction_id' is set if ($playback_restriction_id === null || (is_array($playback_restriction_id) && count($playback_restriction_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $playback_restriction_id when calling updateUserAgentRestriction' ); } // verify the required parameter 'update_user_agent_restriction_request' is set if ($update_user_agent_restriction_request === null || (is_array($update_user_agent_restriction_request) && count($update_user_agent_restriction_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $update_user_agent_restriction_request when calling updateUserAgentRestriction' ); } $resourcePath = '/video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}/user_agent'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($playback_restriction_id !== null) { $resourcePath = str_replace( '{' . 'PLAYBACK_RESTRICTION_ID' . '}', ObjectSerializer::toPathValue($playback_restriction_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_user_agent_restriction_request)) { if ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($update_user_agent_restriction_request)); } else { $httpBody = $update_user_agent_restriction_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 |
proxy
|
phpinfo
|
Settings