AdminApi.php 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311
  1. <?php
  2. /**
  3. * AdminApi
  4. * PHP version 8.1
  5. *
  6. * @category Class
  7. * @package WikipaliApi
  8. * @author OpenAPI Generator team
  9. * @link https://openapi-generator.tech
  10. */
  11. /**
  12. * MINT API
  13. *
  14. * International Academy Of Pali Tipitaka(国际巴利三藏学院) 由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
  15. *
  16. * The version of the OpenAPI document: 2026.11.12
  17. * Generated by: https://openapi-generator.tech
  18. * Generator version: 7.25.0
  19. */
  20. /**
  21. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  22. * https://openapi-generator.tech
  23. * Do not edit the class manually.
  24. */
  25. namespace WikipaliApi\Api;
  26. use GuzzleHttp\Client;
  27. use GuzzleHttp\ClientInterface;
  28. use GuzzleHttp\Exception\ConnectException;
  29. use GuzzleHttp\Exception\RequestException;
  30. use GuzzleHttp\Psr7\MultipartStream;
  31. use GuzzleHttp\Psr7\Request;
  32. use GuzzleHttp\RequestOptions;
  33. use Psr\Http\Message\RequestInterface;
  34. use Psr\Http\Message\ResponseInterface;
  35. use WikipaliApi\ApiException;
  36. use WikipaliApi\Configuration;
  37. use WikipaliApi\FormDataProcessor;
  38. use WikipaliApi\HeaderSelector;
  39. use WikipaliApi\ObjectSerializer;
  40. /**
  41. * AdminApi Class Doc Comment
  42. *
  43. * @category Class
  44. * @package WikipaliApi
  45. * @author OpenAPI Generator team
  46. * @link https://openapi-generator.tech
  47. */
  48. class AdminApi
  49. {
  50. /**
  51. * @var ClientInterface
  52. */
  53. protected $client;
  54. /**
  55. * @var Configuration
  56. */
  57. protected $config;
  58. /**
  59. * @var HeaderSelector
  60. */
  61. protected $headerSelector;
  62. /**
  63. * @var int Host index
  64. */
  65. protected $hostIndex;
  66. /** @var string[] $contentTypes **/
  67. public const contentTypes = [
  68. 'getApiV3AdminAgentFeedback' => [
  69. 'application/json',
  70. ],
  71. 'getApiV3AdminAgentRuns' => [
  72. 'application/json',
  73. ],
  74. 'getApiV3AdminAgentRunsDigest' => [
  75. 'application/json',
  76. ],
  77. 'getApiV3AdminAgentRunsRun' => [
  78. 'application/json',
  79. ],
  80. 'getApiV3AdminAgentStats' => [
  81. 'application/json',
  82. ],
  83. 'getApiV3AdminReadingStats' => [
  84. 'application/json',
  85. ],
  86. ];
  87. /**
  88. * @param ClientInterface $client
  89. * @param Configuration $config
  90. * @param HeaderSelector $selector
  91. * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
  92. */
  93. public function __construct(
  94. ?ClientInterface $client = null,
  95. ?Configuration $config = null,
  96. ?HeaderSelector $selector = null,
  97. int $hostIndex = 0
  98. ) {
  99. $this->client = $client ?: new Client();
  100. $this->config = $config ?: Configuration::getDefaultConfiguration();
  101. $this->headerSelector = $selector ?: new HeaderSelector();
  102. $this->hostIndex = $hostIndex;
  103. }
  104. /**
  105. * Set the host index
  106. *
  107. * @param int $hostIndex Host index (required)
  108. */
  109. public function setHostIndex($hostIndex): void
  110. {
  111. $this->hostIndex = $hostIndex;
  112. }
  113. /**
  114. * Get the host index
  115. *
  116. * @return int Host index
  117. */
  118. public function getHostIndex()
  119. {
  120. return $this->hostIndex;
  121. }
  122. /**
  123. * @return Configuration
  124. */
  125. public function getConfig()
  126. {
  127. return $this->config;
  128. }
  129. /**
  130. * Operation getApiV3AdminAgentFeedback
  131. *
  132. * 列出评价
  133. *
  134. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  135. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  136. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  137. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  138. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  139. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  140. * @param int|null $page 页码 (optional, default to 1)
  141. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  142. *
  143. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  144. * @throws \InvalidArgumentException
  145. * @return \WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  146. */
  147. 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])
  148. {
  149. list($response) = $this->getApiV3AdminAgentFeedbackWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  150. return $response;
  151. }
  152. /**
  153. * Operation getApiV3AdminAgentFeedbackWithHttpInfo
  154. *
  155. * 列出评价
  156. *
  157. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  158. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  159. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  160. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  161. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  162. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  163. * @param int|null $page 页码 (optional, default to 1)
  164. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  165. *
  166. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  167. * @throws \InvalidArgumentException
  168. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  169. */
  170. 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])
  171. {
  172. $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  173. try {
  174. $options = $this->createHttpClientOption();
  175. try {
  176. $response = $this->client->send($request, $options);
  177. } catch (RequestException $e) {
  178. throw new ApiException(
  179. "[{$e->getCode()}] {$e->getMessage()}",
  180. (int) $e->getCode(),
  181. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  182. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  183. );
  184. } catch (ConnectException $e) {
  185. throw new ApiException(
  186. "[{$e->getCode()}] {$e->getMessage()}",
  187. (int) $e->getCode(),
  188. null,
  189. null
  190. );
  191. }
  192. $statusCode = $response->getStatusCode();
  193. switch($statusCode) {
  194. case 200:
  195. return $this->handleResponseWithDataType(
  196. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  197. $request,
  198. $response,
  199. );
  200. case 401:
  201. return $this->handleResponseWithDataType(
  202. '\WikipaliApi\Model\ProblemDetails',
  203. $request,
  204. $response,
  205. );
  206. case 422:
  207. return $this->handleResponseWithDataType(
  208. '\WikipaliApi\Model\ProblemDetails',
  209. $request,
  210. $response,
  211. );
  212. }
  213. if ($statusCode < 200 || $statusCode > 299) {
  214. throw new ApiException(
  215. sprintf(
  216. '[%d] Error connecting to the API (%s)',
  217. $statusCode,
  218. (string) $request->getUri()
  219. ),
  220. $statusCode,
  221. $response->getHeaders(),
  222. (string) $response->getBody()
  223. );
  224. }
  225. return $this->handleResponseWithDataType(
  226. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  227. $request,
  228. $response,
  229. );
  230. } catch (ApiException $e) {
  231. switch ($e->getCode()) {
  232. case 200:
  233. $data = ObjectSerializer::deserialize(
  234. $e->getResponseBody(),
  235. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  236. $e->getResponseHeaders()
  237. );
  238. $e->setResponseObject($data);
  239. throw $e;
  240. case 401:
  241. $data = ObjectSerializer::deserialize(
  242. $e->getResponseBody(),
  243. '\WikipaliApi\Model\ProblemDetails',
  244. $e->getResponseHeaders()
  245. );
  246. $e->setResponseObject($data);
  247. throw $e;
  248. case 422:
  249. $data = ObjectSerializer::deserialize(
  250. $e->getResponseBody(),
  251. '\WikipaliApi\Model\ProblemDetails',
  252. $e->getResponseHeaders()
  253. );
  254. $e->setResponseObject($data);
  255. throw $e;
  256. }
  257. throw $e;
  258. }
  259. }
  260. /**
  261. * Operation getApiV3AdminAgentFeedbackAsync
  262. *
  263. * 列出评价
  264. *
  265. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  266. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  267. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  268. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  269. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  270. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  271. * @param int|null $page 页码 (optional, default to 1)
  272. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  273. *
  274. * @throws \InvalidArgumentException
  275. * @return \GuzzleHttp\Promise\PromiseInterface
  276. */
  277. 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])
  278. {
  279. return $this->getApiV3AdminAgentFeedbackAsyncWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType)
  280. ->then(
  281. function ($response) {
  282. return $response[0];
  283. }
  284. );
  285. }
  286. /**
  287. * Operation getApiV3AdminAgentFeedbackAsyncWithHttpInfo
  288. *
  289. * 列出评价
  290. *
  291. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  292. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  293. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  294. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  295. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  296. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  297. * @param int|null $page 页码 (optional, default to 1)
  298. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  299. *
  300. * @throws \InvalidArgumentException
  301. * @return \GuzzleHttp\Promise\PromiseInterface
  302. */
  303. 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])
  304. {
  305. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response';
  306. $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  307. return $this->client
  308. ->sendAsync($request, $this->createHttpClientOption())
  309. ->then(
  310. function ($response) use ($returnType) {
  311. if ($returnType === '\SplFileObject') {
  312. $content = $response->getBody(); //stream goes to serializer
  313. } else {
  314. $content = (string) $response->getBody();
  315. if ($returnType !== 'string') {
  316. $content = json_decode($content);
  317. }
  318. }
  319. return [
  320. ObjectSerializer::deserialize($content, $returnType, []),
  321. $response->getStatusCode(),
  322. $response->getHeaders()
  323. ];
  324. },
  325. function ($exception) {
  326. $response = $exception->getResponse();
  327. $statusCode = $response->getStatusCode();
  328. throw new ApiException(
  329. sprintf(
  330. '[%d] Error connecting to the API (%s)',
  331. $statusCode,
  332. $exception->getRequest()->getUri()
  333. ),
  334. $statusCode,
  335. $response->getHeaders(),
  336. (string) $response->getBody()
  337. );
  338. }
  339. );
  340. }
  341. /**
  342. * Create request for operation 'getApiV3AdminAgentFeedback'
  343. *
  344. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  345. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  346. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  347. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  348. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  349. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  350. * @param int|null $page 页码 (optional, default to 1)
  351. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  352. *
  353. * @throws \InvalidArgumentException
  354. * @return \GuzzleHttp\Psr7\Request
  355. */
  356. 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])
  357. {
  358. $resourcePath = '/v3/admin/agent-feedback';
  359. $formParams = [];
  360. $queryParams = [];
  361. $headerParams = [];
  362. $httpBody = '';
  363. $multipart = false;
  364. // query params
  365. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  366. $per_page,
  367. 'per_page', // param base name
  368. 'integer', // openApiType
  369. 'form', // style
  370. true, // explode
  371. false // required
  372. ) ?? []);
  373. // query params
  374. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  375. $filter_rating,
  376. 'filter[rating]', // param base name
  377. 'string', // openApiType
  378. 'form', // style
  379. true, // explode
  380. false // required
  381. ) ?? []);
  382. // query params
  383. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  384. $filter_tag,
  385. 'filter[tag]', // param base name
  386. 'string', // openApiType
  387. 'form', // style
  388. true, // explode
  389. false // required
  390. ) ?? []);
  391. // query params
  392. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  393. $filter_has_comment,
  394. 'filter[has_comment]', // param base name
  395. 'boolean', // openApiType
  396. 'form', // style
  397. true, // explode
  398. false // required
  399. ) ?? []);
  400. // query params
  401. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  402. $from,
  403. 'from', // param base name
  404. 'string', // openApiType
  405. 'form', // style
  406. true, // explode
  407. false // required
  408. ) ?? []);
  409. // query params
  410. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  411. $to,
  412. 'to', // param base name
  413. 'string', // openApiType
  414. 'form', // style
  415. true, // explode
  416. false // required
  417. ) ?? []);
  418. // query params
  419. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  420. $page,
  421. 'page', // param base name
  422. 'integer', // openApiType
  423. 'form', // style
  424. true, // explode
  425. false // required
  426. ) ?? []);
  427. $headers = $this->headerSelector->selectHeaders(
  428. ['application/json', 'application/problem+json', ],
  429. $contentType,
  430. $multipart
  431. );
  432. // for model (json/xml)
  433. if (count($formParams) > 0) {
  434. if ($multipart) {
  435. $multipartContents = [];
  436. foreach ($formParams as $formParamName => $formParamValue) {
  437. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  438. foreach ($formParamValueItems as $formParamValueItem) {
  439. $multipartContents[] = [
  440. 'name' => $formParamName,
  441. 'contents' => $formParamValueItem
  442. ];
  443. }
  444. }
  445. // for HTTP post (form)
  446. $httpBody = new MultipartStream($multipartContents);
  447. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  448. # if Content-Type contains "application/json", json_encode the form parameters
  449. try {
  450. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  451. } catch (\JsonException $e) {
  452. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  453. }
  454. } else {
  455. // for HTTP post (form)
  456. $httpBody = ObjectSerializer::buildQuery($formParams);
  457. }
  458. }
  459. // this endpoint requires Bearer authentication (access token)
  460. if (!empty($this->config->getAccessToken())) {
  461. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  462. }
  463. $defaultHeaders = [];
  464. if ($this->config->getUserAgent()) {
  465. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  466. }
  467. $headers = array_merge(
  468. $defaultHeaders,
  469. $headerParams,
  470. $headers
  471. );
  472. $operationHost = $this->config->getHost();
  473. $query = ObjectSerializer::buildQuery($queryParams);
  474. return new Request(
  475. 'GET',
  476. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  477. $headers,
  478. $httpBody
  479. );
  480. }
  481. /**
  482. * Operation getApiV3AdminAgentRuns
  483. *
  484. * 列出提问
  485. *
  486. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  487. * @param string|null $filter_status 运行结果 (optional)
  488. * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
  489. * @param string|null $filter_account_type 账号类型 (optional)
  490. * @param string|null $filter_client 客户端 (optional)
  491. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  492. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  493. * @param int|null $page 页码 (optional, default to 1)
  494. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  495. *
  496. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  497. * @throws \InvalidArgumentException
  498. * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  499. */
  500. 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])
  501. {
  502. list($response) = $this->getApiV3AdminAgentRunsWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  503. return $response;
  504. }
  505. /**
  506. * Operation getApiV3AdminAgentRunsWithHttpInfo
  507. *
  508. * 列出提问
  509. *
  510. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  511. * @param string|null $filter_status 运行结果 (optional)
  512. * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
  513. * @param string|null $filter_account_type 账号类型 (optional)
  514. * @param string|null $filter_client 客户端 (optional)
  515. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  516. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  517. * @param int|null $page 页码 (optional, default to 1)
  518. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  519. *
  520. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  521. * @throws \InvalidArgumentException
  522. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  523. */
  524. 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])
  525. {
  526. $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  527. try {
  528. $options = $this->createHttpClientOption();
  529. try {
  530. $response = $this->client->send($request, $options);
  531. } catch (RequestException $e) {
  532. throw new ApiException(
  533. "[{$e->getCode()}] {$e->getMessage()}",
  534. (int) $e->getCode(),
  535. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  536. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  537. );
  538. } catch (ConnectException $e) {
  539. throw new ApiException(
  540. "[{$e->getCode()}] {$e->getMessage()}",
  541. (int) $e->getCode(),
  542. null,
  543. null
  544. );
  545. }
  546. $statusCode = $response->getStatusCode();
  547. switch($statusCode) {
  548. case 200:
  549. return $this->handleResponseWithDataType(
  550. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  551. $request,
  552. $response,
  553. );
  554. case 401:
  555. return $this->handleResponseWithDataType(
  556. '\WikipaliApi\Model\ProblemDetails',
  557. $request,
  558. $response,
  559. );
  560. case 422:
  561. return $this->handleResponseWithDataType(
  562. '\WikipaliApi\Model\ProblemDetails',
  563. $request,
  564. $response,
  565. );
  566. }
  567. if ($statusCode < 200 || $statusCode > 299) {
  568. throw new ApiException(
  569. sprintf(
  570. '[%d] Error connecting to the API (%s)',
  571. $statusCode,
  572. (string) $request->getUri()
  573. ),
  574. $statusCode,
  575. $response->getHeaders(),
  576. (string) $response->getBody()
  577. );
  578. }
  579. return $this->handleResponseWithDataType(
  580. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  581. $request,
  582. $response,
  583. );
  584. } catch (ApiException $e) {
  585. switch ($e->getCode()) {
  586. case 200:
  587. $data = ObjectSerializer::deserialize(
  588. $e->getResponseBody(),
  589. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  590. $e->getResponseHeaders()
  591. );
  592. $e->setResponseObject($data);
  593. throw $e;
  594. case 401:
  595. $data = ObjectSerializer::deserialize(
  596. $e->getResponseBody(),
  597. '\WikipaliApi\Model\ProblemDetails',
  598. $e->getResponseHeaders()
  599. );
  600. $e->setResponseObject($data);
  601. throw $e;
  602. case 422:
  603. $data = ObjectSerializer::deserialize(
  604. $e->getResponseBody(),
  605. '\WikipaliApi\Model\ProblemDetails',
  606. $e->getResponseHeaders()
  607. );
  608. $e->setResponseObject($data);
  609. throw $e;
  610. }
  611. throw $e;
  612. }
  613. }
  614. /**
  615. * Operation getApiV3AdminAgentRunsAsync
  616. *
  617. * 列出提问
  618. *
  619. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  620. * @param string|null $filter_status 运行结果 (optional)
  621. * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
  622. * @param string|null $filter_account_type 账号类型 (optional)
  623. * @param string|null $filter_client 客户端 (optional)
  624. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  625. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  626. * @param int|null $page 页码 (optional, default to 1)
  627. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  628. *
  629. * @throws \InvalidArgumentException
  630. * @return \GuzzleHttp\Promise\PromiseInterface
  631. */
  632. 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])
  633. {
  634. return $this->getApiV3AdminAgentRunsAsyncWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType)
  635. ->then(
  636. function ($response) {
  637. return $response[0];
  638. }
  639. );
  640. }
  641. /**
  642. * Operation getApiV3AdminAgentRunsAsyncWithHttpInfo
  643. *
  644. * 列出提问
  645. *
  646. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  647. * @param string|null $filter_status 运行结果 (optional)
  648. * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
  649. * @param string|null $filter_account_type 账号类型 (optional)
  650. * @param string|null $filter_client 客户端 (optional)
  651. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  652. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  653. * @param int|null $page 页码 (optional, default to 1)
  654. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  655. *
  656. * @throws \InvalidArgumentException
  657. * @return \GuzzleHttp\Promise\PromiseInterface
  658. */
  659. 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])
  660. {
  661. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response';
  662. $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  663. return $this->client
  664. ->sendAsync($request, $this->createHttpClientOption())
  665. ->then(
  666. function ($response) use ($returnType) {
  667. if ($returnType === '\SplFileObject') {
  668. $content = $response->getBody(); //stream goes to serializer
  669. } else {
  670. $content = (string) $response->getBody();
  671. if ($returnType !== 'string') {
  672. $content = json_decode($content);
  673. }
  674. }
  675. return [
  676. ObjectSerializer::deserialize($content, $returnType, []),
  677. $response->getStatusCode(),
  678. $response->getHeaders()
  679. ];
  680. },
  681. function ($exception) {
  682. $response = $exception->getResponse();
  683. $statusCode = $response->getStatusCode();
  684. throw new ApiException(
  685. sprintf(
  686. '[%d] Error connecting to the API (%s)',
  687. $statusCode,
  688. $exception->getRequest()->getUri()
  689. ),
  690. $statusCode,
  691. $response->getHeaders(),
  692. (string) $response->getBody()
  693. );
  694. }
  695. );
  696. }
  697. /**
  698. * Create request for operation 'getApiV3AdminAgentRuns'
  699. *
  700. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  701. * @param string|null $filter_status 运行结果 (optional)
  702. * @param string|null $filter_route 研究路径(question / term / passage / chat) (optional)
  703. * @param string|null $filter_account_type 账号类型 (optional)
  704. * @param string|null $filter_client 客户端 (optional)
  705. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  706. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  707. * @param int|null $page 页码 (optional, default to 1)
  708. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  709. *
  710. * @throws \InvalidArgumentException
  711. * @return \GuzzleHttp\Psr7\Request
  712. */
  713. 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])
  714. {
  715. $resourcePath = '/v3/admin/agent-runs';
  716. $formParams = [];
  717. $queryParams = [];
  718. $headerParams = [];
  719. $httpBody = '';
  720. $multipart = false;
  721. // query params
  722. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  723. $per_page,
  724. 'per_page', // param base name
  725. 'integer', // openApiType
  726. 'form', // style
  727. true, // explode
  728. false // required
  729. ) ?? []);
  730. // query params
  731. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  732. $filter_status,
  733. 'filter[status]', // param base name
  734. 'string', // openApiType
  735. 'form', // style
  736. true, // explode
  737. false // required
  738. ) ?? []);
  739. // query params
  740. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  741. $filter_route,
  742. 'filter[route]', // param base name
  743. 'string', // openApiType
  744. 'form', // style
  745. true, // explode
  746. false // required
  747. ) ?? []);
  748. // query params
  749. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  750. $filter_account_type,
  751. 'filter[account_type]', // param base name
  752. 'string', // openApiType
  753. 'form', // style
  754. true, // explode
  755. false // required
  756. ) ?? []);
  757. // query params
  758. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  759. $filter_client,
  760. 'filter[client]', // param base name
  761. 'string', // openApiType
  762. 'form', // style
  763. true, // explode
  764. false // required
  765. ) ?? []);
  766. // query params
  767. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  768. $filter_improve,
  769. 'filter[improve]', // param base name
  770. 'boolean', // openApiType
  771. 'form', // style
  772. true, // explode
  773. false // required
  774. ) ?? []);
  775. // query params
  776. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  777. $filter_q,
  778. 'filter[q]', // param base name
  779. 'string', // openApiType
  780. 'form', // style
  781. true, // explode
  782. false // required
  783. ) ?? []);
  784. // query params
  785. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  786. $page,
  787. 'page', // param base name
  788. 'integer', // openApiType
  789. 'form', // style
  790. true, // explode
  791. false // required
  792. ) ?? []);
  793. $headers = $this->headerSelector->selectHeaders(
  794. ['application/json', 'application/problem+json', ],
  795. $contentType,
  796. $multipart
  797. );
  798. // for model (json/xml)
  799. if (count($formParams) > 0) {
  800. if ($multipart) {
  801. $multipartContents = [];
  802. foreach ($formParams as $formParamName => $formParamValue) {
  803. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  804. foreach ($formParamValueItems as $formParamValueItem) {
  805. $multipartContents[] = [
  806. 'name' => $formParamName,
  807. 'contents' => $formParamValueItem
  808. ];
  809. }
  810. }
  811. // for HTTP post (form)
  812. $httpBody = new MultipartStream($multipartContents);
  813. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  814. # if Content-Type contains "application/json", json_encode the form parameters
  815. try {
  816. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  817. } catch (\JsonException $e) {
  818. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  819. }
  820. } else {
  821. // for HTTP post (form)
  822. $httpBody = ObjectSerializer::buildQuery($formParams);
  823. }
  824. }
  825. // this endpoint requires Bearer authentication (access token)
  826. if (!empty($this->config->getAccessToken())) {
  827. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  828. }
  829. $defaultHeaders = [];
  830. if ($this->config->getUserAgent()) {
  831. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  832. }
  833. $headers = array_merge(
  834. $defaultHeaders,
  835. $headerParams,
  836. $headers
  837. );
  838. $operationHost = $this->config->getHost();
  839. $query = ObjectSerializer::buildQuery($queryParams);
  840. return new Request(
  841. 'GET',
  842. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  843. $headers,
  844. $httpBody
  845. );
  846. }
  847. /**
  848. * Operation getApiV3AdminAgentRunsDigest
  849. *
  850. * 分析用的精简导出
  851. *
  852. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  853. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  854. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  855. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  856. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  857. *
  858. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  859. * @throws \InvalidArgumentException
  860. * @return \WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  861. */
  862. public function getApiV3AdminAgentRunsDigest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  863. {
  864. list($response) = $this->getApiV3AdminAgentRunsDigestWithHttpInfo($full, $limit, $from, $to, $contentType);
  865. return $response;
  866. }
  867. /**
  868. * Operation getApiV3AdminAgentRunsDigestWithHttpInfo
  869. *
  870. * 分析用的精简导出
  871. *
  872. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  873. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  874. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  875. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  876. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  877. *
  878. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  879. * @throws \InvalidArgumentException
  880. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  881. */
  882. public function getApiV3AdminAgentRunsDigestWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  883. {
  884. $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $contentType);
  885. try {
  886. $options = $this->createHttpClientOption();
  887. try {
  888. $response = $this->client->send($request, $options);
  889. } catch (RequestException $e) {
  890. throw new ApiException(
  891. "[{$e->getCode()}] {$e->getMessage()}",
  892. (int) $e->getCode(),
  893. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  894. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  895. );
  896. } catch (ConnectException $e) {
  897. throw new ApiException(
  898. "[{$e->getCode()}] {$e->getMessage()}",
  899. (int) $e->getCode(),
  900. null,
  901. null
  902. );
  903. }
  904. $statusCode = $response->getStatusCode();
  905. switch($statusCode) {
  906. case 200:
  907. return $this->handleResponseWithDataType(
  908. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  909. $request,
  910. $response,
  911. );
  912. case 401:
  913. return $this->handleResponseWithDataType(
  914. '\WikipaliApi\Model\ProblemDetails',
  915. $request,
  916. $response,
  917. );
  918. case 422:
  919. return $this->handleResponseWithDataType(
  920. '\WikipaliApi\Model\ProblemDetails',
  921. $request,
  922. $response,
  923. );
  924. }
  925. if ($statusCode < 200 || $statusCode > 299) {
  926. throw new ApiException(
  927. sprintf(
  928. '[%d] Error connecting to the API (%s)',
  929. $statusCode,
  930. (string) $request->getUri()
  931. ),
  932. $statusCode,
  933. $response->getHeaders(),
  934. (string) $response->getBody()
  935. );
  936. }
  937. return $this->handleResponseWithDataType(
  938. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  939. $request,
  940. $response,
  941. );
  942. } catch (ApiException $e) {
  943. switch ($e->getCode()) {
  944. case 200:
  945. $data = ObjectSerializer::deserialize(
  946. $e->getResponseBody(),
  947. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  948. $e->getResponseHeaders()
  949. );
  950. $e->setResponseObject($data);
  951. throw $e;
  952. case 401:
  953. $data = ObjectSerializer::deserialize(
  954. $e->getResponseBody(),
  955. '\WikipaliApi\Model\ProblemDetails',
  956. $e->getResponseHeaders()
  957. );
  958. $e->setResponseObject($data);
  959. throw $e;
  960. case 422:
  961. $data = ObjectSerializer::deserialize(
  962. $e->getResponseBody(),
  963. '\WikipaliApi\Model\ProblemDetails',
  964. $e->getResponseHeaders()
  965. );
  966. $e->setResponseObject($data);
  967. throw $e;
  968. }
  969. throw $e;
  970. }
  971. }
  972. /**
  973. * Operation getApiV3AdminAgentRunsDigestAsync
  974. *
  975. * 分析用的精简导出
  976. *
  977. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  978. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  979. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  980. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  981. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  982. *
  983. * @throws \InvalidArgumentException
  984. * @return \GuzzleHttp\Promise\PromiseInterface
  985. */
  986. public function getApiV3AdminAgentRunsDigestAsync($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  987. {
  988. return $this->getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full, $limit, $from, $to, $contentType)
  989. ->then(
  990. function ($response) {
  991. return $response[0];
  992. }
  993. );
  994. }
  995. /**
  996. * Operation getApiV3AdminAgentRunsDigestAsyncWithHttpInfo
  997. *
  998. * 分析用的精简导出
  999. *
  1000. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  1001. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  1002. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1003. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1004. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  1005. *
  1006. * @throws \InvalidArgumentException
  1007. * @return \GuzzleHttp\Promise\PromiseInterface
  1008. */
  1009. public function getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  1010. {
  1011. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response';
  1012. $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $contentType);
  1013. return $this->client
  1014. ->sendAsync($request, $this->createHttpClientOption())
  1015. ->then(
  1016. function ($response) use ($returnType) {
  1017. if ($returnType === '\SplFileObject') {
  1018. $content = $response->getBody(); //stream goes to serializer
  1019. } else {
  1020. $content = (string) $response->getBody();
  1021. if ($returnType !== 'string') {
  1022. $content = json_decode($content);
  1023. }
  1024. }
  1025. return [
  1026. ObjectSerializer::deserialize($content, $returnType, []),
  1027. $response->getStatusCode(),
  1028. $response->getHeaders()
  1029. ];
  1030. },
  1031. function ($exception) {
  1032. $response = $exception->getResponse();
  1033. $statusCode = $response->getStatusCode();
  1034. throw new ApiException(
  1035. sprintf(
  1036. '[%d] Error connecting to the API (%s)',
  1037. $statusCode,
  1038. $exception->getRequest()->getUri()
  1039. ),
  1040. $statusCode,
  1041. $response->getHeaders(),
  1042. (string) $response->getBody()
  1043. );
  1044. }
  1045. );
  1046. }
  1047. /**
  1048. * Create request for operation 'getApiV3AdminAgentRunsDigest'
  1049. *
  1050. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  1051. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  1052. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1053. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1054. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  1055. *
  1056. * @throws \InvalidArgumentException
  1057. * @return \GuzzleHttp\Psr7\Request
  1058. */
  1059. public function getApiV3AdminAgentRunsDigestRequest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  1060. {
  1061. $resourcePath = '/v3/admin/agent-runs/digest';
  1062. $formParams = [];
  1063. $queryParams = [];
  1064. $headerParams = [];
  1065. $httpBody = '';
  1066. $multipart = false;
  1067. // query params
  1068. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1069. $full,
  1070. 'full', // param base name
  1071. 'boolean', // openApiType
  1072. 'form', // style
  1073. true, // explode
  1074. false // required
  1075. ) ?? []);
  1076. // query params
  1077. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1078. $limit,
  1079. 'limit', // param base name
  1080. 'integer', // openApiType
  1081. 'form', // style
  1082. true, // explode
  1083. false // required
  1084. ) ?? []);
  1085. // query params
  1086. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1087. $from,
  1088. 'from', // param base name
  1089. 'string', // openApiType
  1090. 'form', // style
  1091. true, // explode
  1092. false // required
  1093. ) ?? []);
  1094. // query params
  1095. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1096. $to,
  1097. 'to', // param base name
  1098. 'string', // openApiType
  1099. 'form', // style
  1100. true, // explode
  1101. false // required
  1102. ) ?? []);
  1103. $headers = $this->headerSelector->selectHeaders(
  1104. ['application/json', 'application/problem+json', ],
  1105. $contentType,
  1106. $multipart
  1107. );
  1108. // for model (json/xml)
  1109. if (count($formParams) > 0) {
  1110. if ($multipart) {
  1111. $multipartContents = [];
  1112. foreach ($formParams as $formParamName => $formParamValue) {
  1113. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1114. foreach ($formParamValueItems as $formParamValueItem) {
  1115. $multipartContents[] = [
  1116. 'name' => $formParamName,
  1117. 'contents' => $formParamValueItem
  1118. ];
  1119. }
  1120. }
  1121. // for HTTP post (form)
  1122. $httpBody = new MultipartStream($multipartContents);
  1123. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1124. # if Content-Type contains "application/json", json_encode the form parameters
  1125. try {
  1126. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1127. } catch (\JsonException $e) {
  1128. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1129. }
  1130. } else {
  1131. // for HTTP post (form)
  1132. $httpBody = ObjectSerializer::buildQuery($formParams);
  1133. }
  1134. }
  1135. // this endpoint requires Bearer authentication (access token)
  1136. if (!empty($this->config->getAccessToken())) {
  1137. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1138. }
  1139. $defaultHeaders = [];
  1140. if ($this->config->getUserAgent()) {
  1141. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1142. }
  1143. $headers = array_merge(
  1144. $defaultHeaders,
  1145. $headerParams,
  1146. $headers
  1147. );
  1148. $operationHost = $this->config->getHost();
  1149. $query = ObjectSerializer::buildQuery($queryParams);
  1150. return new Request(
  1151. 'GET',
  1152. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1153. $headers,
  1154. $httpBody
  1155. );
  1156. }
  1157. /**
  1158. * Operation getApiV3AdminAgentRunsRun
  1159. *
  1160. * 查看一次提问的研究过程
  1161. *
  1162. * @param string $run AG-UI runId(uuid) (required)
  1163. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1164. *
  1165. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1166. * @throws \InvalidArgumentException
  1167. * @return \WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1168. */
  1169. public function getApiV3AdminAgentRunsRun($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1170. {
  1171. list($response) = $this->getApiV3AdminAgentRunsRunWithHttpInfo($run, $contentType);
  1172. return $response;
  1173. }
  1174. /**
  1175. * Operation getApiV3AdminAgentRunsRunWithHttpInfo
  1176. *
  1177. * 查看一次提问的研究过程
  1178. *
  1179. * @param string $run AG-UI runId(uuid) (required)
  1180. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1181. *
  1182. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1183. * @throws \InvalidArgumentException
  1184. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1185. */
  1186. public function getApiV3AdminAgentRunsRunWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1187. {
  1188. $request = $this->getApiV3AdminAgentRunsRunRequest($run, $contentType);
  1189. try {
  1190. $options = $this->createHttpClientOption();
  1191. try {
  1192. $response = $this->client->send($request, $options);
  1193. } catch (RequestException $e) {
  1194. throw new ApiException(
  1195. "[{$e->getCode()}] {$e->getMessage()}",
  1196. (int) $e->getCode(),
  1197. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1198. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1199. );
  1200. } catch (ConnectException $e) {
  1201. throw new ApiException(
  1202. "[{$e->getCode()}] {$e->getMessage()}",
  1203. (int) $e->getCode(),
  1204. null,
  1205. null
  1206. );
  1207. }
  1208. $statusCode = $response->getStatusCode();
  1209. switch($statusCode) {
  1210. case 200:
  1211. return $this->handleResponseWithDataType(
  1212. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1213. $request,
  1214. $response,
  1215. );
  1216. case 401:
  1217. return $this->handleResponseWithDataType(
  1218. '\WikipaliApi\Model\ProblemDetails',
  1219. $request,
  1220. $response,
  1221. );
  1222. case 422:
  1223. return $this->handleResponseWithDataType(
  1224. '\WikipaliApi\Model\ProblemDetails',
  1225. $request,
  1226. $response,
  1227. );
  1228. }
  1229. if ($statusCode < 200 || $statusCode > 299) {
  1230. throw new ApiException(
  1231. sprintf(
  1232. '[%d] Error connecting to the API (%s)',
  1233. $statusCode,
  1234. (string) $request->getUri()
  1235. ),
  1236. $statusCode,
  1237. $response->getHeaders(),
  1238. (string) $response->getBody()
  1239. );
  1240. }
  1241. return $this->handleResponseWithDataType(
  1242. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1243. $request,
  1244. $response,
  1245. );
  1246. } catch (ApiException $e) {
  1247. switch ($e->getCode()) {
  1248. case 200:
  1249. $data = ObjectSerializer::deserialize(
  1250. $e->getResponseBody(),
  1251. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1252. $e->getResponseHeaders()
  1253. );
  1254. $e->setResponseObject($data);
  1255. throw $e;
  1256. case 401:
  1257. $data = ObjectSerializer::deserialize(
  1258. $e->getResponseBody(),
  1259. '\WikipaliApi\Model\ProblemDetails',
  1260. $e->getResponseHeaders()
  1261. );
  1262. $e->setResponseObject($data);
  1263. throw $e;
  1264. case 422:
  1265. $data = ObjectSerializer::deserialize(
  1266. $e->getResponseBody(),
  1267. '\WikipaliApi\Model\ProblemDetails',
  1268. $e->getResponseHeaders()
  1269. );
  1270. $e->setResponseObject($data);
  1271. throw $e;
  1272. }
  1273. throw $e;
  1274. }
  1275. }
  1276. /**
  1277. * Operation getApiV3AdminAgentRunsRunAsync
  1278. *
  1279. * 查看一次提问的研究过程
  1280. *
  1281. * @param string $run AG-UI runId(uuid) (required)
  1282. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1283. *
  1284. * @throws \InvalidArgumentException
  1285. * @return \GuzzleHttp\Promise\PromiseInterface
  1286. */
  1287. public function getApiV3AdminAgentRunsRunAsync($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1288. {
  1289. return $this->getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, $contentType)
  1290. ->then(
  1291. function ($response) {
  1292. return $response[0];
  1293. }
  1294. );
  1295. }
  1296. /**
  1297. * Operation getApiV3AdminAgentRunsRunAsyncWithHttpInfo
  1298. *
  1299. * 查看一次提问的研究过程
  1300. *
  1301. * @param string $run AG-UI runId(uuid) (required)
  1302. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1303. *
  1304. * @throws \InvalidArgumentException
  1305. * @return \GuzzleHttp\Promise\PromiseInterface
  1306. */
  1307. public function getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1308. {
  1309. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response';
  1310. $request = $this->getApiV3AdminAgentRunsRunRequest($run, $contentType);
  1311. return $this->client
  1312. ->sendAsync($request, $this->createHttpClientOption())
  1313. ->then(
  1314. function ($response) use ($returnType) {
  1315. if ($returnType === '\SplFileObject') {
  1316. $content = $response->getBody(); //stream goes to serializer
  1317. } else {
  1318. $content = (string) $response->getBody();
  1319. if ($returnType !== 'string') {
  1320. $content = json_decode($content);
  1321. }
  1322. }
  1323. return [
  1324. ObjectSerializer::deserialize($content, $returnType, []),
  1325. $response->getStatusCode(),
  1326. $response->getHeaders()
  1327. ];
  1328. },
  1329. function ($exception) {
  1330. $response = $exception->getResponse();
  1331. $statusCode = $response->getStatusCode();
  1332. throw new ApiException(
  1333. sprintf(
  1334. '[%d] Error connecting to the API (%s)',
  1335. $statusCode,
  1336. $exception->getRequest()->getUri()
  1337. ),
  1338. $statusCode,
  1339. $response->getHeaders(),
  1340. (string) $response->getBody()
  1341. );
  1342. }
  1343. );
  1344. }
  1345. /**
  1346. * Create request for operation 'getApiV3AdminAgentRunsRun'
  1347. *
  1348. * @param string $run AG-UI runId(uuid) (required)
  1349. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1350. *
  1351. * @throws \InvalidArgumentException
  1352. * @return \GuzzleHttp\Psr7\Request
  1353. */
  1354. public function getApiV3AdminAgentRunsRunRequest($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1355. {
  1356. // verify the required parameter 'run' is set
  1357. if ($run === null || (is_array($run) && count($run) === 0)) {
  1358. throw new \InvalidArgumentException(
  1359. 'Missing the required parameter $run when calling getApiV3AdminAgentRunsRun'
  1360. );
  1361. }
  1362. $resourcePath = '/v3/admin/agent-runs/{run}';
  1363. $formParams = [];
  1364. $queryParams = [];
  1365. $headerParams = [];
  1366. $httpBody = '';
  1367. $multipart = false;
  1368. // path params
  1369. if ($run !== null) {
  1370. $resourcePath = str_replace(
  1371. '{run}',
  1372. ObjectSerializer::toPathValue($run),
  1373. $resourcePath
  1374. );
  1375. }
  1376. $headers = $this->headerSelector->selectHeaders(
  1377. ['application/json', 'application/problem+json', ],
  1378. $contentType,
  1379. $multipart
  1380. );
  1381. // for model (json/xml)
  1382. if (count($formParams) > 0) {
  1383. if ($multipart) {
  1384. $multipartContents = [];
  1385. foreach ($formParams as $formParamName => $formParamValue) {
  1386. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1387. foreach ($formParamValueItems as $formParamValueItem) {
  1388. $multipartContents[] = [
  1389. 'name' => $formParamName,
  1390. 'contents' => $formParamValueItem
  1391. ];
  1392. }
  1393. }
  1394. // for HTTP post (form)
  1395. $httpBody = new MultipartStream($multipartContents);
  1396. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1397. # if Content-Type contains "application/json", json_encode the form parameters
  1398. try {
  1399. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1400. } catch (\JsonException $e) {
  1401. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1402. }
  1403. } else {
  1404. // for HTTP post (form)
  1405. $httpBody = ObjectSerializer::buildQuery($formParams);
  1406. }
  1407. }
  1408. // this endpoint requires Bearer authentication (access token)
  1409. if (!empty($this->config->getAccessToken())) {
  1410. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1411. }
  1412. $defaultHeaders = [];
  1413. if ($this->config->getUserAgent()) {
  1414. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1415. }
  1416. $headers = array_merge(
  1417. $defaultHeaders,
  1418. $headerParams,
  1419. $headers
  1420. );
  1421. $operationHost = $this->config->getHost();
  1422. $query = ObjectSerializer::buildQuery($queryParams);
  1423. return new Request(
  1424. 'GET',
  1425. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1426. $headers,
  1427. $httpBody
  1428. );
  1429. }
  1430. /**
  1431. * Operation getApiV3AdminAgentStats
  1432. *
  1433. * AI 对话统计
  1434. *
  1435. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1436. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1437. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1438. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1439. *
  1440. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1441. * @throws \InvalidArgumentException
  1442. * @return \WikipaliApi\Model\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1443. */
  1444. public function getApiV3AdminAgentStats($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1445. {
  1446. list($response) = $this->getApiV3AdminAgentStatsWithHttpInfo($from, $to, $account_type, $contentType);
  1447. return $response;
  1448. }
  1449. /**
  1450. * Operation getApiV3AdminAgentStatsWithHttpInfo
  1451. *
  1452. * AI 对话统计
  1453. *
  1454. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1455. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1456. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1457. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1458. *
  1459. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1460. * @throws \InvalidArgumentException
  1461. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1462. */
  1463. public function getApiV3AdminAgentStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1464. {
  1465. $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $contentType);
  1466. try {
  1467. $options = $this->createHttpClientOption();
  1468. try {
  1469. $response = $this->client->send($request, $options);
  1470. } catch (RequestException $e) {
  1471. throw new ApiException(
  1472. "[{$e->getCode()}] {$e->getMessage()}",
  1473. (int) $e->getCode(),
  1474. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1475. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1476. );
  1477. } catch (ConnectException $e) {
  1478. throw new ApiException(
  1479. "[{$e->getCode()}] {$e->getMessage()}",
  1480. (int) $e->getCode(),
  1481. null,
  1482. null
  1483. );
  1484. }
  1485. $statusCode = $response->getStatusCode();
  1486. switch($statusCode) {
  1487. case 200:
  1488. return $this->handleResponseWithDataType(
  1489. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1490. $request,
  1491. $response,
  1492. );
  1493. case 401:
  1494. return $this->handleResponseWithDataType(
  1495. '\WikipaliApi\Model\ProblemDetails',
  1496. $request,
  1497. $response,
  1498. );
  1499. case 422:
  1500. return $this->handleResponseWithDataType(
  1501. '\WikipaliApi\Model\ProblemDetails',
  1502. $request,
  1503. $response,
  1504. );
  1505. }
  1506. if ($statusCode < 200 || $statusCode > 299) {
  1507. throw new ApiException(
  1508. sprintf(
  1509. '[%d] Error connecting to the API (%s)',
  1510. $statusCode,
  1511. (string) $request->getUri()
  1512. ),
  1513. $statusCode,
  1514. $response->getHeaders(),
  1515. (string) $response->getBody()
  1516. );
  1517. }
  1518. return $this->handleResponseWithDataType(
  1519. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1520. $request,
  1521. $response,
  1522. );
  1523. } catch (ApiException $e) {
  1524. switch ($e->getCode()) {
  1525. case 200:
  1526. $data = ObjectSerializer::deserialize(
  1527. $e->getResponseBody(),
  1528. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1529. $e->getResponseHeaders()
  1530. );
  1531. $e->setResponseObject($data);
  1532. throw $e;
  1533. case 401:
  1534. $data = ObjectSerializer::deserialize(
  1535. $e->getResponseBody(),
  1536. '\WikipaliApi\Model\ProblemDetails',
  1537. $e->getResponseHeaders()
  1538. );
  1539. $e->setResponseObject($data);
  1540. throw $e;
  1541. case 422:
  1542. $data = ObjectSerializer::deserialize(
  1543. $e->getResponseBody(),
  1544. '\WikipaliApi\Model\ProblemDetails',
  1545. $e->getResponseHeaders()
  1546. );
  1547. $e->setResponseObject($data);
  1548. throw $e;
  1549. }
  1550. throw $e;
  1551. }
  1552. }
  1553. /**
  1554. * Operation getApiV3AdminAgentStatsAsync
  1555. *
  1556. * AI 对话统计
  1557. *
  1558. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1559. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1560. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1561. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1562. *
  1563. * @throws \InvalidArgumentException
  1564. * @return \GuzzleHttp\Promise\PromiseInterface
  1565. */
  1566. public function getApiV3AdminAgentStatsAsync($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1567. {
  1568. return $this->getApiV3AdminAgentStatsAsyncWithHttpInfo($from, $to, $account_type, $contentType)
  1569. ->then(
  1570. function ($response) {
  1571. return $response[0];
  1572. }
  1573. );
  1574. }
  1575. /**
  1576. * Operation getApiV3AdminAgentStatsAsyncWithHttpInfo
  1577. *
  1578. * AI 对话统计
  1579. *
  1580. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1581. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1582. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1583. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1584. *
  1585. * @throws \InvalidArgumentException
  1586. * @return \GuzzleHttp\Promise\PromiseInterface
  1587. */
  1588. public function getApiV3AdminAgentStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1589. {
  1590. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response';
  1591. $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $contentType);
  1592. return $this->client
  1593. ->sendAsync($request, $this->createHttpClientOption())
  1594. ->then(
  1595. function ($response) use ($returnType) {
  1596. if ($returnType === '\SplFileObject') {
  1597. $content = $response->getBody(); //stream goes to serializer
  1598. } else {
  1599. $content = (string) $response->getBody();
  1600. if ($returnType !== 'string') {
  1601. $content = json_decode($content);
  1602. }
  1603. }
  1604. return [
  1605. ObjectSerializer::deserialize($content, $returnType, []),
  1606. $response->getStatusCode(),
  1607. $response->getHeaders()
  1608. ];
  1609. },
  1610. function ($exception) {
  1611. $response = $exception->getResponse();
  1612. $statusCode = $response->getStatusCode();
  1613. throw new ApiException(
  1614. sprintf(
  1615. '[%d] Error connecting to the API (%s)',
  1616. $statusCode,
  1617. $exception->getRequest()->getUri()
  1618. ),
  1619. $statusCode,
  1620. $response->getHeaders(),
  1621. (string) $response->getBody()
  1622. );
  1623. }
  1624. );
  1625. }
  1626. /**
  1627. * Create request for operation 'getApiV3AdminAgentStats'
  1628. *
  1629. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1630. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1631. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1632. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1633. *
  1634. * @throws \InvalidArgumentException
  1635. * @return \GuzzleHttp\Psr7\Request
  1636. */
  1637. public function getApiV3AdminAgentStatsRequest($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1638. {
  1639. $resourcePath = '/v3/admin/agent-stats';
  1640. $formParams = [];
  1641. $queryParams = [];
  1642. $headerParams = [];
  1643. $httpBody = '';
  1644. $multipart = false;
  1645. // query params
  1646. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1647. $from,
  1648. 'from', // param base name
  1649. 'string', // openApiType
  1650. 'form', // style
  1651. true, // explode
  1652. false // required
  1653. ) ?? []);
  1654. // query params
  1655. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1656. $to,
  1657. 'to', // param base name
  1658. 'string', // openApiType
  1659. 'form', // style
  1660. true, // explode
  1661. false // required
  1662. ) ?? []);
  1663. // query params
  1664. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1665. $account_type,
  1666. 'account_type', // param base name
  1667. 'string', // openApiType
  1668. 'form', // style
  1669. true, // explode
  1670. false // required
  1671. ) ?? []);
  1672. $headers = $this->headerSelector->selectHeaders(
  1673. ['application/json', 'application/problem+json', ],
  1674. $contentType,
  1675. $multipart
  1676. );
  1677. // for model (json/xml)
  1678. if (count($formParams) > 0) {
  1679. if ($multipart) {
  1680. $multipartContents = [];
  1681. foreach ($formParams as $formParamName => $formParamValue) {
  1682. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1683. foreach ($formParamValueItems as $formParamValueItem) {
  1684. $multipartContents[] = [
  1685. 'name' => $formParamName,
  1686. 'contents' => $formParamValueItem
  1687. ];
  1688. }
  1689. }
  1690. // for HTTP post (form)
  1691. $httpBody = new MultipartStream($multipartContents);
  1692. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1693. # if Content-Type contains "application/json", json_encode the form parameters
  1694. try {
  1695. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1696. } catch (\JsonException $e) {
  1697. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1698. }
  1699. } else {
  1700. // for HTTP post (form)
  1701. $httpBody = ObjectSerializer::buildQuery($formParams);
  1702. }
  1703. }
  1704. // this endpoint requires Bearer authentication (access token)
  1705. if (!empty($this->config->getAccessToken())) {
  1706. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1707. }
  1708. $defaultHeaders = [];
  1709. if ($this->config->getUserAgent()) {
  1710. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1711. }
  1712. $headers = array_merge(
  1713. $defaultHeaders,
  1714. $headerParams,
  1715. $headers
  1716. );
  1717. $operationHost = $this->config->getHost();
  1718. $query = ObjectSerializer::buildQuery($queryParams);
  1719. return new Request(
  1720. 'GET',
  1721. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1722. $headers,
  1723. $httpBody
  1724. );
  1725. }
  1726. /**
  1727. * Operation getApiV3AdminReadingStats
  1728. *
  1729. * 阅读统计
  1730. *
  1731. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1732. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1733. * @param string|null $client 客户端 (optional, default to 'all')
  1734. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  1735. *
  1736. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1737. * @throws \InvalidArgumentException
  1738. * @return \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1739. */
  1740. public function getApiV3AdminReadingStats($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  1741. {
  1742. list($response) = $this->getApiV3AdminReadingStatsWithHttpInfo($from, $to, $client, $contentType);
  1743. return $response;
  1744. }
  1745. /**
  1746. * Operation getApiV3AdminReadingStatsWithHttpInfo
  1747. *
  1748. * 阅读统计
  1749. *
  1750. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1751. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1752. * @param string|null $client 客户端 (optional, default to 'all')
  1753. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  1754. *
  1755. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1756. * @throws \InvalidArgumentException
  1757. * @return array of \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1758. */
  1759. public function getApiV3AdminReadingStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  1760. {
  1761. $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
  1762. try {
  1763. $options = $this->createHttpClientOption();
  1764. try {
  1765. $response = $this->client->send($request, $options);
  1766. } catch (RequestException $e) {
  1767. throw new ApiException(
  1768. "[{$e->getCode()}] {$e->getMessage()}",
  1769. (int) $e->getCode(),
  1770. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1771. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1772. );
  1773. } catch (ConnectException $e) {
  1774. throw new ApiException(
  1775. "[{$e->getCode()}] {$e->getMessage()}",
  1776. (int) $e->getCode(),
  1777. null,
  1778. null
  1779. );
  1780. }
  1781. $statusCode = $response->getStatusCode();
  1782. switch($statusCode) {
  1783. case 200:
  1784. return $this->handleResponseWithDataType(
  1785. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  1786. $request,
  1787. $response,
  1788. );
  1789. case 401:
  1790. return $this->handleResponseWithDataType(
  1791. '\WikipaliApi\Model\ProblemDetails',
  1792. $request,
  1793. $response,
  1794. );
  1795. case 422:
  1796. return $this->handleResponseWithDataType(
  1797. '\WikipaliApi\Model\ProblemDetails',
  1798. $request,
  1799. $response,
  1800. );
  1801. }
  1802. if ($statusCode < 200 || $statusCode > 299) {
  1803. throw new ApiException(
  1804. sprintf(
  1805. '[%d] Error connecting to the API (%s)',
  1806. $statusCode,
  1807. (string) $request->getUri()
  1808. ),
  1809. $statusCode,
  1810. $response->getHeaders(),
  1811. (string) $response->getBody()
  1812. );
  1813. }
  1814. return $this->handleResponseWithDataType(
  1815. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  1816. $request,
  1817. $response,
  1818. );
  1819. } catch (ApiException $e) {
  1820. switch ($e->getCode()) {
  1821. case 200:
  1822. $data = ObjectSerializer::deserialize(
  1823. $e->getResponseBody(),
  1824. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  1825. $e->getResponseHeaders()
  1826. );
  1827. $e->setResponseObject($data);
  1828. throw $e;
  1829. case 401:
  1830. $data = ObjectSerializer::deserialize(
  1831. $e->getResponseBody(),
  1832. '\WikipaliApi\Model\ProblemDetails',
  1833. $e->getResponseHeaders()
  1834. );
  1835. $e->setResponseObject($data);
  1836. throw $e;
  1837. case 422:
  1838. $data = ObjectSerializer::deserialize(
  1839. $e->getResponseBody(),
  1840. '\WikipaliApi\Model\ProblemDetails',
  1841. $e->getResponseHeaders()
  1842. );
  1843. $e->setResponseObject($data);
  1844. throw $e;
  1845. }
  1846. throw $e;
  1847. }
  1848. }
  1849. /**
  1850. * Operation getApiV3AdminReadingStatsAsync
  1851. *
  1852. * 阅读统计
  1853. *
  1854. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1855. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1856. * @param string|null $client 客户端 (optional, default to 'all')
  1857. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  1858. *
  1859. * @throws \InvalidArgumentException
  1860. * @return \GuzzleHttp\Promise\PromiseInterface
  1861. */
  1862. public function getApiV3AdminReadingStatsAsync($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  1863. {
  1864. return $this->getApiV3AdminReadingStatsAsyncWithHttpInfo($from, $to, $client, $contentType)
  1865. ->then(
  1866. function ($response) {
  1867. return $response[0];
  1868. }
  1869. );
  1870. }
  1871. /**
  1872. * Operation getApiV3AdminReadingStatsAsyncWithHttpInfo
  1873. *
  1874. * 阅读统计
  1875. *
  1876. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1877. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1878. * @param string|null $client 客户端 (optional, default to 'all')
  1879. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  1880. *
  1881. * @throws \InvalidArgumentException
  1882. * @return \GuzzleHttp\Promise\PromiseInterface
  1883. */
  1884. public function getApiV3AdminReadingStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  1885. {
  1886. $returnType = '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response';
  1887. $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
  1888. return $this->client
  1889. ->sendAsync($request, $this->createHttpClientOption())
  1890. ->then(
  1891. function ($response) use ($returnType) {
  1892. if ($returnType === '\SplFileObject') {
  1893. $content = $response->getBody(); //stream goes to serializer
  1894. } else {
  1895. $content = (string) $response->getBody();
  1896. if ($returnType !== 'string') {
  1897. $content = json_decode($content);
  1898. }
  1899. }
  1900. return [
  1901. ObjectSerializer::deserialize($content, $returnType, []),
  1902. $response->getStatusCode(),
  1903. $response->getHeaders()
  1904. ];
  1905. },
  1906. function ($exception) {
  1907. $response = $exception->getResponse();
  1908. $statusCode = $response->getStatusCode();
  1909. throw new ApiException(
  1910. sprintf(
  1911. '[%d] Error connecting to the API (%s)',
  1912. $statusCode,
  1913. $exception->getRequest()->getUri()
  1914. ),
  1915. $statusCode,
  1916. $response->getHeaders(),
  1917. (string) $response->getBody()
  1918. );
  1919. }
  1920. );
  1921. }
  1922. /**
  1923. * Create request for operation 'getApiV3AdminReadingStats'
  1924. *
  1925. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1926. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1927. * @param string|null $client 客户端 (optional, default to 'all')
  1928. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  1929. *
  1930. * @throws \InvalidArgumentException
  1931. * @return \GuzzleHttp\Psr7\Request
  1932. */
  1933. public function getApiV3AdminReadingStatsRequest($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  1934. {
  1935. $resourcePath = '/v3/admin/reading-stats';
  1936. $formParams = [];
  1937. $queryParams = [];
  1938. $headerParams = [];
  1939. $httpBody = '';
  1940. $multipart = false;
  1941. // query params
  1942. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1943. $from,
  1944. 'from', // param base name
  1945. 'string', // openApiType
  1946. 'form', // style
  1947. true, // explode
  1948. false // required
  1949. ) ?? []);
  1950. // query params
  1951. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1952. $to,
  1953. 'to', // param base name
  1954. 'string', // openApiType
  1955. 'form', // style
  1956. true, // explode
  1957. false // required
  1958. ) ?? []);
  1959. // query params
  1960. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1961. $client,
  1962. 'client', // param base name
  1963. 'string', // openApiType
  1964. 'form', // style
  1965. true, // explode
  1966. false // required
  1967. ) ?? []);
  1968. $headers = $this->headerSelector->selectHeaders(
  1969. ['application/json', 'application/problem+json', ],
  1970. $contentType,
  1971. $multipart
  1972. );
  1973. // for model (json/xml)
  1974. if (count($formParams) > 0) {
  1975. if ($multipart) {
  1976. $multipartContents = [];
  1977. foreach ($formParams as $formParamName => $formParamValue) {
  1978. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1979. foreach ($formParamValueItems as $formParamValueItem) {
  1980. $multipartContents[] = [
  1981. 'name' => $formParamName,
  1982. 'contents' => $formParamValueItem
  1983. ];
  1984. }
  1985. }
  1986. // for HTTP post (form)
  1987. $httpBody = new MultipartStream($multipartContents);
  1988. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1989. # if Content-Type contains "application/json", json_encode the form parameters
  1990. try {
  1991. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1992. } catch (\JsonException $e) {
  1993. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1994. }
  1995. } else {
  1996. // for HTTP post (form)
  1997. $httpBody = ObjectSerializer::buildQuery($formParams);
  1998. }
  1999. }
  2000. // this endpoint requires Bearer authentication (access token)
  2001. if (!empty($this->config->getAccessToken())) {
  2002. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  2003. }
  2004. $defaultHeaders = [];
  2005. if ($this->config->getUserAgent()) {
  2006. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  2007. }
  2008. $headers = array_merge(
  2009. $defaultHeaders,
  2010. $headerParams,
  2011. $headers
  2012. );
  2013. $operationHost = $this->config->getHost();
  2014. $query = ObjectSerializer::buildQuery($queryParams);
  2015. return new Request(
  2016. 'GET',
  2017. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  2018. $headers,
  2019. $httpBody
  2020. );
  2021. }
  2022. /**
  2023. * Create http client option
  2024. *
  2025. * @throws \RuntimeException on file opening failure
  2026. * @return array of http client options
  2027. */
  2028. protected function createHttpClientOption()
  2029. {
  2030. $options = [];
  2031. if ($this->config->getDebug()) {
  2032. $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
  2033. if (!$options[RequestOptions::DEBUG]) {
  2034. throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
  2035. }
  2036. }
  2037. if ($this->config->getCertFile()) {
  2038. $options[RequestOptions::CERT] = $this->config->getCertFile();
  2039. }
  2040. if ($this->config->getKeyFile()) {
  2041. $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
  2042. }
  2043. return $options;
  2044. }
  2045. private function handleResponseWithDataType(
  2046. string $dataType,
  2047. RequestInterface $request,
  2048. ResponseInterface $response
  2049. ): array {
  2050. if ($dataType === '\SplFileObject') {
  2051. $content = $response->getBody(); //stream goes to serializer
  2052. } else {
  2053. $content = (string) $response->getBody();
  2054. if ($dataType !== 'string') {
  2055. try {
  2056. $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
  2057. } catch (\JsonException $exception) {
  2058. throw new ApiException(
  2059. sprintf(
  2060. 'Error JSON decoding server response (%s)',
  2061. $request->getUri()
  2062. ),
  2063. $response->getStatusCode(),
  2064. $response->getHeaders(),
  2065. $content
  2066. );
  2067. }
  2068. }
  2069. }
  2070. return [
  2071. ObjectSerializer::deserialize($content, $dataType, []),
  2072. $response->getStatusCode(),
  2073. $response->getHeaders()
  2074. ];
  2075. }
  2076. private function responseWithinRangeCode(
  2077. string $rangeCode,
  2078. int $statusCode
  2079. ): bool {
  2080. $left = (int) ($rangeCode[0].'00');
  2081. $right = (int) ($rangeCode[0].'99');
  2082. return $statusCode >= $left && $statusCode <= $right;
  2083. }
  2084. }