SearchApi.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. <?php
  2. /**
  3. * SearchApi
  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.10.15
  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. * SearchApi Class Doc Comment
  42. *
  43. * @category Class
  44. * @package WikipaliApi
  45. * @author OpenAPI Generator team
  46. * @link https://openapi-generator.tech
  47. */
  48. class SearchApi
  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. 'getApiV3Search' => [
  69. 'application/json',
  70. ],
  71. 'getApiV3SearchSearch' => [
  72. 'application/json',
  73. ],
  74. 'postApiV3Search' => [
  75. 'application/json',
  76. ],
  77. ];
  78. /**
  79. * @param ClientInterface $client
  80. * @param Configuration $config
  81. * @param HeaderSelector $selector
  82. * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
  83. */
  84. public function __construct(
  85. ?ClientInterface $client = null,
  86. ?Configuration $config = null,
  87. ?HeaderSelector $selector = null,
  88. int $hostIndex = 0
  89. ) {
  90. $this->client = $client ?: new Client();
  91. $this->config = $config ?: Configuration::getDefaultConfiguration();
  92. $this->headerSelector = $selector ?: new HeaderSelector();
  93. $this->hostIndex = $hostIndex;
  94. }
  95. /**
  96. * Set the host index
  97. *
  98. * @param int $hostIndex Host index (required)
  99. */
  100. public function setHostIndex($hostIndex): void
  101. {
  102. $this->hostIndex = $hostIndex;
  103. }
  104. /**
  105. * Get the host index
  106. *
  107. * @return int Host index
  108. */
  109. public function getHostIndex()
  110. {
  111. return $this->hostIndex;
  112. }
  113. /**
  114. * @return Configuration
  115. */
  116. public function getConfig()
  117. {
  118. return $this->config;
  119. }
  120. /**
  121. * Operation getApiV3Search
  122. *
  123. * 全文检索
  124. *
  125. * @param string $q 搜索关键词 (required)
  126. * @param int|null $page 页码 (optional, default to 1)
  127. * @param int|null $page_size 每页数量,上限 100 (optional, default to 20)
  128. * @param string|null $search_mode 检索模式 (optional, default to 'fuzzy')
  129. * @param string|null $resource_type 资源类型 (optional)
  130. * @param string|null $resource_id 限定某个资源 id (optional)
  131. * @param string|null $granularity 文档颗粒度 (optional)
  132. * @param string|null $language 语言 (optional)
  133. * @param string|null $category 文档分类,逗号分隔 (optional)
  134. * @param string|null $tags 标签过滤,逗号分隔 (optional)
  135. * @param string[]|null $page_refs 页码标记 (optional)
  136. * @param string[]|null $related_id 关联 id (optional)
  137. * @param string|null $author 按作者或译者过滤 (optional)
  138. * @param string|null $channel 按来源 channel 过滤 (optional)
  139. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Search'] to see the possible values for this operation
  140. *
  141. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  142. * @throws \InvalidArgumentException
  143. * @return \WikipaliApi\Model\GetApiV3Search200Response|\WikipaliApi\Model\ProblemDetails
  144. */
  145. public function getApiV3Search($q, $page = 1, $page_size = 20, $search_mode = 'fuzzy', $resource_type = null, $resource_id = null, $granularity = null, $language = null, $category = null, $tags = null, $page_refs = null, $related_id = null, $author = null, $channel = null, string $contentType = self::contentTypes['getApiV3Search'][0])
  146. {
  147. list($response) = $this->getApiV3SearchWithHttpInfo($q, $page, $page_size, $search_mode, $resource_type, $resource_id, $granularity, $language, $category, $tags, $page_refs, $related_id, $author, $channel, $contentType);
  148. return $response;
  149. }
  150. /**
  151. * Operation getApiV3SearchWithHttpInfo
  152. *
  153. * 全文检索
  154. *
  155. * @param string $q 搜索关键词 (required)
  156. * @param int|null $page 页码 (optional, default to 1)
  157. * @param int|null $page_size 每页数量,上限 100 (optional, default to 20)
  158. * @param string|null $search_mode 检索模式 (optional, default to 'fuzzy')
  159. * @param string|null $resource_type 资源类型 (optional)
  160. * @param string|null $resource_id 限定某个资源 id (optional)
  161. * @param string|null $granularity 文档颗粒度 (optional)
  162. * @param string|null $language 语言 (optional)
  163. * @param string|null $category 文档分类,逗号分隔 (optional)
  164. * @param string|null $tags 标签过滤,逗号分隔 (optional)
  165. * @param string[]|null $page_refs 页码标记 (optional)
  166. * @param string[]|null $related_id 关联 id (optional)
  167. * @param string|null $author 按作者或译者过滤 (optional)
  168. * @param string|null $channel 按来源 channel 过滤 (optional)
  169. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Search'] to see the possible values for this operation
  170. *
  171. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  172. * @throws \InvalidArgumentException
  173. * @return array of \WikipaliApi\Model\GetApiV3Search200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  174. */
  175. public function getApiV3SearchWithHttpInfo($q, $page = 1, $page_size = 20, $search_mode = 'fuzzy', $resource_type = null, $resource_id = null, $granularity = null, $language = null, $category = null, $tags = null, $page_refs = null, $related_id = null, $author = null, $channel = null, string $contentType = self::contentTypes['getApiV3Search'][0])
  176. {
  177. $request = $this->getApiV3SearchRequest($q, $page, $page_size, $search_mode, $resource_type, $resource_id, $granularity, $language, $category, $tags, $page_refs, $related_id, $author, $channel, $contentType);
  178. try {
  179. $options = $this->createHttpClientOption();
  180. try {
  181. $response = $this->client->send($request, $options);
  182. } catch (RequestException $e) {
  183. throw new ApiException(
  184. "[{$e->getCode()}] {$e->getMessage()}",
  185. (int) $e->getCode(),
  186. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  187. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  188. );
  189. } catch (ConnectException $e) {
  190. throw new ApiException(
  191. "[{$e->getCode()}] {$e->getMessage()}",
  192. (int) $e->getCode(),
  193. null,
  194. null
  195. );
  196. }
  197. $statusCode = $response->getStatusCode();
  198. switch($statusCode) {
  199. case 200:
  200. return $this->handleResponseWithDataType(
  201. '\WikipaliApi\Model\GetApiV3Search200Response',
  202. $request,
  203. $response,
  204. );
  205. case 422:
  206. return $this->handleResponseWithDataType(
  207. '\WikipaliApi\Model\ProblemDetails',
  208. $request,
  209. $response,
  210. );
  211. }
  212. if ($statusCode < 200 || $statusCode > 299) {
  213. throw new ApiException(
  214. sprintf(
  215. '[%d] Error connecting to the API (%s)',
  216. $statusCode,
  217. (string) $request->getUri()
  218. ),
  219. $statusCode,
  220. $response->getHeaders(),
  221. (string) $response->getBody()
  222. );
  223. }
  224. return $this->handleResponseWithDataType(
  225. '\WikipaliApi\Model\GetApiV3Search200Response',
  226. $request,
  227. $response,
  228. );
  229. } catch (ApiException $e) {
  230. switch ($e->getCode()) {
  231. case 200:
  232. $data = ObjectSerializer::deserialize(
  233. $e->getResponseBody(),
  234. '\WikipaliApi\Model\GetApiV3Search200Response',
  235. $e->getResponseHeaders()
  236. );
  237. $e->setResponseObject($data);
  238. throw $e;
  239. case 422:
  240. $data = ObjectSerializer::deserialize(
  241. $e->getResponseBody(),
  242. '\WikipaliApi\Model\ProblemDetails',
  243. $e->getResponseHeaders()
  244. );
  245. $e->setResponseObject($data);
  246. throw $e;
  247. }
  248. throw $e;
  249. }
  250. }
  251. /**
  252. * Operation getApiV3SearchAsync
  253. *
  254. * 全文检索
  255. *
  256. * @param string $q 搜索关键词 (required)
  257. * @param int|null $page 页码 (optional, default to 1)
  258. * @param int|null $page_size 每页数量,上限 100 (optional, default to 20)
  259. * @param string|null $search_mode 检索模式 (optional, default to 'fuzzy')
  260. * @param string|null $resource_type 资源类型 (optional)
  261. * @param string|null $resource_id 限定某个资源 id (optional)
  262. * @param string|null $granularity 文档颗粒度 (optional)
  263. * @param string|null $language 语言 (optional)
  264. * @param string|null $category 文档分类,逗号分隔 (optional)
  265. * @param string|null $tags 标签过滤,逗号分隔 (optional)
  266. * @param string[]|null $page_refs 页码标记 (optional)
  267. * @param string[]|null $related_id 关联 id (optional)
  268. * @param string|null $author 按作者或译者过滤 (optional)
  269. * @param string|null $channel 按来源 channel 过滤 (optional)
  270. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Search'] to see the possible values for this operation
  271. *
  272. * @throws \InvalidArgumentException
  273. * @return \GuzzleHttp\Promise\PromiseInterface
  274. */
  275. public function getApiV3SearchAsync($q, $page = 1, $page_size = 20, $search_mode = 'fuzzy', $resource_type = null, $resource_id = null, $granularity = null, $language = null, $category = null, $tags = null, $page_refs = null, $related_id = null, $author = null, $channel = null, string $contentType = self::contentTypes['getApiV3Search'][0])
  276. {
  277. return $this->getApiV3SearchAsyncWithHttpInfo($q, $page, $page_size, $search_mode, $resource_type, $resource_id, $granularity, $language, $category, $tags, $page_refs, $related_id, $author, $channel, $contentType)
  278. ->then(
  279. function ($response) {
  280. return $response[0];
  281. }
  282. );
  283. }
  284. /**
  285. * Operation getApiV3SearchAsyncWithHttpInfo
  286. *
  287. * 全文检索
  288. *
  289. * @param string $q 搜索关键词 (required)
  290. * @param int|null $page 页码 (optional, default to 1)
  291. * @param int|null $page_size 每页数量,上限 100 (optional, default to 20)
  292. * @param string|null $search_mode 检索模式 (optional, default to 'fuzzy')
  293. * @param string|null $resource_type 资源类型 (optional)
  294. * @param string|null $resource_id 限定某个资源 id (optional)
  295. * @param string|null $granularity 文档颗粒度 (optional)
  296. * @param string|null $language 语言 (optional)
  297. * @param string|null $category 文档分类,逗号分隔 (optional)
  298. * @param string|null $tags 标签过滤,逗号分隔 (optional)
  299. * @param string[]|null $page_refs 页码标记 (optional)
  300. * @param string[]|null $related_id 关联 id (optional)
  301. * @param string|null $author 按作者或译者过滤 (optional)
  302. * @param string|null $channel 按来源 channel 过滤 (optional)
  303. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Search'] to see the possible values for this operation
  304. *
  305. * @throws \InvalidArgumentException
  306. * @return \GuzzleHttp\Promise\PromiseInterface
  307. */
  308. public function getApiV3SearchAsyncWithHttpInfo($q, $page = 1, $page_size = 20, $search_mode = 'fuzzy', $resource_type = null, $resource_id = null, $granularity = null, $language = null, $category = null, $tags = null, $page_refs = null, $related_id = null, $author = null, $channel = null, string $contentType = self::contentTypes['getApiV3Search'][0])
  309. {
  310. $returnType = '\WikipaliApi\Model\GetApiV3Search200Response';
  311. $request = $this->getApiV3SearchRequest($q, $page, $page_size, $search_mode, $resource_type, $resource_id, $granularity, $language, $category, $tags, $page_refs, $related_id, $author, $channel, $contentType);
  312. return $this->client
  313. ->sendAsync($request, $this->createHttpClientOption())
  314. ->then(
  315. function ($response) use ($returnType) {
  316. if ($returnType === '\SplFileObject') {
  317. $content = $response->getBody(); //stream goes to serializer
  318. } else {
  319. $content = (string) $response->getBody();
  320. if ($returnType !== 'string') {
  321. $content = json_decode($content);
  322. }
  323. }
  324. return [
  325. ObjectSerializer::deserialize($content, $returnType, []),
  326. $response->getStatusCode(),
  327. $response->getHeaders()
  328. ];
  329. },
  330. function ($exception) {
  331. $response = $exception->getResponse();
  332. $statusCode = $response->getStatusCode();
  333. throw new ApiException(
  334. sprintf(
  335. '[%d] Error connecting to the API (%s)',
  336. $statusCode,
  337. $exception->getRequest()->getUri()
  338. ),
  339. $statusCode,
  340. $response->getHeaders(),
  341. (string) $response->getBody()
  342. );
  343. }
  344. );
  345. }
  346. /**
  347. * Create request for operation 'getApiV3Search'
  348. *
  349. * @param string $q 搜索关键词 (required)
  350. * @param int|null $page 页码 (optional, default to 1)
  351. * @param int|null $page_size 每页数量,上限 100 (optional, default to 20)
  352. * @param string|null $search_mode 检索模式 (optional, default to 'fuzzy')
  353. * @param string|null $resource_type 资源类型 (optional)
  354. * @param string|null $resource_id 限定某个资源 id (optional)
  355. * @param string|null $granularity 文档颗粒度 (optional)
  356. * @param string|null $language 语言 (optional)
  357. * @param string|null $category 文档分类,逗号分隔 (optional)
  358. * @param string|null $tags 标签过滤,逗号分隔 (optional)
  359. * @param string[]|null $page_refs 页码标记 (optional)
  360. * @param string[]|null $related_id 关联 id (optional)
  361. * @param string|null $author 按作者或译者过滤 (optional)
  362. * @param string|null $channel 按来源 channel 过滤 (optional)
  363. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3Search'] to see the possible values for this operation
  364. *
  365. * @throws \InvalidArgumentException
  366. * @return \GuzzleHttp\Psr7\Request
  367. */
  368. public function getApiV3SearchRequest($q, $page = 1, $page_size = 20, $search_mode = 'fuzzy', $resource_type = null, $resource_id = null, $granularity = null, $language = null, $category = null, $tags = null, $page_refs = null, $related_id = null, $author = null, $channel = null, string $contentType = self::contentTypes['getApiV3Search'][0])
  369. {
  370. // verify the required parameter 'q' is set
  371. if ($q === null || (is_array($q) && count($q) === 0)) {
  372. throw new \InvalidArgumentException(
  373. 'Missing the required parameter $q when calling getApiV3Search'
  374. );
  375. }
  376. $resourcePath = '/v3/search';
  377. $formParams = [];
  378. $queryParams = [];
  379. $headerParams = [];
  380. $httpBody = '';
  381. $multipart = false;
  382. // query params
  383. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  384. $q,
  385. 'q', // param base name
  386. 'string', // openApiType
  387. 'form', // style
  388. true, // explode
  389. true // required
  390. ) ?? []);
  391. // query params
  392. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  393. $page,
  394. 'page', // param base name
  395. 'integer', // openApiType
  396. 'form', // style
  397. true, // explode
  398. false // required
  399. ) ?? []);
  400. // query params
  401. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  402. $page_size,
  403. 'page_size', // param base name
  404. 'integer', // openApiType
  405. 'form', // style
  406. true, // explode
  407. false // required
  408. ) ?? []);
  409. // query params
  410. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  411. $search_mode,
  412. 'search_mode', // 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. $resource_type,
  421. 'resource_type', // param base name
  422. 'string', // openApiType
  423. 'form', // style
  424. true, // explode
  425. false // required
  426. ) ?? []);
  427. // query params
  428. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  429. $resource_id,
  430. 'resource_id', // param base name
  431. 'string', // openApiType
  432. 'form', // style
  433. true, // explode
  434. false // required
  435. ) ?? []);
  436. // query params
  437. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  438. $granularity,
  439. 'granularity', // param base name
  440. 'string', // openApiType
  441. 'form', // style
  442. true, // explode
  443. false // required
  444. ) ?? []);
  445. // query params
  446. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  447. $language,
  448. 'language', // param base name
  449. 'string', // openApiType
  450. 'form', // style
  451. true, // explode
  452. false // required
  453. ) ?? []);
  454. // query params
  455. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  456. $category,
  457. 'category', // param base name
  458. 'string', // openApiType
  459. 'form', // style
  460. true, // explode
  461. false // required
  462. ) ?? []);
  463. // query params
  464. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  465. $tags,
  466. 'tags', // param base name
  467. 'string', // openApiType
  468. 'form', // style
  469. true, // explode
  470. false // required
  471. ) ?? []);
  472. // query params
  473. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  474. $page_refs,
  475. 'page_refs', // param base name
  476. 'array', // openApiType
  477. 'form', // style
  478. true, // explode
  479. false // required
  480. ) ?? []);
  481. // query params
  482. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  483. $related_id,
  484. 'related_id', // param base name
  485. 'array', // openApiType
  486. 'form', // style
  487. true, // explode
  488. false // required
  489. ) ?? []);
  490. // query params
  491. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  492. $author,
  493. 'author', // param base name
  494. 'string', // openApiType
  495. 'form', // style
  496. true, // explode
  497. false // required
  498. ) ?? []);
  499. // query params
  500. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  501. $channel,
  502. 'channel', // param base name
  503. 'string', // openApiType
  504. 'form', // style
  505. true, // explode
  506. false // required
  507. ) ?? []);
  508. $headers = $this->headerSelector->selectHeaders(
  509. ['application/json', 'application/problem+json', ],
  510. $contentType,
  511. $multipart
  512. );
  513. // for model (json/xml)
  514. if (count($formParams) > 0) {
  515. if ($multipart) {
  516. $multipartContents = [];
  517. foreach ($formParams as $formParamName => $formParamValue) {
  518. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  519. foreach ($formParamValueItems as $formParamValueItem) {
  520. $multipartContents[] = [
  521. 'name' => $formParamName,
  522. 'contents' => $formParamValueItem
  523. ];
  524. }
  525. }
  526. // for HTTP post (form)
  527. $httpBody = new MultipartStream($multipartContents);
  528. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  529. # if Content-Type contains "application/json", json_encode the form parameters
  530. try {
  531. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  532. } catch (\JsonException $e) {
  533. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  534. }
  535. } else {
  536. // for HTTP post (form)
  537. $httpBody = ObjectSerializer::buildQuery($formParams);
  538. }
  539. }
  540. // this endpoint requires Bearer authentication (access token)
  541. if (!empty($this->config->getAccessToken())) {
  542. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  543. }
  544. $defaultHeaders = [];
  545. if ($this->config->getUserAgent()) {
  546. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  547. }
  548. $headers = array_merge(
  549. $defaultHeaders,
  550. $headerParams,
  551. $headers
  552. );
  553. $operationHost = $this->config->getHost();
  554. $query = ObjectSerializer::buildQuery($queryParams);
  555. return new Request(
  556. 'GET',
  557. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  558. $headers,
  559. $httpBody
  560. );
  561. }
  562. /**
  563. * Operation getApiV3SearchSearch
  564. *
  565. * 按 id 取单条检索结果
  566. *
  567. * @param string $search OpenSearch 文档 id (required)
  568. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3SearchSearch'] to see the possible values for this operation
  569. *
  570. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  571. * @throws \InvalidArgumentException
  572. * @return \WikipaliApi\Model\GetApiV3SearchSearch200Response|\WikipaliApi\Model\ProblemDetails
  573. */
  574. public function getApiV3SearchSearch($search, string $contentType = self::contentTypes['getApiV3SearchSearch'][0])
  575. {
  576. list($response) = $this->getApiV3SearchSearchWithHttpInfo($search, $contentType);
  577. return $response;
  578. }
  579. /**
  580. * Operation getApiV3SearchSearchWithHttpInfo
  581. *
  582. * 按 id 取单条检索结果
  583. *
  584. * @param string $search OpenSearch 文档 id (required)
  585. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3SearchSearch'] to see the possible values for this operation
  586. *
  587. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  588. * @throws \InvalidArgumentException
  589. * @return array of \WikipaliApi\Model\GetApiV3SearchSearch200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  590. */
  591. public function getApiV3SearchSearchWithHttpInfo($search, string $contentType = self::contentTypes['getApiV3SearchSearch'][0])
  592. {
  593. $request = $this->getApiV3SearchSearchRequest($search, $contentType);
  594. try {
  595. $options = $this->createHttpClientOption();
  596. try {
  597. $response = $this->client->send($request, $options);
  598. } catch (RequestException $e) {
  599. throw new ApiException(
  600. "[{$e->getCode()}] {$e->getMessage()}",
  601. (int) $e->getCode(),
  602. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  603. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  604. );
  605. } catch (ConnectException $e) {
  606. throw new ApiException(
  607. "[{$e->getCode()}] {$e->getMessage()}",
  608. (int) $e->getCode(),
  609. null,
  610. null
  611. );
  612. }
  613. $statusCode = $response->getStatusCode();
  614. switch($statusCode) {
  615. case 200:
  616. return $this->handleResponseWithDataType(
  617. '\WikipaliApi\Model\GetApiV3SearchSearch200Response',
  618. $request,
  619. $response,
  620. );
  621. case 422:
  622. return $this->handleResponseWithDataType(
  623. '\WikipaliApi\Model\ProblemDetails',
  624. $request,
  625. $response,
  626. );
  627. }
  628. if ($statusCode < 200 || $statusCode > 299) {
  629. throw new ApiException(
  630. sprintf(
  631. '[%d] Error connecting to the API (%s)',
  632. $statusCode,
  633. (string) $request->getUri()
  634. ),
  635. $statusCode,
  636. $response->getHeaders(),
  637. (string) $response->getBody()
  638. );
  639. }
  640. return $this->handleResponseWithDataType(
  641. '\WikipaliApi\Model\GetApiV3SearchSearch200Response',
  642. $request,
  643. $response,
  644. );
  645. } catch (ApiException $e) {
  646. switch ($e->getCode()) {
  647. case 200:
  648. $data = ObjectSerializer::deserialize(
  649. $e->getResponseBody(),
  650. '\WikipaliApi\Model\GetApiV3SearchSearch200Response',
  651. $e->getResponseHeaders()
  652. );
  653. $e->setResponseObject($data);
  654. throw $e;
  655. case 422:
  656. $data = ObjectSerializer::deserialize(
  657. $e->getResponseBody(),
  658. '\WikipaliApi\Model\ProblemDetails',
  659. $e->getResponseHeaders()
  660. );
  661. $e->setResponseObject($data);
  662. throw $e;
  663. }
  664. throw $e;
  665. }
  666. }
  667. /**
  668. * Operation getApiV3SearchSearchAsync
  669. *
  670. * 按 id 取单条检索结果
  671. *
  672. * @param string $search OpenSearch 文档 id (required)
  673. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3SearchSearch'] to see the possible values for this operation
  674. *
  675. * @throws \InvalidArgumentException
  676. * @return \GuzzleHttp\Promise\PromiseInterface
  677. */
  678. public function getApiV3SearchSearchAsync($search, string $contentType = self::contentTypes['getApiV3SearchSearch'][0])
  679. {
  680. return $this->getApiV3SearchSearchAsyncWithHttpInfo($search, $contentType)
  681. ->then(
  682. function ($response) {
  683. return $response[0];
  684. }
  685. );
  686. }
  687. /**
  688. * Operation getApiV3SearchSearchAsyncWithHttpInfo
  689. *
  690. * 按 id 取单条检索结果
  691. *
  692. * @param string $search OpenSearch 文档 id (required)
  693. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3SearchSearch'] to see the possible values for this operation
  694. *
  695. * @throws \InvalidArgumentException
  696. * @return \GuzzleHttp\Promise\PromiseInterface
  697. */
  698. public function getApiV3SearchSearchAsyncWithHttpInfo($search, string $contentType = self::contentTypes['getApiV3SearchSearch'][0])
  699. {
  700. $returnType = '\WikipaliApi\Model\GetApiV3SearchSearch200Response';
  701. $request = $this->getApiV3SearchSearchRequest($search, $contentType);
  702. return $this->client
  703. ->sendAsync($request, $this->createHttpClientOption())
  704. ->then(
  705. function ($response) use ($returnType) {
  706. if ($returnType === '\SplFileObject') {
  707. $content = $response->getBody(); //stream goes to serializer
  708. } else {
  709. $content = (string) $response->getBody();
  710. if ($returnType !== 'string') {
  711. $content = json_decode($content);
  712. }
  713. }
  714. return [
  715. ObjectSerializer::deserialize($content, $returnType, []),
  716. $response->getStatusCode(),
  717. $response->getHeaders()
  718. ];
  719. },
  720. function ($exception) {
  721. $response = $exception->getResponse();
  722. $statusCode = $response->getStatusCode();
  723. throw new ApiException(
  724. sprintf(
  725. '[%d] Error connecting to the API (%s)',
  726. $statusCode,
  727. $exception->getRequest()->getUri()
  728. ),
  729. $statusCode,
  730. $response->getHeaders(),
  731. (string) $response->getBody()
  732. );
  733. }
  734. );
  735. }
  736. /**
  737. * Create request for operation 'getApiV3SearchSearch'
  738. *
  739. * @param string $search OpenSearch 文档 id (required)
  740. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3SearchSearch'] to see the possible values for this operation
  741. *
  742. * @throws \InvalidArgumentException
  743. * @return \GuzzleHttp\Psr7\Request
  744. */
  745. public function getApiV3SearchSearchRequest($search, string $contentType = self::contentTypes['getApiV3SearchSearch'][0])
  746. {
  747. // verify the required parameter 'search' is set
  748. if ($search === null || (is_array($search) && count($search) === 0)) {
  749. throw new \InvalidArgumentException(
  750. 'Missing the required parameter $search when calling getApiV3SearchSearch'
  751. );
  752. }
  753. $resourcePath = '/v3/search/{search}';
  754. $formParams = [];
  755. $queryParams = [];
  756. $headerParams = [];
  757. $httpBody = '';
  758. $multipart = false;
  759. // path params
  760. if ($search !== null) {
  761. $resourcePath = str_replace(
  762. '{search}',
  763. ObjectSerializer::toPathValue($search),
  764. $resourcePath
  765. );
  766. }
  767. $headers = $this->headerSelector->selectHeaders(
  768. ['application/json', 'application/problem+json', ],
  769. $contentType,
  770. $multipart
  771. );
  772. // for model (json/xml)
  773. if (count($formParams) > 0) {
  774. if ($multipart) {
  775. $multipartContents = [];
  776. foreach ($formParams as $formParamName => $formParamValue) {
  777. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  778. foreach ($formParamValueItems as $formParamValueItem) {
  779. $multipartContents[] = [
  780. 'name' => $formParamName,
  781. 'contents' => $formParamValueItem
  782. ];
  783. }
  784. }
  785. // for HTTP post (form)
  786. $httpBody = new MultipartStream($multipartContents);
  787. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  788. # if Content-Type contains "application/json", json_encode the form parameters
  789. try {
  790. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  791. } catch (\JsonException $e) {
  792. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  793. }
  794. } else {
  795. // for HTTP post (form)
  796. $httpBody = ObjectSerializer::buildQuery($formParams);
  797. }
  798. }
  799. // this endpoint requires Bearer authentication (access token)
  800. if (!empty($this->config->getAccessToken())) {
  801. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  802. }
  803. $defaultHeaders = [];
  804. if ($this->config->getUserAgent()) {
  805. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  806. }
  807. $headers = array_merge(
  808. $defaultHeaders,
  809. $headerParams,
  810. $headers
  811. );
  812. $operationHost = $this->config->getHost();
  813. $query = ObjectSerializer::buildQuery($queryParams);
  814. return new Request(
  815. 'GET',
  816. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  817. $headers,
  818. $httpBody
  819. );
  820. }
  821. /**
  822. * Operation postApiV3Search
  823. *
  824. * 全文检索(POST)
  825. *
  826. * @param \WikipaliApi\Model\PostApiV3SearchRequest $post_api_v3_search_request post_api_v3_search_request (required)
  827. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3Search'] to see the possible values for this operation
  828. *
  829. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  830. * @throws \InvalidArgumentException
  831. * @return \WikipaliApi\Model\GetApiV3Search200Response|\WikipaliApi\Model\ProblemDetails
  832. */
  833. public function postApiV3Search($post_api_v3_search_request, string $contentType = self::contentTypes['postApiV3Search'][0])
  834. {
  835. list($response) = $this->postApiV3SearchWithHttpInfo($post_api_v3_search_request, $contentType);
  836. return $response;
  837. }
  838. /**
  839. * Operation postApiV3SearchWithHttpInfo
  840. *
  841. * 全文检索(POST)
  842. *
  843. * @param \WikipaliApi\Model\PostApiV3SearchRequest $post_api_v3_search_request (required)
  844. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3Search'] to see the possible values for this operation
  845. *
  846. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  847. * @throws \InvalidArgumentException
  848. * @return array of \WikipaliApi\Model\GetApiV3Search200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  849. */
  850. public function postApiV3SearchWithHttpInfo($post_api_v3_search_request, string $contentType = self::contentTypes['postApiV3Search'][0])
  851. {
  852. $request = $this->postApiV3SearchRequest($post_api_v3_search_request, $contentType);
  853. try {
  854. $options = $this->createHttpClientOption();
  855. try {
  856. $response = $this->client->send($request, $options);
  857. } catch (RequestException $e) {
  858. throw new ApiException(
  859. "[{$e->getCode()}] {$e->getMessage()}",
  860. (int) $e->getCode(),
  861. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  862. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  863. );
  864. } catch (ConnectException $e) {
  865. throw new ApiException(
  866. "[{$e->getCode()}] {$e->getMessage()}",
  867. (int) $e->getCode(),
  868. null,
  869. null
  870. );
  871. }
  872. $statusCode = $response->getStatusCode();
  873. switch($statusCode) {
  874. case 200:
  875. return $this->handleResponseWithDataType(
  876. '\WikipaliApi\Model\GetApiV3Search200Response',
  877. $request,
  878. $response,
  879. );
  880. case 422:
  881. return $this->handleResponseWithDataType(
  882. '\WikipaliApi\Model\ProblemDetails',
  883. $request,
  884. $response,
  885. );
  886. }
  887. if ($statusCode < 200 || $statusCode > 299) {
  888. throw new ApiException(
  889. sprintf(
  890. '[%d] Error connecting to the API (%s)',
  891. $statusCode,
  892. (string) $request->getUri()
  893. ),
  894. $statusCode,
  895. $response->getHeaders(),
  896. (string) $response->getBody()
  897. );
  898. }
  899. return $this->handleResponseWithDataType(
  900. '\WikipaliApi\Model\GetApiV3Search200Response',
  901. $request,
  902. $response,
  903. );
  904. } catch (ApiException $e) {
  905. switch ($e->getCode()) {
  906. case 200:
  907. $data = ObjectSerializer::deserialize(
  908. $e->getResponseBody(),
  909. '\WikipaliApi\Model\GetApiV3Search200Response',
  910. $e->getResponseHeaders()
  911. );
  912. $e->setResponseObject($data);
  913. throw $e;
  914. case 422:
  915. $data = ObjectSerializer::deserialize(
  916. $e->getResponseBody(),
  917. '\WikipaliApi\Model\ProblemDetails',
  918. $e->getResponseHeaders()
  919. );
  920. $e->setResponseObject($data);
  921. throw $e;
  922. }
  923. throw $e;
  924. }
  925. }
  926. /**
  927. * Operation postApiV3SearchAsync
  928. *
  929. * 全文检索(POST)
  930. *
  931. * @param \WikipaliApi\Model\PostApiV3SearchRequest $post_api_v3_search_request (required)
  932. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3Search'] to see the possible values for this operation
  933. *
  934. * @throws \InvalidArgumentException
  935. * @return \GuzzleHttp\Promise\PromiseInterface
  936. */
  937. public function postApiV3SearchAsync($post_api_v3_search_request, string $contentType = self::contentTypes['postApiV3Search'][0])
  938. {
  939. return $this->postApiV3SearchAsyncWithHttpInfo($post_api_v3_search_request, $contentType)
  940. ->then(
  941. function ($response) {
  942. return $response[0];
  943. }
  944. );
  945. }
  946. /**
  947. * Operation postApiV3SearchAsyncWithHttpInfo
  948. *
  949. * 全文检索(POST)
  950. *
  951. * @param \WikipaliApi\Model\PostApiV3SearchRequest $post_api_v3_search_request (required)
  952. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3Search'] to see the possible values for this operation
  953. *
  954. * @throws \InvalidArgumentException
  955. * @return \GuzzleHttp\Promise\PromiseInterface
  956. */
  957. public function postApiV3SearchAsyncWithHttpInfo($post_api_v3_search_request, string $contentType = self::contentTypes['postApiV3Search'][0])
  958. {
  959. $returnType = '\WikipaliApi\Model\GetApiV3Search200Response';
  960. $request = $this->postApiV3SearchRequest($post_api_v3_search_request, $contentType);
  961. return $this->client
  962. ->sendAsync($request, $this->createHttpClientOption())
  963. ->then(
  964. function ($response) use ($returnType) {
  965. if ($returnType === '\SplFileObject') {
  966. $content = $response->getBody(); //stream goes to serializer
  967. } else {
  968. $content = (string) $response->getBody();
  969. if ($returnType !== 'string') {
  970. $content = json_decode($content);
  971. }
  972. }
  973. return [
  974. ObjectSerializer::deserialize($content, $returnType, []),
  975. $response->getStatusCode(),
  976. $response->getHeaders()
  977. ];
  978. },
  979. function ($exception) {
  980. $response = $exception->getResponse();
  981. $statusCode = $response->getStatusCode();
  982. throw new ApiException(
  983. sprintf(
  984. '[%d] Error connecting to the API (%s)',
  985. $statusCode,
  986. $exception->getRequest()->getUri()
  987. ),
  988. $statusCode,
  989. $response->getHeaders(),
  990. (string) $response->getBody()
  991. );
  992. }
  993. );
  994. }
  995. /**
  996. * Create request for operation 'postApiV3Search'
  997. *
  998. * @param \WikipaliApi\Model\PostApiV3SearchRequest $post_api_v3_search_request (required)
  999. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3Search'] to see the possible values for this operation
  1000. *
  1001. * @throws \InvalidArgumentException
  1002. * @return \GuzzleHttp\Psr7\Request
  1003. */
  1004. public function postApiV3SearchRequest($post_api_v3_search_request, string $contentType = self::contentTypes['postApiV3Search'][0])
  1005. {
  1006. // verify the required parameter 'post_api_v3_search_request' is set
  1007. if ($post_api_v3_search_request === null || (is_array($post_api_v3_search_request) && count($post_api_v3_search_request) === 0)) {
  1008. throw new \InvalidArgumentException(
  1009. 'Missing the required parameter $post_api_v3_search_request when calling postApiV3Search'
  1010. );
  1011. }
  1012. $resourcePath = '/v3/search';
  1013. $formParams = [];
  1014. $queryParams = [];
  1015. $headerParams = [];
  1016. $httpBody = '';
  1017. $multipart = false;
  1018. $headers = $this->headerSelector->selectHeaders(
  1019. ['application/json', 'application/problem+json', ],
  1020. $contentType,
  1021. $multipart
  1022. );
  1023. // for model (json/xml)
  1024. if (isset($post_api_v3_search_request)) {
  1025. if (stripos($headers['Content-Type'], 'application/json') !== false) {
  1026. # if Content-Type contains "application/json", json_encode the body
  1027. try {
  1028. $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_search_request), JSON_THROW_ON_ERROR);
  1029. } catch (\JsonException $e) {
  1030. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1031. }
  1032. } else {
  1033. $httpBody = $post_api_v3_search_request;
  1034. }
  1035. } elseif (count($formParams) > 0) {
  1036. if ($multipart) {
  1037. $multipartContents = [];
  1038. foreach ($formParams as $formParamName => $formParamValue) {
  1039. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1040. foreach ($formParamValueItems as $formParamValueItem) {
  1041. $multipartContents[] = [
  1042. 'name' => $formParamName,
  1043. 'contents' => $formParamValueItem
  1044. ];
  1045. }
  1046. }
  1047. // for HTTP post (form)
  1048. $httpBody = new MultipartStream($multipartContents);
  1049. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1050. # if Content-Type contains "application/json", json_encode the form parameters
  1051. try {
  1052. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1053. } catch (\JsonException $e) {
  1054. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1055. }
  1056. } else {
  1057. // for HTTP post (form)
  1058. $httpBody = ObjectSerializer::buildQuery($formParams);
  1059. }
  1060. }
  1061. // this endpoint requires Bearer authentication (access token)
  1062. if (!empty($this->config->getAccessToken())) {
  1063. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1064. }
  1065. $defaultHeaders = [];
  1066. if ($this->config->getUserAgent()) {
  1067. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1068. }
  1069. $headers = array_merge(
  1070. $defaultHeaders,
  1071. $headerParams,
  1072. $headers
  1073. );
  1074. $operationHost = $this->config->getHost();
  1075. $query = ObjectSerializer::buildQuery($queryParams);
  1076. return new Request(
  1077. 'POST',
  1078. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1079. $headers,
  1080. $httpBody
  1081. );
  1082. }
  1083. /**
  1084. * Create http client option
  1085. *
  1086. * @throws \RuntimeException on file opening failure
  1087. * @return array of http client options
  1088. */
  1089. protected function createHttpClientOption()
  1090. {
  1091. $options = [];
  1092. if ($this->config->getDebug()) {
  1093. $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
  1094. if (!$options[RequestOptions::DEBUG]) {
  1095. throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
  1096. }
  1097. }
  1098. if ($this->config->getCertFile()) {
  1099. $options[RequestOptions::CERT] = $this->config->getCertFile();
  1100. }
  1101. if ($this->config->getKeyFile()) {
  1102. $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
  1103. }
  1104. return $options;
  1105. }
  1106. private function handleResponseWithDataType(
  1107. string $dataType,
  1108. RequestInterface $request,
  1109. ResponseInterface $response
  1110. ): array {
  1111. if ($dataType === '\SplFileObject') {
  1112. $content = $response->getBody(); //stream goes to serializer
  1113. } else {
  1114. $content = (string) $response->getBody();
  1115. if ($dataType !== 'string') {
  1116. try {
  1117. $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
  1118. } catch (\JsonException $exception) {
  1119. throw new ApiException(
  1120. sprintf(
  1121. 'Error JSON decoding server response (%s)',
  1122. $request->getUri()
  1123. ),
  1124. $response->getStatusCode(),
  1125. $response->getHeaders(),
  1126. $content
  1127. );
  1128. }
  1129. }
  1130. }
  1131. return [
  1132. ObjectSerializer::deserialize($content, $dataType, []),
  1133. $response->getStatusCode(),
  1134. $response->getHeaders()
  1135. ];
  1136. }
  1137. private function responseWithinRangeCode(
  1138. string $rangeCode,
  1139. int $statusCode
  1140. ): bool {
  1141. $left = (int) ($rangeCode[0].'00');
  1142. $right = (int) ($rangeCode[0].'99');
  1143. return $statusCode >= $left && $statusCode <= $right;
  1144. }
  1145. }