|
|
@@ -0,0 +1,2311 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * AdminApi
|
|
|
+ * PHP version 8.1
|
|
|
+ *
|
|
|
+ * @category Class
|
|
|
+ * @package WikipaliApi
|
|
|
+ * @author OpenAPI Generator team
|
|
|
+ * @link https://openapi-generator.tech
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * MINT API
|
|
|
+ *
|
|
|
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院) 由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
|
|
|
+ *
|
|
|
+ * The version of the OpenAPI document: 2026.11.12
|
|
|
+ * Generated by: https://openapi-generator.tech
|
|
|
+ * Generator version: 7.25.0
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
|
+ * https://openapi-generator.tech
|
|
|
+ * Do not edit the class manually.
|
|
|
+ */
|
|
|
+
|
|
|
+namespace WikipaliApi\Api;
|
|
|
+
|
|
|
+use GuzzleHttp\Client;
|
|
|
+use GuzzleHttp\ClientInterface;
|
|
|
+use GuzzleHttp\Exception\ConnectException;
|
|
|
+use GuzzleHttp\Exception\RequestException;
|
|
|
+use GuzzleHttp\Psr7\MultipartStream;
|
|
|
+use GuzzleHttp\Psr7\Request;
|
|
|
+use GuzzleHttp\RequestOptions;
|
|
|
+use Psr\Http\Message\RequestInterface;
|
|
|
+use Psr\Http\Message\ResponseInterface;
|
|
|
+use WikipaliApi\ApiException;
|
|
|
+use WikipaliApi\Configuration;
|
|
|
+use WikipaliApi\FormDataProcessor;
|
|
|
+use WikipaliApi\HeaderSelector;
|
|
|
+use WikipaliApi\ObjectSerializer;
|
|
|
+
|
|
|
+/**
|
|
|
+ * AdminApi Class Doc Comment
|
|
|
+ *
|
|
|
+ * @category Class
|
|
|
+ * @package WikipaliApi
|
|
|
+ * @author OpenAPI Generator team
|
|
|
+ * @link https://openapi-generator.tech
|
|
|
+ */
|
|
|
+class AdminApi
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * @var ClientInterface
|
|
|
+ */
|
|
|
+ protected $client;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var Configuration
|
|
|
+ */
|
|
|
+ protected $config;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var HeaderSelector
|
|
|
+ */
|
|
|
+ protected $headerSelector;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var int Host index
|
|
|
+ */
|
|
|
+ protected $hostIndex;
|
|
|
+
|
|
|
+ /** @var string[] $contentTypes **/
|
|
|
+ public const contentTypes = [
|
|
|
+ 'getApiV3AdminAgentFeedback' => [
|
|
|
+ 'application/json',
|
|
|
+ ],
|
|
|
+ 'getApiV3AdminAgentRuns' => [
|
|
|
+ 'application/json',
|
|
|
+ ],
|
|
|
+ 'getApiV3AdminAgentRunsDigest' => [
|
|
|
+ 'application/json',
|
|
|
+ ],
|
|
|
+ 'getApiV3AdminAgentRunsRun' => [
|
|
|
+ 'application/json',
|
|
|
+ ],
|
|
|
+ 'getApiV3AdminAgentStats' => [
|
|
|
+ 'application/json',
|
|
|
+ ],
|
|
|
+ 'getApiV3AdminReadingStats' => [
|
|
|
+ '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 getApiV3AdminAgentFeedback
|
|
|
+ *
|
|
|
+ * 列出评价
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
|
|
|
+ * @param string|null $filter_tag 按标签 / 原因筛 (optional)
|
|
|
+ * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional)
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] 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\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentFeedback($per_page = 20, $filter_rating = null, $filter_tag = null, $filter_has_comment = null, $from = null, $to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentFeedback'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminAgentFeedbackWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentFeedbackWithHttpInfo
|
|
|
+ *
|
|
|
+ * 列出评价
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
|
|
|
+ * @param string|null $filter_tag 按标签 / 原因筛 (optional)
|
|
|
+ * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional)
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] 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\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentFeedbackWithHttpInfo($per_page = 20, $filter_rating = null, $filter_tag = null, $filter_has_comment = null, $from = null, $to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentFeedback'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $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\GetApiV3AdminAgentFeedback200Response',
|
|
|
+ $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\GetApiV3AdminAgentFeedback200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
|
|
|
+ $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 getApiV3AdminAgentFeedbackAsync
|
|
|
+ *
|
|
|
+ * 列出评价
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
|
|
|
+ * @param string|null $filter_tag 按标签 / 原因筛 (optional)
|
|
|
+ * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional)
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentFeedbackAsync($per_page = 20, $filter_rating = null, $filter_tag = null, $filter_has_comment = null, $from = null, $to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentFeedback'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminAgentFeedbackAsyncWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentFeedbackAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * 列出评价
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
|
|
|
+ * @param string|null $filter_tag 按标签 / 原因筛 (optional)
|
|
|
+ * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional)
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentFeedbackAsyncWithHttpInfo($per_page = 20, $filter_rating = null, $filter_tag = null, $filter_has_comment = null, $from = null, $to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentFeedback'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response';
|
|
|
+ $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $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 'getApiV3AdminAgentFeedback'
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
|
|
|
+ * @param string|null $filter_tag 按标签 / 原因筛 (optional)
|
|
|
+ * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional)
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentFeedbackRequest($per_page = 20, $filter_rating = null, $filter_tag = null, $filter_has_comment = null, $from = null, $to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentFeedback'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/agent-feedback';
|
|
|
+ $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(
|
|
|
+ $filter_rating,
|
|
|
+ 'filter[rating]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_tag,
|
|
|
+ 'filter[tag]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_has_comment,
|
|
|
+ 'filter[has_comment]', // param base name
|
|
|
+ 'boolean', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $from,
|
|
|
+ 'from', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $to,
|
|
|
+ 'to', // 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 getApiV3AdminAgentRuns
|
|
|
+ *
|
|
|
+ * 列出提问
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_status 运行结果 (optional)
|
|
|
+ * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
|
|
|
+ * @param string|null $filter_account_type 账号类型 (optional)
|
|
|
+ * @param string|null $filter_client 客户端 (optional)
|
|
|
+ * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
|
|
|
+ * @param string|null $filter_q 按提问原文模糊搜索 (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] 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\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRuns($per_page = 20, $filter_status = null, $filter_route = null, $filter_account_type = null, $filter_client = null, $filter_improve = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentRuns'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminAgentRunsWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsWithHttpInfo
|
|
|
+ *
|
|
|
+ * 列出提问
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_status 运行结果 (optional)
|
|
|
+ * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
|
|
|
+ * @param string|null $filter_account_type 账号类型 (optional)
|
|
|
+ * @param string|null $filter_client 客户端 (optional)
|
|
|
+ * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
|
|
|
+ * @param string|null $filter_q 按提问原文模糊搜索 (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] 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\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsWithHttpInfo($per_page = 20, $filter_status = null, $filter_route = null, $filter_account_type = null, $filter_client = null, $filter_improve = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentRuns'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $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\GetApiV3AdminAgentRuns200Response',
|
|
|
+ $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\GetApiV3AdminAgentRuns200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
|
|
|
+ $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 getApiV3AdminAgentRunsAsync
|
|
|
+ *
|
|
|
+ * 列出提问
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_status 运行结果 (optional)
|
|
|
+ * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
|
|
|
+ * @param string|null $filter_account_type 账号类型 (optional)
|
|
|
+ * @param string|null $filter_client 客户端 (optional)
|
|
|
+ * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
|
|
|
+ * @param string|null $filter_q 按提问原文模糊搜索 (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsAsync($per_page = 20, $filter_status = null, $filter_route = null, $filter_account_type = null, $filter_client = null, $filter_improve = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentRuns'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminAgentRunsAsyncWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * 列出提问
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_status 运行结果 (optional)
|
|
|
+ * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
|
|
|
+ * @param string|null $filter_account_type 账号类型 (optional)
|
|
|
+ * @param string|null $filter_client 客户端 (optional)
|
|
|
+ * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
|
|
|
+ * @param string|null $filter_q 按提问原文模糊搜索 (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsAsyncWithHttpInfo($per_page = 20, $filter_status = null, $filter_route = null, $filter_account_type = null, $filter_client = null, $filter_improve = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentRuns'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response';
|
|
|
+ $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $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 'getApiV3AdminAgentRuns'
|
|
|
+ *
|
|
|
+ * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
|
|
|
+ * @param string|null $filter_status 运行结果 (optional)
|
|
|
+ * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
|
|
|
+ * @param string|null $filter_account_type 账号类型 (optional)
|
|
|
+ * @param string|null $filter_client 客户端 (optional)
|
|
|
+ * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
|
|
|
+ * @param string|null $filter_q 按提问原文模糊搜索 (optional)
|
|
|
+ * @param int|null $page 页码 (optional, default to 1)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRequest($per_page = 20, $filter_status = null, $filter_route = null, $filter_account_type = null, $filter_client = null, $filter_improve = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminAgentRuns'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/agent-runs';
|
|
|
+ $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(
|
|
|
+ $filter_status,
|
|
|
+ 'filter[status]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_route,
|
|
|
+ 'filter[route]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_account_type,
|
|
|
+ 'filter[account_type]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_client,
|
|
|
+ 'filter[client]', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_improve,
|
|
|
+ 'filter[improve]', // param base name
|
|
|
+ 'boolean', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $filter_q,
|
|
|
+ 'filter[q]', // 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 getApiV3AdminAgentRunsDigest
|
|
|
+ *
|
|
|
+ * 分析用的精简导出
|
|
|
+ *
|
|
|
+ * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
|
|
|
+ * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] 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\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsDigest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminAgentRunsDigestWithHttpInfo($full, $limit, $from, $to, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsDigestWithHttpInfo
|
|
|
+ *
|
|
|
+ * 分析用的精简导出
|
|
|
+ *
|
|
|
+ * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
|
|
|
+ * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] 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\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsDigestWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $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\GetApiV3AdminAgentRunsDigest200Response',
|
|
|
+ $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\GetApiV3AdminAgentRunsDigest200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
|
|
|
+ $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 getApiV3AdminAgentRunsDigestAsync
|
|
|
+ *
|
|
|
+ * 分析用的精简导出
|
|
|
+ *
|
|
|
+ * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
|
|
|
+ * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsDigestAsync($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full, $limit, $from, $to, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsDigestAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * 分析用的精简导出
|
|
|
+ *
|
|
|
+ * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
|
|
|
+ * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response';
|
|
|
+ $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $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 'getApiV3AdminAgentRunsDigest'
|
|
|
+ *
|
|
|
+ * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
|
|
|
+ * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsDigestRequest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/agent-runs/digest';
|
|
|
+ $formParams = [];
|
|
|
+ $queryParams = [];
|
|
|
+ $headerParams = [];
|
|
|
+ $httpBody = '';
|
|
|
+ $multipart = false;
|
|
|
+
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $full,
|
|
|
+ 'full', // param base name
|
|
|
+ 'boolean', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $limit,
|
|
|
+ 'limit', // param base name
|
|
|
+ 'integer', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $from,
|
|
|
+ 'from', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $to,
|
|
|
+ 'to', // param base name
|
|
|
+ 'string', // 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 getApiV3AdminAgentRunsRun
|
|
|
+ *
|
|
|
+ * 查看一次提问的研究过程
|
|
|
+ *
|
|
|
+ * @param string $run AG-UI runId(uuid) (required)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] 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\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRun($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminAgentRunsRunWithHttpInfo($run, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsRunWithHttpInfo
|
|
|
+ *
|
|
|
+ * 查看一次提问的研究过程
|
|
|
+ *
|
|
|
+ * @param string $run AG-UI runId(uuid) (required)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] 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\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRunWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminAgentRunsRunRequest($run, $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\GetApiV3AdminAgentRunsRun200Response',
|
|
|
+ $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\GetApiV3AdminAgentRunsRun200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
|
|
|
+ $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 getApiV3AdminAgentRunsRunAsync
|
|
|
+ *
|
|
|
+ * 查看一次提问的研究过程
|
|
|
+ *
|
|
|
+ * @param string $run AG-UI runId(uuid) (required)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRunAsync($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentRunsRunAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * 查看一次提问的研究过程
|
|
|
+ *
|
|
|
+ * @param string $run AG-UI runId(uuid) (required)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response';
|
|
|
+ $request = $this->getApiV3AdminAgentRunsRunRequest($run, $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 'getApiV3AdminAgentRunsRun'
|
|
|
+ *
|
|
|
+ * @param string $run AG-UI runId(uuid) (required)
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentRunsRunRequest($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+ // verify the required parameter 'run' is set
|
|
|
+ if ($run === null || (is_array($run) && count($run) === 0)) {
|
|
|
+ throw new \InvalidArgumentException(
|
|
|
+ 'Missing the required parameter $run when calling getApiV3AdminAgentRunsRun'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/agent-runs/{run}';
|
|
|
+ $formParams = [];
|
|
|
+ $queryParams = [];
|
|
|
+ $headerParams = [];
|
|
|
+ $httpBody = '';
|
|
|
+ $multipart = false;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // path params
|
|
|
+ if ($run !== null) {
|
|
|
+ $resourcePath = str_replace(
|
|
|
+ '{run}',
|
|
|
+ ObjectSerializer::toPathValue($run),
|
|
|
+ $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 getApiV3AdminAgentStats
|
|
|
+ *
|
|
|
+ * AI 对话统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $account_type 账号类型 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] 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\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentStats($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminAgentStatsWithHttpInfo($from, $to, $account_type, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentStatsWithHttpInfo
|
|
|
+ *
|
|
|
+ * AI 对话统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $account_type 账号类型 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] 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\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $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\GetApiV3AdminAgentStats200Response',
|
|
|
+ $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\GetApiV3AdminAgentStats200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
|
|
|
+ $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 getApiV3AdminAgentStatsAsync
|
|
|
+ *
|
|
|
+ * AI 对话统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $account_type 账号类型 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentStatsAsync($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminAgentStatsAsyncWithHttpInfo($from, $to, $account_type, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminAgentStatsAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * AI 对话统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $account_type 账号类型 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response';
|
|
|
+ $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $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 'getApiV3AdminAgentStats'
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $account_type 账号类型 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminAgentStatsRequest($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/agent-stats';
|
|
|
+ $formParams = [];
|
|
|
+ $queryParams = [];
|
|
|
+ $headerParams = [];
|
|
|
+ $httpBody = '';
|
|
|
+ $multipart = false;
|
|
|
+
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $from,
|
|
|
+ 'from', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $to,
|
|
|
+ 'to', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $account_type,
|
|
|
+ 'account_type', // param base name
|
|
|
+ 'string', // 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 getApiV3AdminReadingStats
|
|
|
+ *
|
|
|
+ * 阅读统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $client 客户端 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] 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\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
|
|
|
+ */
|
|
|
+ public function getApiV3AdminReadingStats($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
|
|
|
+ {
|
|
|
+ list($response) = $this->getApiV3AdminReadingStatsWithHttpInfo($from, $to, $client, $contentType);
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminReadingStatsWithHttpInfo
|
|
|
+ *
|
|
|
+ * 阅读统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $client 客户端 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] 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\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
|
|
|
+ */
|
|
|
+ public function getApiV3AdminReadingStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
|
|
|
+ {
|
|
|
+ $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $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\GetApiV3AdminReadingStats200Response',
|
|
|
+ $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\GetApiV3AdminReadingStats200Response',
|
|
|
+ $request,
|
|
|
+ $response,
|
|
|
+ );
|
|
|
+ } catch (ApiException $e) {
|
|
|
+ switch ($e->getCode()) {
|
|
|
+ case 200:
|
|
|
+ $data = ObjectSerializer::deserialize(
|
|
|
+ $e->getResponseBody(),
|
|
|
+ '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
|
|
|
+ $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 getApiV3AdminReadingStatsAsync
|
|
|
+ *
|
|
|
+ * 阅读统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $client 客户端 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminReadingStatsAsync($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
|
|
|
+ {
|
|
|
+ return $this->getApiV3AdminReadingStatsAsyncWithHttpInfo($from, $to, $client, $contentType)
|
|
|
+ ->then(
|
|
|
+ function ($response) {
|
|
|
+ return $response[0];
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Operation getApiV3AdminReadingStatsAsyncWithHttpInfo
|
|
|
+ *
|
|
|
+ * 阅读统计
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $client 客户端 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Promise\PromiseInterface
|
|
|
+ */
|
|
|
+ public function getApiV3AdminReadingStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
|
|
|
+ {
|
|
|
+ $returnType = '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response';
|
|
|
+ $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $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 'getApiV3AdminReadingStats'
|
|
|
+ *
|
|
|
+ * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
|
|
|
+ * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
|
|
|
+ * @param string|null $client 客户端 (optional, default to 'all')
|
|
|
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
|
|
|
+ *
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @return \GuzzleHttp\Psr7\Request
|
|
|
+ */
|
|
|
+ public function getApiV3AdminReadingStatsRequest($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $resourcePath = '/v3/admin/reading-stats';
|
|
|
+ $formParams = [];
|
|
|
+ $queryParams = [];
|
|
|
+ $headerParams = [];
|
|
|
+ $httpBody = '';
|
|
|
+ $multipart = false;
|
|
|
+
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $from,
|
|
|
+ 'from', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $to,
|
|
|
+ 'to', // param base name
|
|
|
+ 'string', // openApiType
|
|
|
+ 'form', // style
|
|
|
+ true, // explode
|
|
|
+ false // required
|
|
|
+ ) ?? []);
|
|
|
+ // query params
|
|
|
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
|
|
|
+ $client,
|
|
|
+ 'client', // param base name
|
|
|
+ 'string', // 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
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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;
|
|
|
+ }
|
|
|
+}
|