[ 'application/json', ], 'getApiV3Channels' => [ 'application/json', ], 'getApiV3ChannelsChannel' => [ 'application/json', ], 'getApiV3ChannelsChannelLinks' => [ 'application/json', ], 'getApiV3ChannelsEditable' => [ 'application/json', ], 'patchApiV3ChannelsChannel' => [ 'application/json', ], 'patchApiV3ChannelsChannelLinks' => [ 'application/json', ], 'postApiV3ChannelsBatchProgress' => [ 'application/json', ], ]; /** * @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, int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } /** * Set the host index * * @param int $hostIndex Host index (required) */ public function setHostIndex($hostIndex): void { $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 deleteApiV3ChannelsChannel * * 删除 channel * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function deleteApiV3ChannelsChannel($channel, string $contentType = self::contentTypes['deleteApiV3ChannelsChannel'][0]) { list($response) = $this->deleteApiV3ChannelsChannelWithHttpInfo($channel, $contentType); return $response; } /** * Operation deleteApiV3ChannelsChannelWithHttpInfo * * 删除 channel * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function deleteApiV3ChannelsChannelWithHttpInfo($channel, string $contentType = self::contentTypes['deleteApiV3ChannelsChannel'][0]) { $request = $this->deleteApiV3ChannelsChannelRequest($channel, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 409: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 409: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation deleteApiV3ChannelsChannelAsync * * 删除 channel * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteApiV3ChannelsChannelAsync($channel, string $contentType = self::contentTypes['deleteApiV3ChannelsChannel'][0]) { return $this->deleteApiV3ChannelsChannelAsyncWithHttpInfo($channel, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation deleteApiV3ChannelsChannelAsyncWithHttpInfo * * 删除 channel * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteApiV3ChannelsChannelAsyncWithHttpInfo($channel, string $contentType = self::contentTypes['deleteApiV3ChannelsChannel'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response'; $request = $this->deleteApiV3ChannelsChannelRequest($channel, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'deleteApiV3ChannelsChannel' * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function deleteApiV3ChannelsChannelRequest($channel, string $contentType = self::contentTypes['deleteApiV3ChannelsChannel'][0]) { // verify the required parameter 'channel' is set if ($channel === null || (is_array($channel) && count($channel) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $channel when calling deleteApiV3ChannelsChannel' ); } $resourcePath = '/v3/channels/{channel}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($channel !== null) { $resourcePath = str_replace( '{channel}', ObjectSerializer::toPathValue($channel), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'DELETE', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getApiV3Channels * * 公开 channel 目录 * * @param bool|null $system 只列系统 channel (optional) * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Channels'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3Channels200Response|\WikipaliApi\Model\ProblemDetails */ public function getApiV3Channels($system = null, $per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3Channels'][0]) { list($response) = $this->getApiV3ChannelsWithHttpInfo($system, $per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); return $response; } /** * Operation getApiV3ChannelsWithHttpInfo * * 公开 channel 目录 * * @param bool|null $system 只列系统 channel (optional) * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Channels'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3Channels200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function getApiV3ChannelsWithHttpInfo($system = null, $per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3Channels'][0]) { $request = $this->getApiV3ChannelsRequest($system, $per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3Channels200Response', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3Channels200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3Channels200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation getApiV3ChannelsAsync * * 公开 channel 目录 * * @param bool|null $system 只列系统 channel (optional) * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Channels'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsAsync($system = null, $per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3Channels'][0]) { return $this->getApiV3ChannelsAsyncWithHttpInfo($system, $per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation getApiV3ChannelsAsyncWithHttpInfo * * 公开 channel 目录 * * @param bool|null $system 只列系统 channel (optional) * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Channels'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsAsyncWithHttpInfo($system = null, $per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3Channels'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3Channels200Response'; $request = $this->getApiV3ChannelsRequest($system, $per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'getApiV3Channels' * * @param bool|null $system 只列系统 channel (optional) * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Channels'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getApiV3ChannelsRequest($system = null, $per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3Channels'][0]) { $resourcePath = '/v3/channels'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $system, 'system', // param base name 'boolean', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $per_page, 'per_page', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search, 'search', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $type, 'type', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $lang, 'lang', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $book, 'book', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $para, 'para', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $order, 'order', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $dir, 'dir', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $page, 'page', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getApiV3ChannelsChannel * * channel 详情 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function getApiV3ChannelsChannel($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannel'][0]) { list($response) = $this->getApiV3ChannelsChannelWithHttpInfo($channel, $contentType); return $response; } /** * Operation getApiV3ChannelsChannelWithHttpInfo * * channel 详情 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function getApiV3ChannelsChannelWithHttpInfo($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannel'][0]) { $request = $this->getApiV3ChannelsChannelRequest($channel, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation getApiV3ChannelsChannelAsync * * channel 详情 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsChannelAsync($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannel'][0]) { return $this->getApiV3ChannelsChannelAsyncWithHttpInfo($channel, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation getApiV3ChannelsChannelAsyncWithHttpInfo * * channel 详情 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsChannelAsyncWithHttpInfo($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannel'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response'; $request = $this->getApiV3ChannelsChannelRequest($channel, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'getApiV3ChannelsChannel' * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getApiV3ChannelsChannelRequest($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannel'][0]) { // verify the required parameter 'channel' is set if ($channel === null || (is_array($channel) && count($channel) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $channel when calling getApiV3ChannelsChannel' ); } $resourcePath = '/v3/channels/{channel}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($channel !== null) { $resourcePath = str_replace( '{channel}', ObjectSerializer::toPathValue($channel), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getApiV3ChannelsChannelLinks * * channel 的关系设置 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function getApiV3ChannelsChannelLinks($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannelLinks'][0]) { list($response) = $this->getApiV3ChannelsChannelLinksWithHttpInfo($channel, $contentType); return $response; } /** * Operation getApiV3ChannelsChannelLinksWithHttpInfo * * channel 的关系设置 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function getApiV3ChannelsChannelLinksWithHttpInfo($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannelLinks'][0]) { $request = $this->getApiV3ChannelsChannelLinksRequest($channel, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation getApiV3ChannelsChannelLinksAsync * * channel 的关系设置 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsChannelLinksAsync($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannelLinks'][0]) { return $this->getApiV3ChannelsChannelLinksAsyncWithHttpInfo($channel, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation getApiV3ChannelsChannelLinksAsyncWithHttpInfo * * channel 的关系设置 * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsChannelLinksAsyncWithHttpInfo($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannelLinks'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response'; $request = $this->getApiV3ChannelsChannelLinksRequest($channel, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'getApiV3ChannelsChannelLinks' * * @param string $channel channel uid (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getApiV3ChannelsChannelLinksRequest($channel, string $contentType = self::contentTypes['getApiV3ChannelsChannelLinks'][0]) { // verify the required parameter 'channel' is set if ($channel === null || (is_array($channel) && count($channel) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $channel when calling getApiV3ChannelsChannelLinks' ); } $resourcePath = '/v3/channels/{channel}/links'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($channel !== null) { $resourcePath = str_replace( '{channel}', ObjectSerializer::toPathValue($channel), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getApiV3ChannelsEditable * * 列出我能写的 channel * * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsEditable'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3Channels200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function getApiV3ChannelsEditable($per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3ChannelsEditable'][0]) { list($response) = $this->getApiV3ChannelsEditableWithHttpInfo($per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); return $response; } /** * Operation getApiV3ChannelsEditableWithHttpInfo * * 列出我能写的 channel * * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsEditable'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3Channels200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function getApiV3ChannelsEditableWithHttpInfo($per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3ChannelsEditable'][0]) { $request = $this->getApiV3ChannelsEditableRequest($per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3Channels200Response', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3Channels200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3Channels200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation getApiV3ChannelsEditableAsync * * 列出我能写的 channel * * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsEditable'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsEditableAsync($per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3ChannelsEditable'][0]) { return $this->getApiV3ChannelsEditableAsyncWithHttpInfo($per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation getApiV3ChannelsEditableAsyncWithHttpInfo * * 列出我能写的 channel * * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsEditable'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getApiV3ChannelsEditableAsyncWithHttpInfo($per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3ChannelsEditable'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3Channels200Response'; $request = $this->getApiV3ChannelsEditableRequest($per_page, $search, $type, $lang, $book, $para, $order, $dir, $page, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'getApiV3ChannelsEditable' * * @param int|null $per_page 每页数量,最大 200 (optional, default to 20) * @param string|null $search 按名字模糊匹配 (optional) * @param string|null $type channel 类型 (optional) * @param string|null $lang 语言 (optional) * @param int|null $book 章节所在的书(与 para 同时给) (optional) * @param int|null $para 章节起始段(与 book 同时给) (optional) * @param string|null $order 排序字段 (optional, default to 'updated_at') * @param string|null $dir 排序方向 (optional, default to 'desc') * @param int|null $page 页码 (optional, default to 1) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3ChannelsEditable'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getApiV3ChannelsEditableRequest($per_page = 20, $search = null, $type = null, $lang = null, $book = null, $para = null, $order = 'updated_at', $dir = 'desc', $page = 1, string $contentType = self::contentTypes['getApiV3ChannelsEditable'][0]) { $resourcePath = '/v3/channels/editable'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $per_page, 'per_page', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search, 'search', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $type, 'type', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $lang, 'lang', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $book, 'book', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $para, 'para', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $order, 'order', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $dir, 'dir', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $page, 'page', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation patchApiV3ChannelsChannel * * 改 channel 信息 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelRequest|null $patch_api_v3_channels_channel_request patch_api_v3_channels_channel_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function patchApiV3ChannelsChannel($channel, $patch_api_v3_channels_channel_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannel'][0]) { list($response) = $this->patchApiV3ChannelsChannelWithHttpInfo($channel, $patch_api_v3_channels_channel_request, $contentType); return $response; } /** * Operation patchApiV3ChannelsChannelWithHttpInfo * * 改 channel 信息 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelRequest|null $patch_api_v3_channels_channel_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3ChannelsChannel200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function patchApiV3ChannelsChannelWithHttpInfo($channel, $patch_api_v3_channels_channel_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannel'][0]) { $request = $this->patchApiV3ChannelsChannelRequest($channel, $patch_api_v3_channels_channel_request, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation patchApiV3ChannelsChannelAsync * * 改 channel 信息 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelRequest|null $patch_api_v3_channels_channel_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function patchApiV3ChannelsChannelAsync($channel, $patch_api_v3_channels_channel_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannel'][0]) { return $this->patchApiV3ChannelsChannelAsyncWithHttpInfo($channel, $patch_api_v3_channels_channel_request, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation patchApiV3ChannelsChannelAsyncWithHttpInfo * * 改 channel 信息 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelRequest|null $patch_api_v3_channels_channel_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function patchApiV3ChannelsChannelAsyncWithHttpInfo($channel, $patch_api_v3_channels_channel_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannel'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3ChannelsChannel200Response'; $request = $this->patchApiV3ChannelsChannelRequest($channel, $patch_api_v3_channels_channel_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'patchApiV3ChannelsChannel' * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelRequest|null $patch_api_v3_channels_channel_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function patchApiV3ChannelsChannelRequest($channel, $patch_api_v3_channels_channel_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannel'][0]) { // verify the required parameter 'channel' is set if ($channel === null || (is_array($channel) && count($channel) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $channel when calling patchApiV3ChannelsChannel' ); } $resourcePath = '/v3/channels/{channel}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($channel !== null) { $resourcePath = str_replace( '{channel}', ObjectSerializer::toPathValue($channel), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // for model (json/xml) if (isset($patch_api_v3_channels_channel_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body try { $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($patch_api_v3_channels_channel_request), JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { $httpBody = $patch_api_v3_channels_channel_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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'PATCH', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation patchApiV3ChannelsChannelLinks * * 改 channel 的关系设置 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelLinksRequest|null $patch_api_v3_channels_channel_links_request patch_api_v3_channels_channel_links_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function patchApiV3ChannelsChannelLinks($channel, $patch_api_v3_channels_channel_links_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannelLinks'][0]) { list($response) = $this->patchApiV3ChannelsChannelLinksWithHttpInfo($channel, $patch_api_v3_channels_channel_links_request, $contentType); return $response; } /** * Operation patchApiV3ChannelsChannelLinksWithHttpInfo * * 改 channel 的关系设置 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelLinksRequest|null $patch_api_v3_channels_channel_links_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function patchApiV3ChannelsChannelLinksWithHttpInfo($channel, $patch_api_v3_channels_channel_links_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannelLinks'][0]) { $request = $this->patchApiV3ChannelsChannelLinksRequest($channel, $patch_api_v3_channels_channel_links_request, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation patchApiV3ChannelsChannelLinksAsync * * 改 channel 的关系设置 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelLinksRequest|null $patch_api_v3_channels_channel_links_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function patchApiV3ChannelsChannelLinksAsync($channel, $patch_api_v3_channels_channel_links_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannelLinks'][0]) { return $this->patchApiV3ChannelsChannelLinksAsyncWithHttpInfo($channel, $patch_api_v3_channels_channel_links_request, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation patchApiV3ChannelsChannelLinksAsyncWithHttpInfo * * 改 channel 的关系设置 * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelLinksRequest|null $patch_api_v3_channels_channel_links_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function patchApiV3ChannelsChannelLinksAsyncWithHttpInfo($channel, $patch_api_v3_channels_channel_links_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannelLinks'][0]) { $returnType = '\WikipaliApi\Model\GetApiV3ChannelsChannelLinks200Response'; $request = $this->patchApiV3ChannelsChannelLinksRequest($channel, $patch_api_v3_channels_channel_links_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'patchApiV3ChannelsChannelLinks' * * @param string $channel channel uid (required) * @param \WikipaliApi\Model\PatchApiV3ChannelsChannelLinksRequest|null $patch_api_v3_channels_channel_links_request (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['patchApiV3ChannelsChannelLinks'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function patchApiV3ChannelsChannelLinksRequest($channel, $patch_api_v3_channels_channel_links_request = null, string $contentType = self::contentTypes['patchApiV3ChannelsChannelLinks'][0]) { // verify the required parameter 'channel' is set if ($channel === null || (is_array($channel) && count($channel) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $channel when calling patchApiV3ChannelsChannelLinks' ); } $resourcePath = '/v3/channels/{channel}/links'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($channel !== null) { $resourcePath = str_replace( '{channel}', ObjectSerializer::toPathValue($channel), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // for model (json/xml) if (isset($patch_api_v3_channels_channel_links_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body try { $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($patch_api_v3_channels_channel_links_request), JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { $httpBody = $patch_api_v3_channels_channel_links_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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'PATCH', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation postApiV3ChannelsBatchProgress * * 查一批句子在各 channel 的完成度 * * @param \WikipaliApi\Model\PostApiV3ChannelsBatchProgressRequest $post_api_v3_channels_batch_progress_request post_api_v3_channels_batch_progress_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3ChannelsBatchProgress'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails */ public function postApiV3ChannelsBatchProgress($post_api_v3_channels_batch_progress_request, string $contentType = self::contentTypes['postApiV3ChannelsBatchProgress'][0]) { list($response) = $this->postApiV3ChannelsBatchProgressWithHttpInfo($post_api_v3_channels_batch_progress_request, $contentType); return $response; } /** * Operation postApiV3ChannelsBatchProgressWithHttpInfo * * 查一批句子在各 channel 的完成度 * * @param \WikipaliApi\Model\PostApiV3ChannelsBatchProgressRequest $post_api_v3_channels_batch_progress_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3ChannelsBatchProgress'] to see the possible values for this operation * * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function postApiV3ChannelsBatchProgressWithHttpInfo($post_api_v3_channels_batch_progress_request, string $contentType = self::contentTypes['postApiV3ChannelsBatchProgress'][0]) { $request = $this->postApiV3ChannelsBatchProgressRequest($post_api_v3_channels_batch_progress_request, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); case 422: return $this->handleResponseWithDataType( '\WikipaliApi\Model\ProblemDetails', $request, $response, ); } if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } return $this->handleResponseWithDataType( '\WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 422: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\WikipaliApi\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation postApiV3ChannelsBatchProgressAsync * * 查一批句子在各 channel 的完成度 * * @param \WikipaliApi\Model\PostApiV3ChannelsBatchProgressRequest $post_api_v3_channels_batch_progress_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3ChannelsBatchProgress'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function postApiV3ChannelsBatchProgressAsync($post_api_v3_channels_batch_progress_request, string $contentType = self::contentTypes['postApiV3ChannelsBatchProgress'][0]) { return $this->postApiV3ChannelsBatchProgressAsyncWithHttpInfo($post_api_v3_channels_batch_progress_request, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation postApiV3ChannelsBatchProgressAsyncWithHttpInfo * * 查一批句子在各 channel 的完成度 * * @param \WikipaliApi\Model\PostApiV3ChannelsBatchProgressRequest $post_api_v3_channels_batch_progress_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3ChannelsBatchProgress'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function postApiV3ChannelsBatchProgressAsyncWithHttpInfo($post_api_v3_channels_batch_progress_request, string $contentType = self::contentTypes['postApiV3ChannelsBatchProgress'][0]) { $returnType = '\WikipaliApi\Model\PostApiV3ChannelsBatchProgress200Response'; $request = $this->postApiV3ChannelsBatchProgressRequest($post_api_v3_channels_batch_progress_request, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } 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(), (string) $response->getBody() ); } ); } /** * Create request for operation 'postApiV3ChannelsBatchProgress' * * @param \WikipaliApi\Model\PostApiV3ChannelsBatchProgressRequest $post_api_v3_channels_batch_progress_request (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3ChannelsBatchProgress'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function postApiV3ChannelsBatchProgressRequest($post_api_v3_channels_batch_progress_request, string $contentType = self::contentTypes['postApiV3ChannelsBatchProgress'][0]) { // verify the required parameter 'post_api_v3_channels_batch_progress_request' is set if ($post_api_v3_channels_batch_progress_request === null || (is_array($post_api_v3_channels_batch_progress_request) && count($post_api_v3_channels_batch_progress_request) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $post_api_v3_channels_batch_progress_request when calling postApiV3ChannelsBatchProgress' ); } $resourcePath = '/v3/channels/batch-progress'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json', ], $contentType, $multipart ); // for model (json/xml) if (isset($post_api_v3_channels_batch_progress_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body try { $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_channels_batch_progress_request), JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { $httpBody = $post_api_v3_channels_batch_progress_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 (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters try { $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires Bearer authentication (access token) if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'POST', $operationHost . $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()); } } if ($this->config->getCertFile()) { $options[RequestOptions::CERT] = $this->config->getCertFile(); } if ($this->config->getKeyFile()) { $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); } return $options; } private function handleResponseWithDataType( string $dataType, RequestInterface $request, ResponseInterface $response ): array { if ($dataType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($dataType !== 'string') { try { $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { throw new ApiException( sprintf( 'Error JSON decoding server response (%s)', $request->getUri() ), $response->getStatusCode(), $response->getHeaders(), $content ); } } } return [ ObjectSerializer::deserialize($content, $dataType, []), $response->getStatusCode(), $response->getHeaders() ]; } private function responseWithinRangeCode( string $rangeCode, int $statusCode ): bool { $left = (int) ($rangeCode[0].'00'); $right = (int) ($rangeCode[0].'99'); return $statusCode >= $left && $statusCode <= $right; } }