AdminApi.php 165 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995
  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: 1.0.0
  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. 'getApiV3AdminCreditAccounts' => [
  84. 'application/json',
  85. ],
  86. 'getApiV3AdminCreditLedger' => [
  87. 'application/json',
  88. ],
  89. 'getApiV3AdminCreditOverview' => [
  90. 'application/json',
  91. ],
  92. 'getApiV3AdminReadingStats' => [
  93. 'application/json',
  94. ],
  95. 'postApiV3AdminCreditAdjustments' => [
  96. 'application/json',
  97. ],
  98. 'postApiV3AdminCreditSettlements' => [
  99. 'application/json',
  100. ],
  101. ];
  102. /**
  103. * @param ClientInterface $client
  104. * @param Configuration $config
  105. * @param HeaderSelector $selector
  106. * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
  107. */
  108. public function __construct(
  109. ?ClientInterface $client = null,
  110. ?Configuration $config = null,
  111. ?HeaderSelector $selector = null,
  112. int $hostIndex = 0
  113. ) {
  114. $this->client = $client ?: new Client();
  115. $this->config = $config ?: Configuration::getDefaultConfiguration();
  116. $this->headerSelector = $selector ?: new HeaderSelector();
  117. $this->hostIndex = $hostIndex;
  118. }
  119. /**
  120. * Set the host index
  121. *
  122. * @param int $hostIndex Host index (required)
  123. */
  124. public function setHostIndex($hostIndex): void
  125. {
  126. $this->hostIndex = $hostIndex;
  127. }
  128. /**
  129. * Get the host index
  130. *
  131. * @return int Host index
  132. */
  133. public function getHostIndex()
  134. {
  135. return $this->hostIndex;
  136. }
  137. /**
  138. * @return Configuration
  139. */
  140. public function getConfig()
  141. {
  142. return $this->config;
  143. }
  144. /**
  145. * Operation getApiV3AdminAgentFeedback
  146. *
  147. * 列出评价
  148. *
  149. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  150. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  151. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  152. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  153. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  154. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  155. * @param int|null $page 页码 (optional, default to 1)
  156. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  157. *
  158. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  159. * @throws \InvalidArgumentException
  160. * @return \WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  161. */
  162. 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])
  163. {
  164. list($response) = $this->getApiV3AdminAgentFeedbackWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  165. return $response;
  166. }
  167. /**
  168. * Operation getApiV3AdminAgentFeedbackWithHttpInfo
  169. *
  170. * 列出评价
  171. *
  172. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  173. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  174. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  175. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  176. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  177. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  178. * @param int|null $page 页码 (optional, default to 1)
  179. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  180. *
  181. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  182. * @throws \InvalidArgumentException
  183. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  184. */
  185. 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])
  186. {
  187. $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  188. try {
  189. $options = $this->createHttpClientOption();
  190. try {
  191. $response = $this->client->send($request, $options);
  192. } catch (RequestException $e) {
  193. throw new ApiException(
  194. "[{$e->getCode()}] {$e->getMessage()}",
  195. (int) $e->getCode(),
  196. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  197. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  198. );
  199. } catch (ConnectException $e) {
  200. throw new ApiException(
  201. "[{$e->getCode()}] {$e->getMessage()}",
  202. (int) $e->getCode(),
  203. null,
  204. null
  205. );
  206. }
  207. $statusCode = $response->getStatusCode();
  208. switch($statusCode) {
  209. case 200:
  210. return $this->handleResponseWithDataType(
  211. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  212. $request,
  213. $response,
  214. );
  215. case 401:
  216. return $this->handleResponseWithDataType(
  217. '\WikipaliApi\Model\ProblemDetails',
  218. $request,
  219. $response,
  220. );
  221. case 422:
  222. return $this->handleResponseWithDataType(
  223. '\WikipaliApi\Model\ProblemDetails',
  224. $request,
  225. $response,
  226. );
  227. }
  228. if ($statusCode < 200 || $statusCode > 299) {
  229. throw new ApiException(
  230. sprintf(
  231. '[%d] Error connecting to the API (%s)',
  232. $statusCode,
  233. (string) $request->getUri()
  234. ),
  235. $statusCode,
  236. $response->getHeaders(),
  237. (string) $response->getBody()
  238. );
  239. }
  240. return $this->handleResponseWithDataType(
  241. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  242. $request,
  243. $response,
  244. );
  245. } catch (ApiException $e) {
  246. switch ($e->getCode()) {
  247. case 200:
  248. $data = ObjectSerializer::deserialize(
  249. $e->getResponseBody(),
  250. '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response',
  251. $e->getResponseHeaders()
  252. );
  253. $e->setResponseObject($data);
  254. throw $e;
  255. case 401:
  256. $data = ObjectSerializer::deserialize(
  257. $e->getResponseBody(),
  258. '\WikipaliApi\Model\ProblemDetails',
  259. $e->getResponseHeaders()
  260. );
  261. $e->setResponseObject($data);
  262. throw $e;
  263. case 422:
  264. $data = ObjectSerializer::deserialize(
  265. $e->getResponseBody(),
  266. '\WikipaliApi\Model\ProblemDetails',
  267. $e->getResponseHeaders()
  268. );
  269. $e->setResponseObject($data);
  270. throw $e;
  271. }
  272. throw $e;
  273. }
  274. }
  275. /**
  276. * Operation getApiV3AdminAgentFeedbackAsync
  277. *
  278. * 列出评价
  279. *
  280. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  281. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  282. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  283. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  284. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  285. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  286. * @param int|null $page 页码 (optional, default to 1)
  287. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  288. *
  289. * @throws \InvalidArgumentException
  290. * @return \GuzzleHttp\Promise\PromiseInterface
  291. */
  292. 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])
  293. {
  294. return $this->getApiV3AdminAgentFeedbackAsyncWithHttpInfo($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType)
  295. ->then(
  296. function ($response) {
  297. return $response[0];
  298. }
  299. );
  300. }
  301. /**
  302. * Operation getApiV3AdminAgentFeedbackAsyncWithHttpInfo
  303. *
  304. * 列出评价
  305. *
  306. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  307. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  308. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  309. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  310. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  311. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  312. * @param int|null $page 页码 (optional, default to 1)
  313. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  314. *
  315. * @throws \InvalidArgumentException
  316. * @return \GuzzleHttp\Promise\PromiseInterface
  317. */
  318. 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])
  319. {
  320. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentFeedback200Response';
  321. $request = $this->getApiV3AdminAgentFeedbackRequest($per_page, $filter_rating, $filter_tag, $filter_has_comment, $from, $to, $page, $contentType);
  322. return $this->client
  323. ->sendAsync($request, $this->createHttpClientOption())
  324. ->then(
  325. function ($response) use ($returnType) {
  326. if ($returnType === '\SplFileObject') {
  327. $content = $response->getBody(); //stream goes to serializer
  328. } else {
  329. $content = (string) $response->getBody();
  330. if ($returnType !== 'string') {
  331. $content = json_decode($content);
  332. }
  333. }
  334. return [
  335. ObjectSerializer::deserialize($content, $returnType, []),
  336. $response->getStatusCode(),
  337. $response->getHeaders()
  338. ];
  339. },
  340. function ($exception) {
  341. $response = $exception->getResponse();
  342. $statusCode = $response->getStatusCode();
  343. throw new ApiException(
  344. sprintf(
  345. '[%d] Error connecting to the API (%s)',
  346. $statusCode,
  347. $exception->getRequest()->getUri()
  348. ),
  349. $statusCode,
  350. $response->getHeaders(),
  351. (string) $response->getBody()
  352. );
  353. }
  354. );
  355. }
  356. /**
  357. * Create request for operation 'getApiV3AdminAgentFeedback'
  358. *
  359. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  360. * @param string|null $filter_rating 1 赞 / -1 踩 (optional)
  361. * @param string|null $filter_tag 按标签 / 原因筛 (optional)
  362. * @param bool|null $filter_has_comment 只看带文字说明的 (optional)
  363. * @param string|null $from 起始日(UTC,Y-m-d) (optional)
  364. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional)
  365. * @param int|null $page 页码 (optional, default to 1)
  366. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentFeedback'] to see the possible values for this operation
  367. *
  368. * @throws \InvalidArgumentException
  369. * @return \GuzzleHttp\Psr7\Request
  370. */
  371. 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])
  372. {
  373. $resourcePath = '/v3/admin/agent-feedback';
  374. $formParams = [];
  375. $queryParams = [];
  376. $headerParams = [];
  377. $httpBody = '';
  378. $multipart = false;
  379. // query params
  380. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  381. $per_page,
  382. 'per_page', // param base name
  383. 'integer', // openApiType
  384. 'form', // style
  385. true, // explode
  386. false // required
  387. ) ?? []);
  388. // query params
  389. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  390. $filter_rating,
  391. 'filter[rating]', // param base name
  392. 'string', // openApiType
  393. 'form', // style
  394. true, // explode
  395. false // required
  396. ) ?? []);
  397. // query params
  398. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  399. $filter_tag,
  400. 'filter[tag]', // param base name
  401. 'string', // openApiType
  402. 'form', // style
  403. true, // explode
  404. false // required
  405. ) ?? []);
  406. // query params
  407. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  408. $filter_has_comment,
  409. 'filter[has_comment]', // param base name
  410. 'boolean', // openApiType
  411. 'form', // style
  412. true, // explode
  413. false // required
  414. ) ?? []);
  415. // query params
  416. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  417. $from,
  418. 'from', // param base name
  419. 'string', // openApiType
  420. 'form', // style
  421. true, // explode
  422. false // required
  423. ) ?? []);
  424. // query params
  425. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  426. $to,
  427. 'to', // param base name
  428. 'string', // openApiType
  429. 'form', // style
  430. true, // explode
  431. false // required
  432. ) ?? []);
  433. // query params
  434. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  435. $page,
  436. 'page', // param base name
  437. 'integer', // openApiType
  438. 'form', // style
  439. true, // explode
  440. false // required
  441. ) ?? []);
  442. $headers = $this->headerSelector->selectHeaders(
  443. ['application/json', 'application/problem+json', ],
  444. $contentType,
  445. $multipart
  446. );
  447. // for model (json/xml)
  448. if (count($formParams) > 0) {
  449. if ($multipart) {
  450. $multipartContents = [];
  451. foreach ($formParams as $formParamName => $formParamValue) {
  452. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  453. foreach ($formParamValueItems as $formParamValueItem) {
  454. $multipartContents[] = [
  455. 'name' => $formParamName,
  456. 'contents' => $formParamValueItem
  457. ];
  458. }
  459. }
  460. // for HTTP post (form)
  461. $httpBody = new MultipartStream($multipartContents);
  462. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  463. # if Content-Type contains "application/json", json_encode the form parameters
  464. try {
  465. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  466. } catch (\JsonException $e) {
  467. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  468. }
  469. } else {
  470. // for HTTP post (form)
  471. $httpBody = ObjectSerializer::buildQuery($formParams);
  472. }
  473. }
  474. // this endpoint requires Bearer authentication (access token)
  475. if (!empty($this->config->getAccessToken())) {
  476. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  477. }
  478. $defaultHeaders = [];
  479. if ($this->config->getUserAgent()) {
  480. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  481. }
  482. $headers = array_merge(
  483. $defaultHeaders,
  484. $headerParams,
  485. $headers
  486. );
  487. $operationHost = $this->config->getHost();
  488. $query = ObjectSerializer::buildQuery($queryParams);
  489. return new Request(
  490. 'GET',
  491. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  492. $headers,
  493. $httpBody
  494. );
  495. }
  496. /**
  497. * Operation getApiV3AdminAgentRuns
  498. *
  499. * 列出提问
  500. *
  501. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  502. * @param string|null $filter_status 运行结果 (optional)
  503. * @param string|null $filter_route 研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊 (optional)
  504. * @param string|null $filter_account_type 账号类型 (optional)
  505. * @param string|null $filter_client 客户端 (optional)
  506. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  507. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  508. * @param int|null $page 页码 (optional, default to 1)
  509. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  510. *
  511. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  512. * @throws \InvalidArgumentException
  513. * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  514. */
  515. 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])
  516. {
  517. list($response) = $this->getApiV3AdminAgentRunsWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  518. return $response;
  519. }
  520. /**
  521. * Operation getApiV3AdminAgentRunsWithHttpInfo
  522. *
  523. * 列出提问
  524. *
  525. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  526. * @param string|null $filter_status 运行结果 (optional)
  527. * @param string|null $filter_route 研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊 (optional)
  528. * @param string|null $filter_account_type 账号类型 (optional)
  529. * @param string|null $filter_client 客户端 (optional)
  530. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  531. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  532. * @param int|null $page 页码 (optional, default to 1)
  533. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  534. *
  535. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  536. * @throws \InvalidArgumentException
  537. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRuns200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  538. */
  539. 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])
  540. {
  541. $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  542. try {
  543. $options = $this->createHttpClientOption();
  544. try {
  545. $response = $this->client->send($request, $options);
  546. } catch (RequestException $e) {
  547. throw new ApiException(
  548. "[{$e->getCode()}] {$e->getMessage()}",
  549. (int) $e->getCode(),
  550. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  551. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  552. );
  553. } catch (ConnectException $e) {
  554. throw new ApiException(
  555. "[{$e->getCode()}] {$e->getMessage()}",
  556. (int) $e->getCode(),
  557. null,
  558. null
  559. );
  560. }
  561. $statusCode = $response->getStatusCode();
  562. switch($statusCode) {
  563. case 200:
  564. return $this->handleResponseWithDataType(
  565. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  566. $request,
  567. $response,
  568. );
  569. case 401:
  570. return $this->handleResponseWithDataType(
  571. '\WikipaliApi\Model\ProblemDetails',
  572. $request,
  573. $response,
  574. );
  575. case 422:
  576. return $this->handleResponseWithDataType(
  577. '\WikipaliApi\Model\ProblemDetails',
  578. $request,
  579. $response,
  580. );
  581. }
  582. if ($statusCode < 200 || $statusCode > 299) {
  583. throw new ApiException(
  584. sprintf(
  585. '[%d] Error connecting to the API (%s)',
  586. $statusCode,
  587. (string) $request->getUri()
  588. ),
  589. $statusCode,
  590. $response->getHeaders(),
  591. (string) $response->getBody()
  592. );
  593. }
  594. return $this->handleResponseWithDataType(
  595. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  596. $request,
  597. $response,
  598. );
  599. } catch (ApiException $e) {
  600. switch ($e->getCode()) {
  601. case 200:
  602. $data = ObjectSerializer::deserialize(
  603. $e->getResponseBody(),
  604. '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response',
  605. $e->getResponseHeaders()
  606. );
  607. $e->setResponseObject($data);
  608. throw $e;
  609. case 401:
  610. $data = ObjectSerializer::deserialize(
  611. $e->getResponseBody(),
  612. '\WikipaliApi\Model\ProblemDetails',
  613. $e->getResponseHeaders()
  614. );
  615. $e->setResponseObject($data);
  616. throw $e;
  617. case 422:
  618. $data = ObjectSerializer::deserialize(
  619. $e->getResponseBody(),
  620. '\WikipaliApi\Model\ProblemDetails',
  621. $e->getResponseHeaders()
  622. );
  623. $e->setResponseObject($data);
  624. throw $e;
  625. }
  626. throw $e;
  627. }
  628. }
  629. /**
  630. * Operation getApiV3AdminAgentRunsAsync
  631. *
  632. * 列出提问
  633. *
  634. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  635. * @param string|null $filter_status 运行结果 (optional)
  636. * @param string|null $filter_route 研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊 (optional)
  637. * @param string|null $filter_account_type 账号类型 (optional)
  638. * @param string|null $filter_client 客户端 (optional)
  639. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  640. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  641. * @param int|null $page 页码 (optional, default to 1)
  642. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  643. *
  644. * @throws \InvalidArgumentException
  645. * @return \GuzzleHttp\Promise\PromiseInterface
  646. */
  647. 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])
  648. {
  649. return $this->getApiV3AdminAgentRunsAsyncWithHttpInfo($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType)
  650. ->then(
  651. function ($response) {
  652. return $response[0];
  653. }
  654. );
  655. }
  656. /**
  657. * Operation getApiV3AdminAgentRunsAsyncWithHttpInfo
  658. *
  659. * 列出提问
  660. *
  661. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  662. * @param string|null $filter_status 运行结果 (optional)
  663. * @param string|null $filter_route 研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊 (optional)
  664. * @param string|null $filter_account_type 账号类型 (optional)
  665. * @param string|null $filter_client 客户端 (optional)
  666. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  667. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  668. * @param int|null $page 页码 (optional, default to 1)
  669. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  670. *
  671. * @throws \InvalidArgumentException
  672. * @return \GuzzleHttp\Promise\PromiseInterface
  673. */
  674. 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])
  675. {
  676. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRuns200Response';
  677. $request = $this->getApiV3AdminAgentRunsRequest($per_page, $filter_status, $filter_route, $filter_account_type, $filter_client, $filter_improve, $filter_q, $page, $contentType);
  678. return $this->client
  679. ->sendAsync($request, $this->createHttpClientOption())
  680. ->then(
  681. function ($response) use ($returnType) {
  682. if ($returnType === '\SplFileObject') {
  683. $content = $response->getBody(); //stream goes to serializer
  684. } else {
  685. $content = (string) $response->getBody();
  686. if ($returnType !== 'string') {
  687. $content = json_decode($content);
  688. }
  689. }
  690. return [
  691. ObjectSerializer::deserialize($content, $returnType, []),
  692. $response->getStatusCode(),
  693. $response->getHeaders()
  694. ];
  695. },
  696. function ($exception) {
  697. $response = $exception->getResponse();
  698. $statusCode = $response->getStatusCode();
  699. throw new ApiException(
  700. sprintf(
  701. '[%d] Error connecting to the API (%s)',
  702. $statusCode,
  703. $exception->getRequest()->getUri()
  704. ),
  705. $statusCode,
  706. $response->getHeaders(),
  707. (string) $response->getBody()
  708. );
  709. }
  710. );
  711. }
  712. /**
  713. * Create request for operation 'getApiV3AdminAgentRuns'
  714. *
  715. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  716. * @param string|null $filter_status 运行结果 (optional)
  717. * @param string|null $filter_route 研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊 (optional)
  718. * @param string|null $filter_account_type 账号类型 (optional)
  719. * @param string|null $filter_client 客户端 (optional)
  720. * @param bool|null $filter_improve 是否允许用于改进回答 (optional)
  721. * @param string|null $filter_q 按提问原文模糊搜索 (optional)
  722. * @param int|null $page 页码 (optional, default to 1)
  723. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRuns'] to see the possible values for this operation
  724. *
  725. * @throws \InvalidArgumentException
  726. * @return \GuzzleHttp\Psr7\Request
  727. */
  728. 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])
  729. {
  730. $resourcePath = '/v3/admin/agent-runs';
  731. $formParams = [];
  732. $queryParams = [];
  733. $headerParams = [];
  734. $httpBody = '';
  735. $multipart = false;
  736. // query params
  737. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  738. $per_page,
  739. 'per_page', // param base name
  740. 'integer', // openApiType
  741. 'form', // style
  742. true, // explode
  743. false // required
  744. ) ?? []);
  745. // query params
  746. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  747. $filter_status,
  748. 'filter[status]', // param base name
  749. 'string', // openApiType
  750. 'form', // style
  751. true, // explode
  752. false // required
  753. ) ?? []);
  754. // query params
  755. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  756. $filter_route,
  757. 'filter[route]', // param base name
  758. 'string', // openApiType
  759. 'form', // style
  760. true, // explode
  761. false // required
  762. ) ?? []);
  763. // query params
  764. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  765. $filter_account_type,
  766. 'filter[account_type]', // param base name
  767. 'string', // openApiType
  768. 'form', // style
  769. true, // explode
  770. false // required
  771. ) ?? []);
  772. // query params
  773. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  774. $filter_client,
  775. 'filter[client]', // param base name
  776. 'string', // openApiType
  777. 'form', // style
  778. true, // explode
  779. false // required
  780. ) ?? []);
  781. // query params
  782. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  783. $filter_improve,
  784. 'filter[improve]', // param base name
  785. 'boolean', // openApiType
  786. 'form', // style
  787. true, // explode
  788. false // required
  789. ) ?? []);
  790. // query params
  791. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  792. $filter_q,
  793. 'filter[q]', // param base name
  794. 'string', // openApiType
  795. 'form', // style
  796. true, // explode
  797. false // required
  798. ) ?? []);
  799. // query params
  800. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  801. $page,
  802. 'page', // param base name
  803. 'integer', // openApiType
  804. 'form', // style
  805. true, // explode
  806. false // required
  807. ) ?? []);
  808. $headers = $this->headerSelector->selectHeaders(
  809. ['application/json', 'application/problem+json', ],
  810. $contentType,
  811. $multipart
  812. );
  813. // for model (json/xml)
  814. if (count($formParams) > 0) {
  815. if ($multipart) {
  816. $multipartContents = [];
  817. foreach ($formParams as $formParamName => $formParamValue) {
  818. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  819. foreach ($formParamValueItems as $formParamValueItem) {
  820. $multipartContents[] = [
  821. 'name' => $formParamName,
  822. 'contents' => $formParamValueItem
  823. ];
  824. }
  825. }
  826. // for HTTP post (form)
  827. $httpBody = new MultipartStream($multipartContents);
  828. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  829. # if Content-Type contains "application/json", json_encode the form parameters
  830. try {
  831. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  832. } catch (\JsonException $e) {
  833. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  834. }
  835. } else {
  836. // for HTTP post (form)
  837. $httpBody = ObjectSerializer::buildQuery($formParams);
  838. }
  839. }
  840. // this endpoint requires Bearer authentication (access token)
  841. if (!empty($this->config->getAccessToken())) {
  842. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  843. }
  844. $defaultHeaders = [];
  845. if ($this->config->getUserAgent()) {
  846. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  847. }
  848. $headers = array_merge(
  849. $defaultHeaders,
  850. $headerParams,
  851. $headers
  852. );
  853. $operationHost = $this->config->getHost();
  854. $query = ObjectSerializer::buildQuery($queryParams);
  855. return new Request(
  856. 'GET',
  857. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  858. $headers,
  859. $httpBody
  860. );
  861. }
  862. /**
  863. * Operation getApiV3AdminAgentRunsDigest
  864. *
  865. * 分析用的精简导出
  866. *
  867. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  868. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  869. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  870. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  871. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  872. *
  873. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  874. * @throws \InvalidArgumentException
  875. * @return \WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  876. */
  877. public function getApiV3AdminAgentRunsDigest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  878. {
  879. list($response) = $this->getApiV3AdminAgentRunsDigestWithHttpInfo($full, $limit, $from, $to, $contentType);
  880. return $response;
  881. }
  882. /**
  883. * Operation getApiV3AdminAgentRunsDigestWithHttpInfo
  884. *
  885. * 分析用的精简导出
  886. *
  887. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  888. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  889. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  890. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  891. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  892. *
  893. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  894. * @throws \InvalidArgumentException
  895. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  896. */
  897. public function getApiV3AdminAgentRunsDigestWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  898. {
  899. $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $contentType);
  900. try {
  901. $options = $this->createHttpClientOption();
  902. try {
  903. $response = $this->client->send($request, $options);
  904. } catch (RequestException $e) {
  905. throw new ApiException(
  906. "[{$e->getCode()}] {$e->getMessage()}",
  907. (int) $e->getCode(),
  908. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  909. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  910. );
  911. } catch (ConnectException $e) {
  912. throw new ApiException(
  913. "[{$e->getCode()}] {$e->getMessage()}",
  914. (int) $e->getCode(),
  915. null,
  916. null
  917. );
  918. }
  919. $statusCode = $response->getStatusCode();
  920. switch($statusCode) {
  921. case 200:
  922. return $this->handleResponseWithDataType(
  923. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  924. $request,
  925. $response,
  926. );
  927. case 401:
  928. return $this->handleResponseWithDataType(
  929. '\WikipaliApi\Model\ProblemDetails',
  930. $request,
  931. $response,
  932. );
  933. case 422:
  934. return $this->handleResponseWithDataType(
  935. '\WikipaliApi\Model\ProblemDetails',
  936. $request,
  937. $response,
  938. );
  939. }
  940. if ($statusCode < 200 || $statusCode > 299) {
  941. throw new ApiException(
  942. sprintf(
  943. '[%d] Error connecting to the API (%s)',
  944. $statusCode,
  945. (string) $request->getUri()
  946. ),
  947. $statusCode,
  948. $response->getHeaders(),
  949. (string) $response->getBody()
  950. );
  951. }
  952. return $this->handleResponseWithDataType(
  953. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  954. $request,
  955. $response,
  956. );
  957. } catch (ApiException $e) {
  958. switch ($e->getCode()) {
  959. case 200:
  960. $data = ObjectSerializer::deserialize(
  961. $e->getResponseBody(),
  962. '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response',
  963. $e->getResponseHeaders()
  964. );
  965. $e->setResponseObject($data);
  966. throw $e;
  967. case 401:
  968. $data = ObjectSerializer::deserialize(
  969. $e->getResponseBody(),
  970. '\WikipaliApi\Model\ProblemDetails',
  971. $e->getResponseHeaders()
  972. );
  973. $e->setResponseObject($data);
  974. throw $e;
  975. case 422:
  976. $data = ObjectSerializer::deserialize(
  977. $e->getResponseBody(),
  978. '\WikipaliApi\Model\ProblemDetails',
  979. $e->getResponseHeaders()
  980. );
  981. $e->setResponseObject($data);
  982. throw $e;
  983. }
  984. throw $e;
  985. }
  986. }
  987. /**
  988. * Operation getApiV3AdminAgentRunsDigestAsync
  989. *
  990. * 分析用的精简导出
  991. *
  992. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  993. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  994. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  995. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  996. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  997. *
  998. * @throws \InvalidArgumentException
  999. * @return \GuzzleHttp\Promise\PromiseInterface
  1000. */
  1001. public function getApiV3AdminAgentRunsDigestAsync($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  1002. {
  1003. return $this->getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full, $limit, $from, $to, $contentType)
  1004. ->then(
  1005. function ($response) {
  1006. return $response[0];
  1007. }
  1008. );
  1009. }
  1010. /**
  1011. * Operation getApiV3AdminAgentRunsDigestAsyncWithHttpInfo
  1012. *
  1013. * 分析用的精简导出
  1014. *
  1015. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  1016. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  1017. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1018. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1019. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  1020. *
  1021. * @throws \InvalidArgumentException
  1022. * @return \GuzzleHttp\Promise\PromiseInterface
  1023. */
  1024. public function getApiV3AdminAgentRunsDigestAsyncWithHttpInfo($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  1025. {
  1026. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsDigest200Response';
  1027. $request = $this->getApiV3AdminAgentRunsDigestRequest($full, $limit, $from, $to, $contentType);
  1028. return $this->client
  1029. ->sendAsync($request, $this->createHttpClientOption())
  1030. ->then(
  1031. function ($response) use ($returnType) {
  1032. if ($returnType === '\SplFileObject') {
  1033. $content = $response->getBody(); //stream goes to serializer
  1034. } else {
  1035. $content = (string) $response->getBody();
  1036. if ($returnType !== 'string') {
  1037. $content = json_decode($content);
  1038. }
  1039. }
  1040. return [
  1041. ObjectSerializer::deserialize($content, $returnType, []),
  1042. $response->getStatusCode(),
  1043. $response->getHeaders()
  1044. ];
  1045. },
  1046. function ($exception) {
  1047. $response = $exception->getResponse();
  1048. $statusCode = $response->getStatusCode();
  1049. throw new ApiException(
  1050. sprintf(
  1051. '[%d] Error connecting to the API (%s)',
  1052. $statusCode,
  1053. $exception->getRequest()->getUri()
  1054. ),
  1055. $statusCode,
  1056. $response->getHeaders(),
  1057. (string) $response->getBody()
  1058. );
  1059. }
  1060. );
  1061. }
  1062. /**
  1063. * Create request for operation 'getApiV3AdminAgentRunsDigest'
  1064. *
  1065. * @param bool|null $full 是否带回答、证据全文与引用(此时 limit 最大 200) (optional, default to false)
  1066. * @param int|null $limit 最多多少条,最大 2000(full 时 200) (optional)
  1067. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1068. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1069. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsDigest'] to see the possible values for this operation
  1070. *
  1071. * @throws \InvalidArgumentException
  1072. * @return \GuzzleHttp\Psr7\Request
  1073. */
  1074. public function getApiV3AdminAgentRunsDigestRequest($full = false, $limit = null, $from = '今天往前 29 天', $to = '今天', string $contentType = self::contentTypes['getApiV3AdminAgentRunsDigest'][0])
  1075. {
  1076. $resourcePath = '/v3/admin/agent-runs/digest';
  1077. $formParams = [];
  1078. $queryParams = [];
  1079. $headerParams = [];
  1080. $httpBody = '';
  1081. $multipart = false;
  1082. // query params
  1083. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1084. $full,
  1085. 'full', // param base name
  1086. 'boolean', // openApiType
  1087. 'form', // style
  1088. true, // explode
  1089. false // required
  1090. ) ?? []);
  1091. // query params
  1092. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1093. $limit,
  1094. 'limit', // param base name
  1095. 'integer', // openApiType
  1096. 'form', // style
  1097. true, // explode
  1098. false // required
  1099. ) ?? []);
  1100. // query params
  1101. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1102. $from,
  1103. 'from', // param base name
  1104. 'string', // openApiType
  1105. 'form', // style
  1106. true, // explode
  1107. false // required
  1108. ) ?? []);
  1109. // query params
  1110. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1111. $to,
  1112. 'to', // param base name
  1113. 'string', // openApiType
  1114. 'form', // style
  1115. true, // explode
  1116. false // required
  1117. ) ?? []);
  1118. $headers = $this->headerSelector->selectHeaders(
  1119. ['application/json', 'application/problem+json', ],
  1120. $contentType,
  1121. $multipart
  1122. );
  1123. // for model (json/xml)
  1124. if (count($formParams) > 0) {
  1125. if ($multipart) {
  1126. $multipartContents = [];
  1127. foreach ($formParams as $formParamName => $formParamValue) {
  1128. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1129. foreach ($formParamValueItems as $formParamValueItem) {
  1130. $multipartContents[] = [
  1131. 'name' => $formParamName,
  1132. 'contents' => $formParamValueItem
  1133. ];
  1134. }
  1135. }
  1136. // for HTTP post (form)
  1137. $httpBody = new MultipartStream($multipartContents);
  1138. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1139. # if Content-Type contains "application/json", json_encode the form parameters
  1140. try {
  1141. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1142. } catch (\JsonException $e) {
  1143. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1144. }
  1145. } else {
  1146. // for HTTP post (form)
  1147. $httpBody = ObjectSerializer::buildQuery($formParams);
  1148. }
  1149. }
  1150. // this endpoint requires Bearer authentication (access token)
  1151. if (!empty($this->config->getAccessToken())) {
  1152. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1153. }
  1154. $defaultHeaders = [];
  1155. if ($this->config->getUserAgent()) {
  1156. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1157. }
  1158. $headers = array_merge(
  1159. $defaultHeaders,
  1160. $headerParams,
  1161. $headers
  1162. );
  1163. $operationHost = $this->config->getHost();
  1164. $query = ObjectSerializer::buildQuery($queryParams);
  1165. return new Request(
  1166. 'GET',
  1167. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1168. $headers,
  1169. $httpBody
  1170. );
  1171. }
  1172. /**
  1173. * Operation getApiV3AdminAgentRunsRun
  1174. *
  1175. * 查看一次提问的研究过程
  1176. *
  1177. * @param string $run AG-UI runId(uuid) (required)
  1178. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1179. *
  1180. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1181. * @throws \InvalidArgumentException
  1182. * @return \WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1183. */
  1184. public function getApiV3AdminAgentRunsRun($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1185. {
  1186. list($response) = $this->getApiV3AdminAgentRunsRunWithHttpInfo($run, $contentType);
  1187. return $response;
  1188. }
  1189. /**
  1190. * Operation getApiV3AdminAgentRunsRunWithHttpInfo
  1191. *
  1192. * 查看一次提问的研究过程
  1193. *
  1194. * @param string $run AG-UI runId(uuid) (required)
  1195. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1196. *
  1197. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1198. * @throws \InvalidArgumentException
  1199. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1200. */
  1201. public function getApiV3AdminAgentRunsRunWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1202. {
  1203. $request = $this->getApiV3AdminAgentRunsRunRequest($run, $contentType);
  1204. try {
  1205. $options = $this->createHttpClientOption();
  1206. try {
  1207. $response = $this->client->send($request, $options);
  1208. } catch (RequestException $e) {
  1209. throw new ApiException(
  1210. "[{$e->getCode()}] {$e->getMessage()}",
  1211. (int) $e->getCode(),
  1212. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1213. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1214. );
  1215. } catch (ConnectException $e) {
  1216. throw new ApiException(
  1217. "[{$e->getCode()}] {$e->getMessage()}",
  1218. (int) $e->getCode(),
  1219. null,
  1220. null
  1221. );
  1222. }
  1223. $statusCode = $response->getStatusCode();
  1224. switch($statusCode) {
  1225. case 200:
  1226. return $this->handleResponseWithDataType(
  1227. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1228. $request,
  1229. $response,
  1230. );
  1231. case 401:
  1232. return $this->handleResponseWithDataType(
  1233. '\WikipaliApi\Model\ProblemDetails',
  1234. $request,
  1235. $response,
  1236. );
  1237. case 422:
  1238. return $this->handleResponseWithDataType(
  1239. '\WikipaliApi\Model\ProblemDetails',
  1240. $request,
  1241. $response,
  1242. );
  1243. }
  1244. if ($statusCode < 200 || $statusCode > 299) {
  1245. throw new ApiException(
  1246. sprintf(
  1247. '[%d] Error connecting to the API (%s)',
  1248. $statusCode,
  1249. (string) $request->getUri()
  1250. ),
  1251. $statusCode,
  1252. $response->getHeaders(),
  1253. (string) $response->getBody()
  1254. );
  1255. }
  1256. return $this->handleResponseWithDataType(
  1257. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1258. $request,
  1259. $response,
  1260. );
  1261. } catch (ApiException $e) {
  1262. switch ($e->getCode()) {
  1263. case 200:
  1264. $data = ObjectSerializer::deserialize(
  1265. $e->getResponseBody(),
  1266. '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response',
  1267. $e->getResponseHeaders()
  1268. );
  1269. $e->setResponseObject($data);
  1270. throw $e;
  1271. case 401:
  1272. $data = ObjectSerializer::deserialize(
  1273. $e->getResponseBody(),
  1274. '\WikipaliApi\Model\ProblemDetails',
  1275. $e->getResponseHeaders()
  1276. );
  1277. $e->setResponseObject($data);
  1278. throw $e;
  1279. case 422:
  1280. $data = ObjectSerializer::deserialize(
  1281. $e->getResponseBody(),
  1282. '\WikipaliApi\Model\ProblemDetails',
  1283. $e->getResponseHeaders()
  1284. );
  1285. $e->setResponseObject($data);
  1286. throw $e;
  1287. }
  1288. throw $e;
  1289. }
  1290. }
  1291. /**
  1292. * Operation getApiV3AdminAgentRunsRunAsync
  1293. *
  1294. * 查看一次提问的研究过程
  1295. *
  1296. * @param string $run AG-UI runId(uuid) (required)
  1297. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1298. *
  1299. * @throws \InvalidArgumentException
  1300. * @return \GuzzleHttp\Promise\PromiseInterface
  1301. */
  1302. public function getApiV3AdminAgentRunsRunAsync($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1303. {
  1304. return $this->getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, $contentType)
  1305. ->then(
  1306. function ($response) {
  1307. return $response[0];
  1308. }
  1309. );
  1310. }
  1311. /**
  1312. * Operation getApiV3AdminAgentRunsRunAsyncWithHttpInfo
  1313. *
  1314. * 查看一次提问的研究过程
  1315. *
  1316. * @param string $run AG-UI runId(uuid) (required)
  1317. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1318. *
  1319. * @throws \InvalidArgumentException
  1320. * @return \GuzzleHttp\Promise\PromiseInterface
  1321. */
  1322. public function getApiV3AdminAgentRunsRunAsyncWithHttpInfo($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1323. {
  1324. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentRunsRun200Response';
  1325. $request = $this->getApiV3AdminAgentRunsRunRequest($run, $contentType);
  1326. return $this->client
  1327. ->sendAsync($request, $this->createHttpClientOption())
  1328. ->then(
  1329. function ($response) use ($returnType) {
  1330. if ($returnType === '\SplFileObject') {
  1331. $content = $response->getBody(); //stream goes to serializer
  1332. } else {
  1333. $content = (string) $response->getBody();
  1334. if ($returnType !== 'string') {
  1335. $content = json_decode($content);
  1336. }
  1337. }
  1338. return [
  1339. ObjectSerializer::deserialize($content, $returnType, []),
  1340. $response->getStatusCode(),
  1341. $response->getHeaders()
  1342. ];
  1343. },
  1344. function ($exception) {
  1345. $response = $exception->getResponse();
  1346. $statusCode = $response->getStatusCode();
  1347. throw new ApiException(
  1348. sprintf(
  1349. '[%d] Error connecting to the API (%s)',
  1350. $statusCode,
  1351. $exception->getRequest()->getUri()
  1352. ),
  1353. $statusCode,
  1354. $response->getHeaders(),
  1355. (string) $response->getBody()
  1356. );
  1357. }
  1358. );
  1359. }
  1360. /**
  1361. * Create request for operation 'getApiV3AdminAgentRunsRun'
  1362. *
  1363. * @param string $run AG-UI runId(uuid) (required)
  1364. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentRunsRun'] to see the possible values for this operation
  1365. *
  1366. * @throws \InvalidArgumentException
  1367. * @return \GuzzleHttp\Psr7\Request
  1368. */
  1369. public function getApiV3AdminAgentRunsRunRequest($run, string $contentType = self::contentTypes['getApiV3AdminAgentRunsRun'][0])
  1370. {
  1371. // verify the required parameter 'run' is set
  1372. if ($run === null || (is_array($run) && count($run) === 0)) {
  1373. throw new \InvalidArgumentException(
  1374. 'Missing the required parameter $run when calling getApiV3AdminAgentRunsRun'
  1375. );
  1376. }
  1377. $resourcePath = '/v3/admin/agent-runs/{run}';
  1378. $formParams = [];
  1379. $queryParams = [];
  1380. $headerParams = [];
  1381. $httpBody = '';
  1382. $multipart = false;
  1383. // path params
  1384. if ($run !== null) {
  1385. $resourcePath = str_replace(
  1386. '{run}',
  1387. ObjectSerializer::toPathValue($run),
  1388. $resourcePath
  1389. );
  1390. }
  1391. $headers = $this->headerSelector->selectHeaders(
  1392. ['application/json', 'application/problem+json', ],
  1393. $contentType,
  1394. $multipart
  1395. );
  1396. // for model (json/xml)
  1397. if (count($formParams) > 0) {
  1398. if ($multipart) {
  1399. $multipartContents = [];
  1400. foreach ($formParams as $formParamName => $formParamValue) {
  1401. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1402. foreach ($formParamValueItems as $formParamValueItem) {
  1403. $multipartContents[] = [
  1404. 'name' => $formParamName,
  1405. 'contents' => $formParamValueItem
  1406. ];
  1407. }
  1408. }
  1409. // for HTTP post (form)
  1410. $httpBody = new MultipartStream($multipartContents);
  1411. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1412. # if Content-Type contains "application/json", json_encode the form parameters
  1413. try {
  1414. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1415. } catch (\JsonException $e) {
  1416. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1417. }
  1418. } else {
  1419. // for HTTP post (form)
  1420. $httpBody = ObjectSerializer::buildQuery($formParams);
  1421. }
  1422. }
  1423. // this endpoint requires Bearer authentication (access token)
  1424. if (!empty($this->config->getAccessToken())) {
  1425. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1426. }
  1427. $defaultHeaders = [];
  1428. if ($this->config->getUserAgent()) {
  1429. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1430. }
  1431. $headers = array_merge(
  1432. $defaultHeaders,
  1433. $headerParams,
  1434. $headers
  1435. );
  1436. $operationHost = $this->config->getHost();
  1437. $query = ObjectSerializer::buildQuery($queryParams);
  1438. return new Request(
  1439. 'GET',
  1440. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1441. $headers,
  1442. $httpBody
  1443. );
  1444. }
  1445. /**
  1446. * Operation getApiV3AdminAgentStats
  1447. *
  1448. * AI 对话统计
  1449. *
  1450. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1451. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1452. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1453. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1454. *
  1455. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1456. * @throws \InvalidArgumentException
  1457. * @return \WikipaliApi\Model\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1458. */
  1459. public function getApiV3AdminAgentStats($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1460. {
  1461. list($response) = $this->getApiV3AdminAgentStatsWithHttpInfo($from, $to, $account_type, $contentType);
  1462. return $response;
  1463. }
  1464. /**
  1465. * Operation getApiV3AdminAgentStatsWithHttpInfo
  1466. *
  1467. * AI 对话统计
  1468. *
  1469. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1470. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1471. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1472. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1473. *
  1474. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1475. * @throws \InvalidArgumentException
  1476. * @return array of \WikipaliApi\Model\GetApiV3AdminAgentStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1477. */
  1478. public function getApiV3AdminAgentStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1479. {
  1480. $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $contentType);
  1481. try {
  1482. $options = $this->createHttpClientOption();
  1483. try {
  1484. $response = $this->client->send($request, $options);
  1485. } catch (RequestException $e) {
  1486. throw new ApiException(
  1487. "[{$e->getCode()}] {$e->getMessage()}",
  1488. (int) $e->getCode(),
  1489. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1490. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1491. );
  1492. } catch (ConnectException $e) {
  1493. throw new ApiException(
  1494. "[{$e->getCode()}] {$e->getMessage()}",
  1495. (int) $e->getCode(),
  1496. null,
  1497. null
  1498. );
  1499. }
  1500. $statusCode = $response->getStatusCode();
  1501. switch($statusCode) {
  1502. case 200:
  1503. return $this->handleResponseWithDataType(
  1504. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1505. $request,
  1506. $response,
  1507. );
  1508. case 401:
  1509. return $this->handleResponseWithDataType(
  1510. '\WikipaliApi\Model\ProblemDetails',
  1511. $request,
  1512. $response,
  1513. );
  1514. case 422:
  1515. return $this->handleResponseWithDataType(
  1516. '\WikipaliApi\Model\ProblemDetails',
  1517. $request,
  1518. $response,
  1519. );
  1520. }
  1521. if ($statusCode < 200 || $statusCode > 299) {
  1522. throw new ApiException(
  1523. sprintf(
  1524. '[%d] Error connecting to the API (%s)',
  1525. $statusCode,
  1526. (string) $request->getUri()
  1527. ),
  1528. $statusCode,
  1529. $response->getHeaders(),
  1530. (string) $response->getBody()
  1531. );
  1532. }
  1533. return $this->handleResponseWithDataType(
  1534. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1535. $request,
  1536. $response,
  1537. );
  1538. } catch (ApiException $e) {
  1539. switch ($e->getCode()) {
  1540. case 200:
  1541. $data = ObjectSerializer::deserialize(
  1542. $e->getResponseBody(),
  1543. '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response',
  1544. $e->getResponseHeaders()
  1545. );
  1546. $e->setResponseObject($data);
  1547. throw $e;
  1548. case 401:
  1549. $data = ObjectSerializer::deserialize(
  1550. $e->getResponseBody(),
  1551. '\WikipaliApi\Model\ProblemDetails',
  1552. $e->getResponseHeaders()
  1553. );
  1554. $e->setResponseObject($data);
  1555. throw $e;
  1556. case 422:
  1557. $data = ObjectSerializer::deserialize(
  1558. $e->getResponseBody(),
  1559. '\WikipaliApi\Model\ProblemDetails',
  1560. $e->getResponseHeaders()
  1561. );
  1562. $e->setResponseObject($data);
  1563. throw $e;
  1564. }
  1565. throw $e;
  1566. }
  1567. }
  1568. /**
  1569. * Operation getApiV3AdminAgentStatsAsync
  1570. *
  1571. * AI 对话统计
  1572. *
  1573. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1574. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1575. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1576. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1577. *
  1578. * @throws \InvalidArgumentException
  1579. * @return \GuzzleHttp\Promise\PromiseInterface
  1580. */
  1581. public function getApiV3AdminAgentStatsAsync($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1582. {
  1583. return $this->getApiV3AdminAgentStatsAsyncWithHttpInfo($from, $to, $account_type, $contentType)
  1584. ->then(
  1585. function ($response) {
  1586. return $response[0];
  1587. }
  1588. );
  1589. }
  1590. /**
  1591. * Operation getApiV3AdminAgentStatsAsyncWithHttpInfo
  1592. *
  1593. * AI 对话统计
  1594. *
  1595. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1596. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1597. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1598. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1599. *
  1600. * @throws \InvalidArgumentException
  1601. * @return \GuzzleHttp\Promise\PromiseInterface
  1602. */
  1603. public function getApiV3AdminAgentStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1604. {
  1605. $returnType = '\WikipaliApi\Model\GetApiV3AdminAgentStats200Response';
  1606. $request = $this->getApiV3AdminAgentStatsRequest($from, $to, $account_type, $contentType);
  1607. return $this->client
  1608. ->sendAsync($request, $this->createHttpClientOption())
  1609. ->then(
  1610. function ($response) use ($returnType) {
  1611. if ($returnType === '\SplFileObject') {
  1612. $content = $response->getBody(); //stream goes to serializer
  1613. } else {
  1614. $content = (string) $response->getBody();
  1615. if ($returnType !== 'string') {
  1616. $content = json_decode($content);
  1617. }
  1618. }
  1619. return [
  1620. ObjectSerializer::deserialize($content, $returnType, []),
  1621. $response->getStatusCode(),
  1622. $response->getHeaders()
  1623. ];
  1624. },
  1625. function ($exception) {
  1626. $response = $exception->getResponse();
  1627. $statusCode = $response->getStatusCode();
  1628. throw new ApiException(
  1629. sprintf(
  1630. '[%d] Error connecting to the API (%s)',
  1631. $statusCode,
  1632. $exception->getRequest()->getUri()
  1633. ),
  1634. $statusCode,
  1635. $response->getHeaders(),
  1636. (string) $response->getBody()
  1637. );
  1638. }
  1639. );
  1640. }
  1641. /**
  1642. * Create request for operation 'getApiV3AdminAgentStats'
  1643. *
  1644. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  1645. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  1646. * @param string|null $account_type 账号类型 (optional, default to 'all')
  1647. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminAgentStats'] to see the possible values for this operation
  1648. *
  1649. * @throws \InvalidArgumentException
  1650. * @return \GuzzleHttp\Psr7\Request
  1651. */
  1652. public function getApiV3AdminAgentStatsRequest($from = '今天往前 29 天', $to = '今天', $account_type = 'all', string $contentType = self::contentTypes['getApiV3AdminAgentStats'][0])
  1653. {
  1654. $resourcePath = '/v3/admin/agent-stats';
  1655. $formParams = [];
  1656. $queryParams = [];
  1657. $headerParams = [];
  1658. $httpBody = '';
  1659. $multipart = false;
  1660. // query params
  1661. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1662. $from,
  1663. 'from', // param base name
  1664. 'string', // openApiType
  1665. 'form', // style
  1666. true, // explode
  1667. false // required
  1668. ) ?? []);
  1669. // query params
  1670. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1671. $to,
  1672. 'to', // param base name
  1673. 'string', // openApiType
  1674. 'form', // style
  1675. true, // explode
  1676. false // required
  1677. ) ?? []);
  1678. // query params
  1679. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1680. $account_type,
  1681. 'account_type', // param base name
  1682. 'string', // openApiType
  1683. 'form', // style
  1684. true, // explode
  1685. false // required
  1686. ) ?? []);
  1687. $headers = $this->headerSelector->selectHeaders(
  1688. ['application/json', 'application/problem+json', ],
  1689. $contentType,
  1690. $multipart
  1691. );
  1692. // for model (json/xml)
  1693. if (count($formParams) > 0) {
  1694. if ($multipart) {
  1695. $multipartContents = [];
  1696. foreach ($formParams as $formParamName => $formParamValue) {
  1697. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  1698. foreach ($formParamValueItems as $formParamValueItem) {
  1699. $multipartContents[] = [
  1700. 'name' => $formParamName,
  1701. 'contents' => $formParamValueItem
  1702. ];
  1703. }
  1704. }
  1705. // for HTTP post (form)
  1706. $httpBody = new MultipartStream($multipartContents);
  1707. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  1708. # if Content-Type contains "application/json", json_encode the form parameters
  1709. try {
  1710. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  1711. } catch (\JsonException $e) {
  1712. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  1713. }
  1714. } else {
  1715. // for HTTP post (form)
  1716. $httpBody = ObjectSerializer::buildQuery($formParams);
  1717. }
  1718. }
  1719. // this endpoint requires Bearer authentication (access token)
  1720. if (!empty($this->config->getAccessToken())) {
  1721. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  1722. }
  1723. $defaultHeaders = [];
  1724. if ($this->config->getUserAgent()) {
  1725. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  1726. }
  1727. $headers = array_merge(
  1728. $defaultHeaders,
  1729. $headerParams,
  1730. $headers
  1731. );
  1732. $operationHost = $this->config->getHost();
  1733. $query = ObjectSerializer::buildQuery($queryParams);
  1734. return new Request(
  1735. 'GET',
  1736. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  1737. $headers,
  1738. $httpBody
  1739. );
  1740. }
  1741. /**
  1742. * Operation getApiV3AdminCreditAccounts
  1743. *
  1744. * 列出积分账号
  1745. *
  1746. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  1747. * @param string|null $filter_account_type 账号类型 (optional)
  1748. * @param string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
  1749. * @param int|null $page 页码 (optional, default to 1)
  1750. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
  1751. *
  1752. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1753. * @throws \InvalidArgumentException
  1754. * @return \WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  1755. */
  1756. public function getApiV3AdminCreditAccounts($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
  1757. {
  1758. list($response) = $this->getApiV3AdminCreditAccountsWithHttpInfo($per_page, $filter_account_type, $filter_q, $page, $contentType);
  1759. return $response;
  1760. }
  1761. /**
  1762. * Operation getApiV3AdminCreditAccountsWithHttpInfo
  1763. *
  1764. * 列出积分账号
  1765. *
  1766. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  1767. * @param string|null $filter_account_type 账号类型 (optional)
  1768. * @param string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
  1769. * @param int|null $page 页码 (optional, default to 1)
  1770. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
  1771. *
  1772. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  1773. * @throws \InvalidArgumentException
  1774. * @return array of \WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  1775. */
  1776. public function getApiV3AdminCreditAccountsWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
  1777. {
  1778. $request = $this->getApiV3AdminCreditAccountsRequest($per_page, $filter_account_type, $filter_q, $page, $contentType);
  1779. try {
  1780. $options = $this->createHttpClientOption();
  1781. try {
  1782. $response = $this->client->send($request, $options);
  1783. } catch (RequestException $e) {
  1784. throw new ApiException(
  1785. "[{$e->getCode()}] {$e->getMessage()}",
  1786. (int) $e->getCode(),
  1787. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  1788. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  1789. );
  1790. } catch (ConnectException $e) {
  1791. throw new ApiException(
  1792. "[{$e->getCode()}] {$e->getMessage()}",
  1793. (int) $e->getCode(),
  1794. null,
  1795. null
  1796. );
  1797. }
  1798. $statusCode = $response->getStatusCode();
  1799. switch($statusCode) {
  1800. case 200:
  1801. return $this->handleResponseWithDataType(
  1802. '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
  1803. $request,
  1804. $response,
  1805. );
  1806. case 401:
  1807. return $this->handleResponseWithDataType(
  1808. '\WikipaliApi\Model\ProblemDetails',
  1809. $request,
  1810. $response,
  1811. );
  1812. case 422:
  1813. return $this->handleResponseWithDataType(
  1814. '\WikipaliApi\Model\ProblemDetails',
  1815. $request,
  1816. $response,
  1817. );
  1818. }
  1819. if ($statusCode < 200 || $statusCode > 299) {
  1820. throw new ApiException(
  1821. sprintf(
  1822. '[%d] Error connecting to the API (%s)',
  1823. $statusCode,
  1824. (string) $request->getUri()
  1825. ),
  1826. $statusCode,
  1827. $response->getHeaders(),
  1828. (string) $response->getBody()
  1829. );
  1830. }
  1831. return $this->handleResponseWithDataType(
  1832. '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
  1833. $request,
  1834. $response,
  1835. );
  1836. } catch (ApiException $e) {
  1837. switch ($e->getCode()) {
  1838. case 200:
  1839. $data = ObjectSerializer::deserialize(
  1840. $e->getResponseBody(),
  1841. '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
  1842. $e->getResponseHeaders()
  1843. );
  1844. $e->setResponseObject($data);
  1845. throw $e;
  1846. case 401:
  1847. $data = ObjectSerializer::deserialize(
  1848. $e->getResponseBody(),
  1849. '\WikipaliApi\Model\ProblemDetails',
  1850. $e->getResponseHeaders()
  1851. );
  1852. $e->setResponseObject($data);
  1853. throw $e;
  1854. case 422:
  1855. $data = ObjectSerializer::deserialize(
  1856. $e->getResponseBody(),
  1857. '\WikipaliApi\Model\ProblemDetails',
  1858. $e->getResponseHeaders()
  1859. );
  1860. $e->setResponseObject($data);
  1861. throw $e;
  1862. }
  1863. throw $e;
  1864. }
  1865. }
  1866. /**
  1867. * Operation getApiV3AdminCreditAccountsAsync
  1868. *
  1869. * 列出积分账号
  1870. *
  1871. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  1872. * @param string|null $filter_account_type 账号类型 (optional)
  1873. * @param string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
  1874. * @param int|null $page 页码 (optional, default to 1)
  1875. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
  1876. *
  1877. * @throws \InvalidArgumentException
  1878. * @return \GuzzleHttp\Promise\PromiseInterface
  1879. */
  1880. public function getApiV3AdminCreditAccountsAsync($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
  1881. {
  1882. return $this->getApiV3AdminCreditAccountsAsyncWithHttpInfo($per_page, $filter_account_type, $filter_q, $page, $contentType)
  1883. ->then(
  1884. function ($response) {
  1885. return $response[0];
  1886. }
  1887. );
  1888. }
  1889. /**
  1890. * Operation getApiV3AdminCreditAccountsAsyncWithHttpInfo
  1891. *
  1892. * 列出积分账号
  1893. *
  1894. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  1895. * @param string|null $filter_account_type 账号类型 (optional)
  1896. * @param string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
  1897. * @param int|null $page 页码 (optional, default to 1)
  1898. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
  1899. *
  1900. * @throws \InvalidArgumentException
  1901. * @return \GuzzleHttp\Promise\PromiseInterface
  1902. */
  1903. public function getApiV3AdminCreditAccountsAsyncWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
  1904. {
  1905. $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response';
  1906. $request = $this->getApiV3AdminCreditAccountsRequest($per_page, $filter_account_type, $filter_q, $page, $contentType);
  1907. return $this->client
  1908. ->sendAsync($request, $this->createHttpClientOption())
  1909. ->then(
  1910. function ($response) use ($returnType) {
  1911. if ($returnType === '\SplFileObject') {
  1912. $content = $response->getBody(); //stream goes to serializer
  1913. } else {
  1914. $content = (string) $response->getBody();
  1915. if ($returnType !== 'string') {
  1916. $content = json_decode($content);
  1917. }
  1918. }
  1919. return [
  1920. ObjectSerializer::deserialize($content, $returnType, []),
  1921. $response->getStatusCode(),
  1922. $response->getHeaders()
  1923. ];
  1924. },
  1925. function ($exception) {
  1926. $response = $exception->getResponse();
  1927. $statusCode = $response->getStatusCode();
  1928. throw new ApiException(
  1929. sprintf(
  1930. '[%d] Error connecting to the API (%s)',
  1931. $statusCode,
  1932. $exception->getRequest()->getUri()
  1933. ),
  1934. $statusCode,
  1935. $response->getHeaders(),
  1936. (string) $response->getBody()
  1937. );
  1938. }
  1939. );
  1940. }
  1941. /**
  1942. * Create request for operation 'getApiV3AdminCreditAccounts'
  1943. *
  1944. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  1945. * @param string|null $filter_account_type 账号类型 (optional)
  1946. * @param string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
  1947. * @param int|null $page 页码 (optional, default to 1)
  1948. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
  1949. *
  1950. * @throws \InvalidArgumentException
  1951. * @return \GuzzleHttp\Psr7\Request
  1952. */
  1953. public function getApiV3AdminCreditAccountsRequest($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
  1954. {
  1955. $resourcePath = '/v3/admin/credit-accounts';
  1956. $formParams = [];
  1957. $queryParams = [];
  1958. $headerParams = [];
  1959. $httpBody = '';
  1960. $multipart = false;
  1961. // query params
  1962. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1963. $per_page,
  1964. 'per_page', // param base name
  1965. 'integer', // openApiType
  1966. 'form', // style
  1967. true, // explode
  1968. false // required
  1969. ) ?? []);
  1970. // query params
  1971. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1972. $filter_account_type,
  1973. 'filter[account_type]', // param base name
  1974. 'string', // openApiType
  1975. 'form', // style
  1976. true, // explode
  1977. false // required
  1978. ) ?? []);
  1979. // query params
  1980. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1981. $filter_q,
  1982. 'filter[q]', // param base name
  1983. 'string', // openApiType
  1984. 'form', // style
  1985. true, // explode
  1986. false // required
  1987. ) ?? []);
  1988. // query params
  1989. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  1990. $page,
  1991. 'page', // param base name
  1992. 'integer', // openApiType
  1993. 'form', // style
  1994. true, // explode
  1995. false // required
  1996. ) ?? []);
  1997. $headers = $this->headerSelector->selectHeaders(
  1998. ['application/json', 'application/problem+json', ],
  1999. $contentType,
  2000. $multipart
  2001. );
  2002. // for model (json/xml)
  2003. if (count($formParams) > 0) {
  2004. if ($multipart) {
  2005. $multipartContents = [];
  2006. foreach ($formParams as $formParamName => $formParamValue) {
  2007. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  2008. foreach ($formParamValueItems as $formParamValueItem) {
  2009. $multipartContents[] = [
  2010. 'name' => $formParamName,
  2011. 'contents' => $formParamValueItem
  2012. ];
  2013. }
  2014. }
  2015. // for HTTP post (form)
  2016. $httpBody = new MultipartStream($multipartContents);
  2017. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  2018. # if Content-Type contains "application/json", json_encode the form parameters
  2019. try {
  2020. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  2021. } catch (\JsonException $e) {
  2022. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  2023. }
  2024. } else {
  2025. // for HTTP post (form)
  2026. $httpBody = ObjectSerializer::buildQuery($formParams);
  2027. }
  2028. }
  2029. // this endpoint requires Bearer authentication (access token)
  2030. if (!empty($this->config->getAccessToken())) {
  2031. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  2032. }
  2033. $defaultHeaders = [];
  2034. if ($this->config->getUserAgent()) {
  2035. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  2036. }
  2037. $headers = array_merge(
  2038. $defaultHeaders,
  2039. $headerParams,
  2040. $headers
  2041. );
  2042. $operationHost = $this->config->getHost();
  2043. $query = ObjectSerializer::buildQuery($queryParams);
  2044. return new Request(
  2045. 'GET',
  2046. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  2047. $headers,
  2048. $httpBody
  2049. );
  2050. }
  2051. /**
  2052. * Operation getApiV3AdminCreditLedger
  2053. *
  2054. * 列出积分流水
  2055. *
  2056. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  2057. * @param string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
  2058. * @param string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
  2059. * @param string|null $filter_kind 流水类型 (optional)
  2060. * @param string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
  2061. * @param string|null $filter_source 来源 (optional)
  2062. * @param string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
  2063. * @param string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
  2064. * @param int|null $page 页码 (optional, default to 1)
  2065. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
  2066. *
  2067. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2068. * @throws \InvalidArgumentException
  2069. * @return \WikipaliApi\Model\GetApiV3AdminCreditLedger200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  2070. */
  2071. public function getApiV3AdminCreditLedger($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
  2072. {
  2073. list($response) = $this->getApiV3AdminCreditLedgerWithHttpInfo($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
  2074. return $response;
  2075. }
  2076. /**
  2077. * Operation getApiV3AdminCreditLedgerWithHttpInfo
  2078. *
  2079. * 列出积分流水
  2080. *
  2081. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  2082. * @param string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
  2083. * @param string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
  2084. * @param string|null $filter_kind 流水类型 (optional)
  2085. * @param string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
  2086. * @param string|null $filter_source 来源 (optional)
  2087. * @param string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
  2088. * @param string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
  2089. * @param int|null $page 页码 (optional, default to 1)
  2090. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
  2091. *
  2092. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2093. * @throws \InvalidArgumentException
  2094. * @return array of \WikipaliApi\Model\GetApiV3AdminCreditLedger200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  2095. */
  2096. public function getApiV3AdminCreditLedgerWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
  2097. {
  2098. $request = $this->getApiV3AdminCreditLedgerRequest($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
  2099. try {
  2100. $options = $this->createHttpClientOption();
  2101. try {
  2102. $response = $this->client->send($request, $options);
  2103. } catch (RequestException $e) {
  2104. throw new ApiException(
  2105. "[{$e->getCode()}] {$e->getMessage()}",
  2106. (int) $e->getCode(),
  2107. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  2108. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  2109. );
  2110. } catch (ConnectException $e) {
  2111. throw new ApiException(
  2112. "[{$e->getCode()}] {$e->getMessage()}",
  2113. (int) $e->getCode(),
  2114. null,
  2115. null
  2116. );
  2117. }
  2118. $statusCode = $response->getStatusCode();
  2119. switch($statusCode) {
  2120. case 200:
  2121. return $this->handleResponseWithDataType(
  2122. '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
  2123. $request,
  2124. $response,
  2125. );
  2126. case 401:
  2127. return $this->handleResponseWithDataType(
  2128. '\WikipaliApi\Model\ProblemDetails',
  2129. $request,
  2130. $response,
  2131. );
  2132. case 422:
  2133. return $this->handleResponseWithDataType(
  2134. '\WikipaliApi\Model\ProblemDetails',
  2135. $request,
  2136. $response,
  2137. );
  2138. }
  2139. if ($statusCode < 200 || $statusCode > 299) {
  2140. throw new ApiException(
  2141. sprintf(
  2142. '[%d] Error connecting to the API (%s)',
  2143. $statusCode,
  2144. (string) $request->getUri()
  2145. ),
  2146. $statusCode,
  2147. $response->getHeaders(),
  2148. (string) $response->getBody()
  2149. );
  2150. }
  2151. return $this->handleResponseWithDataType(
  2152. '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
  2153. $request,
  2154. $response,
  2155. );
  2156. } catch (ApiException $e) {
  2157. switch ($e->getCode()) {
  2158. case 200:
  2159. $data = ObjectSerializer::deserialize(
  2160. $e->getResponseBody(),
  2161. '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
  2162. $e->getResponseHeaders()
  2163. );
  2164. $e->setResponseObject($data);
  2165. throw $e;
  2166. case 401:
  2167. $data = ObjectSerializer::deserialize(
  2168. $e->getResponseBody(),
  2169. '\WikipaliApi\Model\ProblemDetails',
  2170. $e->getResponseHeaders()
  2171. );
  2172. $e->setResponseObject($data);
  2173. throw $e;
  2174. case 422:
  2175. $data = ObjectSerializer::deserialize(
  2176. $e->getResponseBody(),
  2177. '\WikipaliApi\Model\ProblemDetails',
  2178. $e->getResponseHeaders()
  2179. );
  2180. $e->setResponseObject($data);
  2181. throw $e;
  2182. }
  2183. throw $e;
  2184. }
  2185. }
  2186. /**
  2187. * Operation getApiV3AdminCreditLedgerAsync
  2188. *
  2189. * 列出积分流水
  2190. *
  2191. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  2192. * @param string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
  2193. * @param string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
  2194. * @param string|null $filter_kind 流水类型 (optional)
  2195. * @param string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
  2196. * @param string|null $filter_source 来源 (optional)
  2197. * @param string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
  2198. * @param string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
  2199. * @param int|null $page 页码 (optional, default to 1)
  2200. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
  2201. *
  2202. * @throws \InvalidArgumentException
  2203. * @return \GuzzleHttp\Promise\PromiseInterface
  2204. */
  2205. public function getApiV3AdminCreditLedgerAsync($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
  2206. {
  2207. return $this->getApiV3AdminCreditLedgerAsyncWithHttpInfo($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType)
  2208. ->then(
  2209. function ($response) {
  2210. return $response[0];
  2211. }
  2212. );
  2213. }
  2214. /**
  2215. * Operation getApiV3AdminCreditLedgerAsyncWithHttpInfo
  2216. *
  2217. * 列出积分流水
  2218. *
  2219. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  2220. * @param string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
  2221. * @param string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
  2222. * @param string|null $filter_kind 流水类型 (optional)
  2223. * @param string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
  2224. * @param string|null $filter_source 来源 (optional)
  2225. * @param string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
  2226. * @param string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
  2227. * @param int|null $page 页码 (optional, default to 1)
  2228. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
  2229. *
  2230. * @throws \InvalidArgumentException
  2231. * @return \GuzzleHttp\Promise\PromiseInterface
  2232. */
  2233. public function getApiV3AdminCreditLedgerAsyncWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
  2234. {
  2235. $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response';
  2236. $request = $this->getApiV3AdminCreditLedgerRequest($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
  2237. return $this->client
  2238. ->sendAsync($request, $this->createHttpClientOption())
  2239. ->then(
  2240. function ($response) use ($returnType) {
  2241. if ($returnType === '\SplFileObject') {
  2242. $content = $response->getBody(); //stream goes to serializer
  2243. } else {
  2244. $content = (string) $response->getBody();
  2245. if ($returnType !== 'string') {
  2246. $content = json_decode($content);
  2247. }
  2248. }
  2249. return [
  2250. ObjectSerializer::deserialize($content, $returnType, []),
  2251. $response->getStatusCode(),
  2252. $response->getHeaders()
  2253. ];
  2254. },
  2255. function ($exception) {
  2256. $response = $exception->getResponse();
  2257. $statusCode = $response->getStatusCode();
  2258. throw new ApiException(
  2259. sprintf(
  2260. '[%d] Error connecting to the API (%s)',
  2261. $statusCode,
  2262. $exception->getRequest()->getUri()
  2263. ),
  2264. $statusCode,
  2265. $response->getHeaders(),
  2266. (string) $response->getBody()
  2267. );
  2268. }
  2269. );
  2270. }
  2271. /**
  2272. * Create request for operation 'getApiV3AdminCreditLedger'
  2273. *
  2274. * @param int|null $per_page 每页数量,最大 100 (optional, default to 20)
  2275. * @param string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
  2276. * @param string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
  2277. * @param string|null $filter_kind 流水类型 (optional)
  2278. * @param string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
  2279. * @param string|null $filter_source 来源 (optional)
  2280. * @param string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
  2281. * @param string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
  2282. * @param int|null $page 页码 (optional, default to 1)
  2283. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
  2284. *
  2285. * @throws \InvalidArgumentException
  2286. * @return \GuzzleHttp\Psr7\Request
  2287. */
  2288. public function getApiV3AdminCreditLedgerRequest($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
  2289. {
  2290. $resourcePath = '/v3/admin/credit-ledger';
  2291. $formParams = [];
  2292. $queryParams = [];
  2293. $headerParams = [];
  2294. $httpBody = '';
  2295. $multipart = false;
  2296. // query params
  2297. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2298. $per_page,
  2299. 'per_page', // param base name
  2300. 'integer', // openApiType
  2301. 'form', // style
  2302. true, // explode
  2303. false // required
  2304. ) ?? []);
  2305. // query params
  2306. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2307. $filter_account_type,
  2308. 'filter[account_type]', // param base name
  2309. 'string', // openApiType
  2310. 'form', // style
  2311. true, // explode
  2312. false // required
  2313. ) ?? []);
  2314. // query params
  2315. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2316. $filter_account_id,
  2317. 'filter[account_id]', // param base name
  2318. 'string', // openApiType
  2319. 'form', // style
  2320. true, // explode
  2321. false // required
  2322. ) ?? []);
  2323. // query params
  2324. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2325. $filter_kind,
  2326. 'filter[kind]', // param base name
  2327. 'string', // openApiType
  2328. 'form', // style
  2329. true, // explode
  2330. false // required
  2331. ) ?? []);
  2332. // query params
  2333. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2334. $filter_bucket,
  2335. 'filter[bucket]', // param base name
  2336. 'string', // openApiType
  2337. 'form', // style
  2338. true, // explode
  2339. false // required
  2340. ) ?? []);
  2341. // query params
  2342. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2343. $filter_source,
  2344. 'filter[source]', // param base name
  2345. 'string', // openApiType
  2346. 'form', // style
  2347. true, // explode
  2348. false // required
  2349. ) ?? []);
  2350. // query params
  2351. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2352. $filter_from,
  2353. 'filter[from]', // param base name
  2354. 'string', // openApiType
  2355. 'form', // style
  2356. true, // explode
  2357. false // required
  2358. ) ?? []);
  2359. // query params
  2360. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2361. $filter_to,
  2362. 'filter[to]', // param base name
  2363. 'string', // openApiType
  2364. 'form', // style
  2365. true, // explode
  2366. false // required
  2367. ) ?? []);
  2368. // query params
  2369. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2370. $page,
  2371. 'page', // param base name
  2372. 'integer', // openApiType
  2373. 'form', // style
  2374. true, // explode
  2375. false // required
  2376. ) ?? []);
  2377. $headers = $this->headerSelector->selectHeaders(
  2378. ['application/json', 'application/problem+json', ],
  2379. $contentType,
  2380. $multipart
  2381. );
  2382. // for model (json/xml)
  2383. if (count($formParams) > 0) {
  2384. if ($multipart) {
  2385. $multipartContents = [];
  2386. foreach ($formParams as $formParamName => $formParamValue) {
  2387. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  2388. foreach ($formParamValueItems as $formParamValueItem) {
  2389. $multipartContents[] = [
  2390. 'name' => $formParamName,
  2391. 'contents' => $formParamValueItem
  2392. ];
  2393. }
  2394. }
  2395. // for HTTP post (form)
  2396. $httpBody = new MultipartStream($multipartContents);
  2397. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  2398. # if Content-Type contains "application/json", json_encode the form parameters
  2399. try {
  2400. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  2401. } catch (\JsonException $e) {
  2402. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  2403. }
  2404. } else {
  2405. // for HTTP post (form)
  2406. $httpBody = ObjectSerializer::buildQuery($formParams);
  2407. }
  2408. }
  2409. // this endpoint requires Bearer authentication (access token)
  2410. if (!empty($this->config->getAccessToken())) {
  2411. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  2412. }
  2413. $defaultHeaders = [];
  2414. if ($this->config->getUserAgent()) {
  2415. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  2416. }
  2417. $headers = array_merge(
  2418. $defaultHeaders,
  2419. $headerParams,
  2420. $headers
  2421. );
  2422. $operationHost = $this->config->getHost();
  2423. $query = ObjectSerializer::buildQuery($queryParams);
  2424. return new Request(
  2425. 'GET',
  2426. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  2427. $headers,
  2428. $httpBody
  2429. );
  2430. }
  2431. /**
  2432. * Operation getApiV3AdminCreditOverview
  2433. *
  2434. * 积分概览
  2435. *
  2436. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
  2437. *
  2438. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2439. * @throws \InvalidArgumentException
  2440. * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200Response|\WikipaliApi\Model\ProblemDetails
  2441. */
  2442. public function getApiV3AdminCreditOverview(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
  2443. {
  2444. list($response) = $this->getApiV3AdminCreditOverviewWithHttpInfo($contentType);
  2445. return $response;
  2446. }
  2447. /**
  2448. * Operation getApiV3AdminCreditOverviewWithHttpInfo
  2449. *
  2450. * 积分概览
  2451. *
  2452. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
  2453. *
  2454. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2455. * @throws \InvalidArgumentException
  2456. * @return array of \WikipaliApi\Model\GetApiV3AdminCreditOverview200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  2457. */
  2458. public function getApiV3AdminCreditOverviewWithHttpInfo(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
  2459. {
  2460. $request = $this->getApiV3AdminCreditOverviewRequest($contentType);
  2461. try {
  2462. $options = $this->createHttpClientOption();
  2463. try {
  2464. $response = $this->client->send($request, $options);
  2465. } catch (RequestException $e) {
  2466. throw new ApiException(
  2467. "[{$e->getCode()}] {$e->getMessage()}",
  2468. (int) $e->getCode(),
  2469. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  2470. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  2471. );
  2472. } catch (ConnectException $e) {
  2473. throw new ApiException(
  2474. "[{$e->getCode()}] {$e->getMessage()}",
  2475. (int) $e->getCode(),
  2476. null,
  2477. null
  2478. );
  2479. }
  2480. $statusCode = $response->getStatusCode();
  2481. switch($statusCode) {
  2482. case 200:
  2483. return $this->handleResponseWithDataType(
  2484. '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
  2485. $request,
  2486. $response,
  2487. );
  2488. case 401:
  2489. return $this->handleResponseWithDataType(
  2490. '\WikipaliApi\Model\ProblemDetails',
  2491. $request,
  2492. $response,
  2493. );
  2494. }
  2495. if ($statusCode < 200 || $statusCode > 299) {
  2496. throw new ApiException(
  2497. sprintf(
  2498. '[%d] Error connecting to the API (%s)',
  2499. $statusCode,
  2500. (string) $request->getUri()
  2501. ),
  2502. $statusCode,
  2503. $response->getHeaders(),
  2504. (string) $response->getBody()
  2505. );
  2506. }
  2507. return $this->handleResponseWithDataType(
  2508. '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
  2509. $request,
  2510. $response,
  2511. );
  2512. } catch (ApiException $e) {
  2513. switch ($e->getCode()) {
  2514. case 200:
  2515. $data = ObjectSerializer::deserialize(
  2516. $e->getResponseBody(),
  2517. '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
  2518. $e->getResponseHeaders()
  2519. );
  2520. $e->setResponseObject($data);
  2521. throw $e;
  2522. case 401:
  2523. $data = ObjectSerializer::deserialize(
  2524. $e->getResponseBody(),
  2525. '\WikipaliApi\Model\ProblemDetails',
  2526. $e->getResponseHeaders()
  2527. );
  2528. $e->setResponseObject($data);
  2529. throw $e;
  2530. }
  2531. throw $e;
  2532. }
  2533. }
  2534. /**
  2535. * Operation getApiV3AdminCreditOverviewAsync
  2536. *
  2537. * 积分概览
  2538. *
  2539. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
  2540. *
  2541. * @throws \InvalidArgumentException
  2542. * @return \GuzzleHttp\Promise\PromiseInterface
  2543. */
  2544. public function getApiV3AdminCreditOverviewAsync(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
  2545. {
  2546. return $this->getApiV3AdminCreditOverviewAsyncWithHttpInfo($contentType)
  2547. ->then(
  2548. function ($response) {
  2549. return $response[0];
  2550. }
  2551. );
  2552. }
  2553. /**
  2554. * Operation getApiV3AdminCreditOverviewAsyncWithHttpInfo
  2555. *
  2556. * 积分概览
  2557. *
  2558. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
  2559. *
  2560. * @throws \InvalidArgumentException
  2561. * @return \GuzzleHttp\Promise\PromiseInterface
  2562. */
  2563. public function getApiV3AdminCreditOverviewAsyncWithHttpInfo(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
  2564. {
  2565. $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response';
  2566. $request = $this->getApiV3AdminCreditOverviewRequest($contentType);
  2567. return $this->client
  2568. ->sendAsync($request, $this->createHttpClientOption())
  2569. ->then(
  2570. function ($response) use ($returnType) {
  2571. if ($returnType === '\SplFileObject') {
  2572. $content = $response->getBody(); //stream goes to serializer
  2573. } else {
  2574. $content = (string) $response->getBody();
  2575. if ($returnType !== 'string') {
  2576. $content = json_decode($content);
  2577. }
  2578. }
  2579. return [
  2580. ObjectSerializer::deserialize($content, $returnType, []),
  2581. $response->getStatusCode(),
  2582. $response->getHeaders()
  2583. ];
  2584. },
  2585. function ($exception) {
  2586. $response = $exception->getResponse();
  2587. $statusCode = $response->getStatusCode();
  2588. throw new ApiException(
  2589. sprintf(
  2590. '[%d] Error connecting to the API (%s)',
  2591. $statusCode,
  2592. $exception->getRequest()->getUri()
  2593. ),
  2594. $statusCode,
  2595. $response->getHeaders(),
  2596. (string) $response->getBody()
  2597. );
  2598. }
  2599. );
  2600. }
  2601. /**
  2602. * Create request for operation 'getApiV3AdminCreditOverview'
  2603. *
  2604. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
  2605. *
  2606. * @throws \InvalidArgumentException
  2607. * @return \GuzzleHttp\Psr7\Request
  2608. */
  2609. public function getApiV3AdminCreditOverviewRequest(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
  2610. {
  2611. $resourcePath = '/v3/admin/credit-overview';
  2612. $formParams = [];
  2613. $queryParams = [];
  2614. $headerParams = [];
  2615. $httpBody = '';
  2616. $multipart = false;
  2617. $headers = $this->headerSelector->selectHeaders(
  2618. ['application/json', 'application/problem+json', ],
  2619. $contentType,
  2620. $multipart
  2621. );
  2622. // for model (json/xml)
  2623. if (count($formParams) > 0) {
  2624. if ($multipart) {
  2625. $multipartContents = [];
  2626. foreach ($formParams as $formParamName => $formParamValue) {
  2627. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  2628. foreach ($formParamValueItems as $formParamValueItem) {
  2629. $multipartContents[] = [
  2630. 'name' => $formParamName,
  2631. 'contents' => $formParamValueItem
  2632. ];
  2633. }
  2634. }
  2635. // for HTTP post (form)
  2636. $httpBody = new MultipartStream($multipartContents);
  2637. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  2638. # if Content-Type contains "application/json", json_encode the form parameters
  2639. try {
  2640. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  2641. } catch (\JsonException $e) {
  2642. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  2643. }
  2644. } else {
  2645. // for HTTP post (form)
  2646. $httpBody = ObjectSerializer::buildQuery($formParams);
  2647. }
  2648. }
  2649. // this endpoint requires Bearer authentication (access token)
  2650. if (!empty($this->config->getAccessToken())) {
  2651. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  2652. }
  2653. $defaultHeaders = [];
  2654. if ($this->config->getUserAgent()) {
  2655. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  2656. }
  2657. $headers = array_merge(
  2658. $defaultHeaders,
  2659. $headerParams,
  2660. $headers
  2661. );
  2662. $operationHost = $this->config->getHost();
  2663. $query = ObjectSerializer::buildQuery($queryParams);
  2664. return new Request(
  2665. 'GET',
  2666. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  2667. $headers,
  2668. $httpBody
  2669. );
  2670. }
  2671. /**
  2672. * Operation getApiV3AdminReadingStats
  2673. *
  2674. * 阅读统计
  2675. *
  2676. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  2677. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  2678. * @param string|null $client 客户端 (optional, default to 'all')
  2679. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  2680. *
  2681. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2682. * @throws \InvalidArgumentException
  2683. * @return \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  2684. */
  2685. public function getApiV3AdminReadingStats($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  2686. {
  2687. list($response) = $this->getApiV3AdminReadingStatsWithHttpInfo($from, $to, $client, $contentType);
  2688. return $response;
  2689. }
  2690. /**
  2691. * Operation getApiV3AdminReadingStatsWithHttpInfo
  2692. *
  2693. * 阅读统计
  2694. *
  2695. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  2696. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  2697. * @param string|null $client 客户端 (optional, default to 'all')
  2698. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  2699. *
  2700. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2701. * @throws \InvalidArgumentException
  2702. * @return array of \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  2703. */
  2704. public function getApiV3AdminReadingStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  2705. {
  2706. $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
  2707. try {
  2708. $options = $this->createHttpClientOption();
  2709. try {
  2710. $response = $this->client->send($request, $options);
  2711. } catch (RequestException $e) {
  2712. throw new ApiException(
  2713. "[{$e->getCode()}] {$e->getMessage()}",
  2714. (int) $e->getCode(),
  2715. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  2716. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  2717. );
  2718. } catch (ConnectException $e) {
  2719. throw new ApiException(
  2720. "[{$e->getCode()}] {$e->getMessage()}",
  2721. (int) $e->getCode(),
  2722. null,
  2723. null
  2724. );
  2725. }
  2726. $statusCode = $response->getStatusCode();
  2727. switch($statusCode) {
  2728. case 200:
  2729. return $this->handleResponseWithDataType(
  2730. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  2731. $request,
  2732. $response,
  2733. );
  2734. case 401:
  2735. return $this->handleResponseWithDataType(
  2736. '\WikipaliApi\Model\ProblemDetails',
  2737. $request,
  2738. $response,
  2739. );
  2740. case 422:
  2741. return $this->handleResponseWithDataType(
  2742. '\WikipaliApi\Model\ProblemDetails',
  2743. $request,
  2744. $response,
  2745. );
  2746. }
  2747. if ($statusCode < 200 || $statusCode > 299) {
  2748. throw new ApiException(
  2749. sprintf(
  2750. '[%d] Error connecting to the API (%s)',
  2751. $statusCode,
  2752. (string) $request->getUri()
  2753. ),
  2754. $statusCode,
  2755. $response->getHeaders(),
  2756. (string) $response->getBody()
  2757. );
  2758. }
  2759. return $this->handleResponseWithDataType(
  2760. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  2761. $request,
  2762. $response,
  2763. );
  2764. } catch (ApiException $e) {
  2765. switch ($e->getCode()) {
  2766. case 200:
  2767. $data = ObjectSerializer::deserialize(
  2768. $e->getResponseBody(),
  2769. '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
  2770. $e->getResponseHeaders()
  2771. );
  2772. $e->setResponseObject($data);
  2773. throw $e;
  2774. case 401:
  2775. $data = ObjectSerializer::deserialize(
  2776. $e->getResponseBody(),
  2777. '\WikipaliApi\Model\ProblemDetails',
  2778. $e->getResponseHeaders()
  2779. );
  2780. $e->setResponseObject($data);
  2781. throw $e;
  2782. case 422:
  2783. $data = ObjectSerializer::deserialize(
  2784. $e->getResponseBody(),
  2785. '\WikipaliApi\Model\ProblemDetails',
  2786. $e->getResponseHeaders()
  2787. );
  2788. $e->setResponseObject($data);
  2789. throw $e;
  2790. }
  2791. throw $e;
  2792. }
  2793. }
  2794. /**
  2795. * Operation getApiV3AdminReadingStatsAsync
  2796. *
  2797. * 阅读统计
  2798. *
  2799. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  2800. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  2801. * @param string|null $client 客户端 (optional, default to 'all')
  2802. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  2803. *
  2804. * @throws \InvalidArgumentException
  2805. * @return \GuzzleHttp\Promise\PromiseInterface
  2806. */
  2807. public function getApiV3AdminReadingStatsAsync($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  2808. {
  2809. return $this->getApiV3AdminReadingStatsAsyncWithHttpInfo($from, $to, $client, $contentType)
  2810. ->then(
  2811. function ($response) {
  2812. return $response[0];
  2813. }
  2814. );
  2815. }
  2816. /**
  2817. * Operation getApiV3AdminReadingStatsAsyncWithHttpInfo
  2818. *
  2819. * 阅读统计
  2820. *
  2821. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  2822. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  2823. * @param string|null $client 客户端 (optional, default to 'all')
  2824. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  2825. *
  2826. * @throws \InvalidArgumentException
  2827. * @return \GuzzleHttp\Promise\PromiseInterface
  2828. */
  2829. public function getApiV3AdminReadingStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  2830. {
  2831. $returnType = '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response';
  2832. $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
  2833. return $this->client
  2834. ->sendAsync($request, $this->createHttpClientOption())
  2835. ->then(
  2836. function ($response) use ($returnType) {
  2837. if ($returnType === '\SplFileObject') {
  2838. $content = $response->getBody(); //stream goes to serializer
  2839. } else {
  2840. $content = (string) $response->getBody();
  2841. if ($returnType !== 'string') {
  2842. $content = json_decode($content);
  2843. }
  2844. }
  2845. return [
  2846. ObjectSerializer::deserialize($content, $returnType, []),
  2847. $response->getStatusCode(),
  2848. $response->getHeaders()
  2849. ];
  2850. },
  2851. function ($exception) {
  2852. $response = $exception->getResponse();
  2853. $statusCode = $response->getStatusCode();
  2854. throw new ApiException(
  2855. sprintf(
  2856. '[%d] Error connecting to the API (%s)',
  2857. $statusCode,
  2858. $exception->getRequest()->getUri()
  2859. ),
  2860. $statusCode,
  2861. $response->getHeaders(),
  2862. (string) $response->getBody()
  2863. );
  2864. }
  2865. );
  2866. }
  2867. /**
  2868. * Create request for operation 'getApiV3AdminReadingStats'
  2869. *
  2870. * @param string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
  2871. * @param string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
  2872. * @param string|null $client 客户端 (optional, default to 'all')
  2873. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
  2874. *
  2875. * @throws \InvalidArgumentException
  2876. * @return \GuzzleHttp\Psr7\Request
  2877. */
  2878. public function getApiV3AdminReadingStatsRequest($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
  2879. {
  2880. $resourcePath = '/v3/admin/reading-stats';
  2881. $formParams = [];
  2882. $queryParams = [];
  2883. $headerParams = [];
  2884. $httpBody = '';
  2885. $multipart = false;
  2886. // query params
  2887. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2888. $from,
  2889. 'from', // param base name
  2890. 'string', // openApiType
  2891. 'form', // style
  2892. true, // explode
  2893. false // required
  2894. ) ?? []);
  2895. // query params
  2896. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2897. $to,
  2898. 'to', // param base name
  2899. 'string', // openApiType
  2900. 'form', // style
  2901. true, // explode
  2902. false // required
  2903. ) ?? []);
  2904. // query params
  2905. $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
  2906. $client,
  2907. 'client', // param base name
  2908. 'string', // openApiType
  2909. 'form', // style
  2910. true, // explode
  2911. false // required
  2912. ) ?? []);
  2913. $headers = $this->headerSelector->selectHeaders(
  2914. ['application/json', 'application/problem+json', ],
  2915. $contentType,
  2916. $multipart
  2917. );
  2918. // for model (json/xml)
  2919. if (count($formParams) > 0) {
  2920. if ($multipart) {
  2921. $multipartContents = [];
  2922. foreach ($formParams as $formParamName => $formParamValue) {
  2923. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  2924. foreach ($formParamValueItems as $formParamValueItem) {
  2925. $multipartContents[] = [
  2926. 'name' => $formParamName,
  2927. 'contents' => $formParamValueItem
  2928. ];
  2929. }
  2930. }
  2931. // for HTTP post (form)
  2932. $httpBody = new MultipartStream($multipartContents);
  2933. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  2934. # if Content-Type contains "application/json", json_encode the form parameters
  2935. try {
  2936. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  2937. } catch (\JsonException $e) {
  2938. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  2939. }
  2940. } else {
  2941. // for HTTP post (form)
  2942. $httpBody = ObjectSerializer::buildQuery($formParams);
  2943. }
  2944. }
  2945. // this endpoint requires Bearer authentication (access token)
  2946. if (!empty($this->config->getAccessToken())) {
  2947. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  2948. }
  2949. $defaultHeaders = [];
  2950. if ($this->config->getUserAgent()) {
  2951. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  2952. }
  2953. $headers = array_merge(
  2954. $defaultHeaders,
  2955. $headerParams,
  2956. $headers
  2957. );
  2958. $operationHost = $this->config->getHost();
  2959. $query = ObjectSerializer::buildQuery($queryParams);
  2960. return new Request(
  2961. 'GET',
  2962. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  2963. $headers,
  2964. $httpBody
  2965. );
  2966. }
  2967. /**
  2968. * Operation postApiV3AdminCreditAdjustments
  2969. *
  2970. * 手工加减积分
  2971. *
  2972. * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request post_api_v3_admin_credit_adjustments_request (required)
  2973. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
  2974. *
  2975. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2976. * @throws \InvalidArgumentException
  2977. * @return \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  2978. */
  2979. public function postApiV3AdminCreditAdjustments($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
  2980. {
  2981. list($response) = $this->postApiV3AdminCreditAdjustmentsWithHttpInfo($post_api_v3_admin_credit_adjustments_request, $contentType);
  2982. return $response;
  2983. }
  2984. /**
  2985. * Operation postApiV3AdminCreditAdjustmentsWithHttpInfo
  2986. *
  2987. * 手工加减积分
  2988. *
  2989. * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
  2990. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
  2991. *
  2992. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  2993. * @throws \InvalidArgumentException
  2994. * @return array of \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  2995. */
  2996. public function postApiV3AdminCreditAdjustmentsWithHttpInfo($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
  2997. {
  2998. $request = $this->postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, $contentType);
  2999. try {
  3000. $options = $this->createHttpClientOption();
  3001. try {
  3002. $response = $this->client->send($request, $options);
  3003. } catch (RequestException $e) {
  3004. throw new ApiException(
  3005. "[{$e->getCode()}] {$e->getMessage()}",
  3006. (int) $e->getCode(),
  3007. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  3008. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  3009. );
  3010. } catch (ConnectException $e) {
  3011. throw new ApiException(
  3012. "[{$e->getCode()}] {$e->getMessage()}",
  3013. (int) $e->getCode(),
  3014. null,
  3015. null
  3016. );
  3017. }
  3018. $statusCode = $response->getStatusCode();
  3019. switch($statusCode) {
  3020. case 200:
  3021. return $this->handleResponseWithDataType(
  3022. '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
  3023. $request,
  3024. $response,
  3025. );
  3026. case 201:
  3027. return $this->handleResponseWithDataType(
  3028. '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
  3029. $request,
  3030. $response,
  3031. );
  3032. case 401:
  3033. return $this->handleResponseWithDataType(
  3034. '\WikipaliApi\Model\ProblemDetails',
  3035. $request,
  3036. $response,
  3037. );
  3038. case 422:
  3039. return $this->handleResponseWithDataType(
  3040. '\WikipaliApi\Model\ProblemDetails',
  3041. $request,
  3042. $response,
  3043. );
  3044. }
  3045. if ($statusCode < 200 || $statusCode > 299) {
  3046. throw new ApiException(
  3047. sprintf(
  3048. '[%d] Error connecting to the API (%s)',
  3049. $statusCode,
  3050. (string) $request->getUri()
  3051. ),
  3052. $statusCode,
  3053. $response->getHeaders(),
  3054. (string) $response->getBody()
  3055. );
  3056. }
  3057. return $this->handleResponseWithDataType(
  3058. '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
  3059. $request,
  3060. $response,
  3061. );
  3062. } catch (ApiException $e) {
  3063. switch ($e->getCode()) {
  3064. case 200:
  3065. $data = ObjectSerializer::deserialize(
  3066. $e->getResponseBody(),
  3067. '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
  3068. $e->getResponseHeaders()
  3069. );
  3070. $e->setResponseObject($data);
  3071. throw $e;
  3072. case 201:
  3073. $data = ObjectSerializer::deserialize(
  3074. $e->getResponseBody(),
  3075. '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
  3076. $e->getResponseHeaders()
  3077. );
  3078. $e->setResponseObject($data);
  3079. throw $e;
  3080. case 401:
  3081. $data = ObjectSerializer::deserialize(
  3082. $e->getResponseBody(),
  3083. '\WikipaliApi\Model\ProblemDetails',
  3084. $e->getResponseHeaders()
  3085. );
  3086. $e->setResponseObject($data);
  3087. throw $e;
  3088. case 422:
  3089. $data = ObjectSerializer::deserialize(
  3090. $e->getResponseBody(),
  3091. '\WikipaliApi\Model\ProblemDetails',
  3092. $e->getResponseHeaders()
  3093. );
  3094. $e->setResponseObject($data);
  3095. throw $e;
  3096. }
  3097. throw $e;
  3098. }
  3099. }
  3100. /**
  3101. * Operation postApiV3AdminCreditAdjustmentsAsync
  3102. *
  3103. * 手工加减积分
  3104. *
  3105. * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
  3106. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
  3107. *
  3108. * @throws \InvalidArgumentException
  3109. * @return \GuzzleHttp\Promise\PromiseInterface
  3110. */
  3111. public function postApiV3AdminCreditAdjustmentsAsync($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
  3112. {
  3113. return $this->postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo($post_api_v3_admin_credit_adjustments_request, $contentType)
  3114. ->then(
  3115. function ($response) {
  3116. return $response[0];
  3117. }
  3118. );
  3119. }
  3120. /**
  3121. * Operation postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo
  3122. *
  3123. * 手工加减积分
  3124. *
  3125. * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
  3126. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
  3127. *
  3128. * @throws \InvalidArgumentException
  3129. * @return \GuzzleHttp\Promise\PromiseInterface
  3130. */
  3131. public function postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
  3132. {
  3133. $returnType = '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response';
  3134. $request = $this->postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, $contentType);
  3135. return $this->client
  3136. ->sendAsync($request, $this->createHttpClientOption())
  3137. ->then(
  3138. function ($response) use ($returnType) {
  3139. if ($returnType === '\SplFileObject') {
  3140. $content = $response->getBody(); //stream goes to serializer
  3141. } else {
  3142. $content = (string) $response->getBody();
  3143. if ($returnType !== 'string') {
  3144. $content = json_decode($content);
  3145. }
  3146. }
  3147. return [
  3148. ObjectSerializer::deserialize($content, $returnType, []),
  3149. $response->getStatusCode(),
  3150. $response->getHeaders()
  3151. ];
  3152. },
  3153. function ($exception) {
  3154. $response = $exception->getResponse();
  3155. $statusCode = $response->getStatusCode();
  3156. throw new ApiException(
  3157. sprintf(
  3158. '[%d] Error connecting to the API (%s)',
  3159. $statusCode,
  3160. $exception->getRequest()->getUri()
  3161. ),
  3162. $statusCode,
  3163. $response->getHeaders(),
  3164. (string) $response->getBody()
  3165. );
  3166. }
  3167. );
  3168. }
  3169. /**
  3170. * Create request for operation 'postApiV3AdminCreditAdjustments'
  3171. *
  3172. * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
  3173. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
  3174. *
  3175. * @throws \InvalidArgumentException
  3176. * @return \GuzzleHttp\Psr7\Request
  3177. */
  3178. public function postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
  3179. {
  3180. // verify the required parameter 'post_api_v3_admin_credit_adjustments_request' is set
  3181. if ($post_api_v3_admin_credit_adjustments_request === null || (is_array($post_api_v3_admin_credit_adjustments_request) && count($post_api_v3_admin_credit_adjustments_request) === 0)) {
  3182. throw new \InvalidArgumentException(
  3183. 'Missing the required parameter $post_api_v3_admin_credit_adjustments_request when calling postApiV3AdminCreditAdjustments'
  3184. );
  3185. }
  3186. $resourcePath = '/v3/admin/credit-adjustments';
  3187. $formParams = [];
  3188. $queryParams = [];
  3189. $headerParams = [];
  3190. $httpBody = '';
  3191. $multipart = false;
  3192. $headers = $this->headerSelector->selectHeaders(
  3193. ['application/json', 'application/problem+json', ],
  3194. $contentType,
  3195. $multipart
  3196. );
  3197. // for model (json/xml)
  3198. if (isset($post_api_v3_admin_credit_adjustments_request)) {
  3199. if (stripos($headers['Content-Type'], 'application/json') !== false) {
  3200. # if Content-Type contains "application/json", json_encode the body
  3201. try {
  3202. $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_admin_credit_adjustments_request), JSON_THROW_ON_ERROR);
  3203. } catch (\JsonException $e) {
  3204. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  3205. }
  3206. } else {
  3207. $httpBody = $post_api_v3_admin_credit_adjustments_request;
  3208. }
  3209. } elseif (count($formParams) > 0) {
  3210. if ($multipart) {
  3211. $multipartContents = [];
  3212. foreach ($formParams as $formParamName => $formParamValue) {
  3213. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  3214. foreach ($formParamValueItems as $formParamValueItem) {
  3215. $multipartContents[] = [
  3216. 'name' => $formParamName,
  3217. 'contents' => $formParamValueItem
  3218. ];
  3219. }
  3220. }
  3221. // for HTTP post (form)
  3222. $httpBody = new MultipartStream($multipartContents);
  3223. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  3224. # if Content-Type contains "application/json", json_encode the form parameters
  3225. try {
  3226. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  3227. } catch (\JsonException $e) {
  3228. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  3229. }
  3230. } else {
  3231. // for HTTP post (form)
  3232. $httpBody = ObjectSerializer::buildQuery($formParams);
  3233. }
  3234. }
  3235. // this endpoint requires Bearer authentication (access token)
  3236. if (!empty($this->config->getAccessToken())) {
  3237. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  3238. }
  3239. $defaultHeaders = [];
  3240. if ($this->config->getUserAgent()) {
  3241. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  3242. }
  3243. $headers = array_merge(
  3244. $defaultHeaders,
  3245. $headerParams,
  3246. $headers
  3247. );
  3248. $operationHost = $this->config->getHost();
  3249. $query = ObjectSerializer::buildQuery($queryParams);
  3250. return new Request(
  3251. 'POST',
  3252. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  3253. $headers,
  3254. $httpBody
  3255. );
  3256. }
  3257. /**
  3258. * Operation postApiV3AdminCreditSettlements
  3259. *
  3260. * 手工结算积分
  3261. *
  3262. * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request post_api_v3_admin_credit_settlements_request (optional)
  3263. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
  3264. *
  3265. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  3266. * @throws \InvalidArgumentException
  3267. * @return \WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
  3268. */
  3269. public function postApiV3AdminCreditSettlements($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
  3270. {
  3271. list($response) = $this->postApiV3AdminCreditSettlementsWithHttpInfo($post_api_v3_admin_credit_settlements_request, $contentType);
  3272. return $response;
  3273. }
  3274. /**
  3275. * Operation postApiV3AdminCreditSettlementsWithHttpInfo
  3276. *
  3277. * 手工结算积分
  3278. *
  3279. * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
  3280. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
  3281. *
  3282. * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
  3283. * @throws \InvalidArgumentException
  3284. * @return array of \WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
  3285. */
  3286. public function postApiV3AdminCreditSettlementsWithHttpInfo($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
  3287. {
  3288. $request = $this->postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request, $contentType);
  3289. try {
  3290. $options = $this->createHttpClientOption();
  3291. try {
  3292. $response = $this->client->send($request, $options);
  3293. } catch (RequestException $e) {
  3294. throw new ApiException(
  3295. "[{$e->getCode()}] {$e->getMessage()}",
  3296. (int) $e->getCode(),
  3297. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  3298. $e->getResponse() ? (string) $e->getResponse()->getBody() : null
  3299. );
  3300. } catch (ConnectException $e) {
  3301. throw new ApiException(
  3302. "[{$e->getCode()}] {$e->getMessage()}",
  3303. (int) $e->getCode(),
  3304. null,
  3305. null
  3306. );
  3307. }
  3308. $statusCode = $response->getStatusCode();
  3309. switch($statusCode) {
  3310. case 200:
  3311. return $this->handleResponseWithDataType(
  3312. '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
  3313. $request,
  3314. $response,
  3315. );
  3316. case 201:
  3317. return $this->handleResponseWithDataType(
  3318. '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
  3319. $request,
  3320. $response,
  3321. );
  3322. case 401:
  3323. return $this->handleResponseWithDataType(
  3324. '\WikipaliApi\Model\ProblemDetails',
  3325. $request,
  3326. $response,
  3327. );
  3328. case 422:
  3329. return $this->handleResponseWithDataType(
  3330. '\WikipaliApi\Model\ProblemDetails',
  3331. $request,
  3332. $response,
  3333. );
  3334. }
  3335. if ($statusCode < 200 || $statusCode > 299) {
  3336. throw new ApiException(
  3337. sprintf(
  3338. '[%d] Error connecting to the API (%s)',
  3339. $statusCode,
  3340. (string) $request->getUri()
  3341. ),
  3342. $statusCode,
  3343. $response->getHeaders(),
  3344. (string) $response->getBody()
  3345. );
  3346. }
  3347. return $this->handleResponseWithDataType(
  3348. '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
  3349. $request,
  3350. $response,
  3351. );
  3352. } catch (ApiException $e) {
  3353. switch ($e->getCode()) {
  3354. case 200:
  3355. $data = ObjectSerializer::deserialize(
  3356. $e->getResponseBody(),
  3357. '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
  3358. $e->getResponseHeaders()
  3359. );
  3360. $e->setResponseObject($data);
  3361. throw $e;
  3362. case 201:
  3363. $data = ObjectSerializer::deserialize(
  3364. $e->getResponseBody(),
  3365. '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
  3366. $e->getResponseHeaders()
  3367. );
  3368. $e->setResponseObject($data);
  3369. throw $e;
  3370. case 401:
  3371. $data = ObjectSerializer::deserialize(
  3372. $e->getResponseBody(),
  3373. '\WikipaliApi\Model\ProblemDetails',
  3374. $e->getResponseHeaders()
  3375. );
  3376. $e->setResponseObject($data);
  3377. throw $e;
  3378. case 422:
  3379. $data = ObjectSerializer::deserialize(
  3380. $e->getResponseBody(),
  3381. '\WikipaliApi\Model\ProblemDetails',
  3382. $e->getResponseHeaders()
  3383. );
  3384. $e->setResponseObject($data);
  3385. throw $e;
  3386. }
  3387. throw $e;
  3388. }
  3389. }
  3390. /**
  3391. * Operation postApiV3AdminCreditSettlementsAsync
  3392. *
  3393. * 手工结算积分
  3394. *
  3395. * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
  3396. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
  3397. *
  3398. * @throws \InvalidArgumentException
  3399. * @return \GuzzleHttp\Promise\PromiseInterface
  3400. */
  3401. public function postApiV3AdminCreditSettlementsAsync($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
  3402. {
  3403. return $this->postApiV3AdminCreditSettlementsAsyncWithHttpInfo($post_api_v3_admin_credit_settlements_request, $contentType)
  3404. ->then(
  3405. function ($response) {
  3406. return $response[0];
  3407. }
  3408. );
  3409. }
  3410. /**
  3411. * Operation postApiV3AdminCreditSettlementsAsyncWithHttpInfo
  3412. *
  3413. * 手工结算积分
  3414. *
  3415. * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
  3416. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
  3417. *
  3418. * @throws \InvalidArgumentException
  3419. * @return \GuzzleHttp\Promise\PromiseInterface
  3420. */
  3421. public function postApiV3AdminCreditSettlementsAsyncWithHttpInfo($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
  3422. {
  3423. $returnType = '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response';
  3424. $request = $this->postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request, $contentType);
  3425. return $this->client
  3426. ->sendAsync($request, $this->createHttpClientOption())
  3427. ->then(
  3428. function ($response) use ($returnType) {
  3429. if ($returnType === '\SplFileObject') {
  3430. $content = $response->getBody(); //stream goes to serializer
  3431. } else {
  3432. $content = (string) $response->getBody();
  3433. if ($returnType !== 'string') {
  3434. $content = json_decode($content);
  3435. }
  3436. }
  3437. return [
  3438. ObjectSerializer::deserialize($content, $returnType, []),
  3439. $response->getStatusCode(),
  3440. $response->getHeaders()
  3441. ];
  3442. },
  3443. function ($exception) {
  3444. $response = $exception->getResponse();
  3445. $statusCode = $response->getStatusCode();
  3446. throw new ApiException(
  3447. sprintf(
  3448. '[%d] Error connecting to the API (%s)',
  3449. $statusCode,
  3450. $exception->getRequest()->getUri()
  3451. ),
  3452. $statusCode,
  3453. $response->getHeaders(),
  3454. (string) $response->getBody()
  3455. );
  3456. }
  3457. );
  3458. }
  3459. /**
  3460. * Create request for operation 'postApiV3AdminCreditSettlements'
  3461. *
  3462. * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
  3463. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
  3464. *
  3465. * @throws \InvalidArgumentException
  3466. * @return \GuzzleHttp\Psr7\Request
  3467. */
  3468. public function postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
  3469. {
  3470. $resourcePath = '/v3/admin/credit-settlements';
  3471. $formParams = [];
  3472. $queryParams = [];
  3473. $headerParams = [];
  3474. $httpBody = '';
  3475. $multipart = false;
  3476. $headers = $this->headerSelector->selectHeaders(
  3477. ['application/json', 'application/problem+json', ],
  3478. $contentType,
  3479. $multipart
  3480. );
  3481. // for model (json/xml)
  3482. if (isset($post_api_v3_admin_credit_settlements_request)) {
  3483. if (stripos($headers['Content-Type'], 'application/json') !== false) {
  3484. # if Content-Type contains "application/json", json_encode the body
  3485. try {
  3486. $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_admin_credit_settlements_request), JSON_THROW_ON_ERROR);
  3487. } catch (\JsonException $e) {
  3488. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  3489. }
  3490. } else {
  3491. $httpBody = $post_api_v3_admin_credit_settlements_request;
  3492. }
  3493. } elseif (count($formParams) > 0) {
  3494. if ($multipart) {
  3495. $multipartContents = [];
  3496. foreach ($formParams as $formParamName => $formParamValue) {
  3497. $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
  3498. foreach ($formParamValueItems as $formParamValueItem) {
  3499. $multipartContents[] = [
  3500. 'name' => $formParamName,
  3501. 'contents' => $formParamValueItem
  3502. ];
  3503. }
  3504. }
  3505. // for HTTP post (form)
  3506. $httpBody = new MultipartStream($multipartContents);
  3507. } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
  3508. # if Content-Type contains "application/json", json_encode the form parameters
  3509. try {
  3510. $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
  3511. } catch (\JsonException $e) {
  3512. throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
  3513. }
  3514. } else {
  3515. // for HTTP post (form)
  3516. $httpBody = ObjectSerializer::buildQuery($formParams);
  3517. }
  3518. }
  3519. // this endpoint requires Bearer authentication (access token)
  3520. if (!empty($this->config->getAccessToken())) {
  3521. $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
  3522. }
  3523. $defaultHeaders = [];
  3524. if ($this->config->getUserAgent()) {
  3525. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  3526. }
  3527. $headers = array_merge(
  3528. $defaultHeaders,
  3529. $headerParams,
  3530. $headers
  3531. );
  3532. $operationHost = $this->config->getHost();
  3533. $query = ObjectSerializer::buildQuery($queryParams);
  3534. return new Request(
  3535. 'POST',
  3536. $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
  3537. $headers,
  3538. $httpBody
  3539. );
  3540. }
  3541. /**
  3542. * Create http client option
  3543. *
  3544. * @throws \RuntimeException on file opening failure
  3545. * @return array of http client options
  3546. */
  3547. protected function createHttpClientOption()
  3548. {
  3549. $options = [];
  3550. if ($this->config->getDebug()) {
  3551. $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
  3552. if (!$options[RequestOptions::DEBUG]) {
  3553. throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
  3554. }
  3555. }
  3556. if ($this->config->getCertFile()) {
  3557. $options[RequestOptions::CERT] = $this->config->getCertFile();
  3558. }
  3559. if ($this->config->getKeyFile()) {
  3560. $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
  3561. }
  3562. return $options;
  3563. }
  3564. private function handleResponseWithDataType(
  3565. string $dataType,
  3566. RequestInterface $request,
  3567. ResponseInterface $response
  3568. ): array {
  3569. if ($dataType === '\SplFileObject') {
  3570. $content = $response->getBody(); //stream goes to serializer
  3571. } else {
  3572. $content = (string) $response->getBody();
  3573. if ($dataType !== 'string') {
  3574. try {
  3575. $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
  3576. } catch (\JsonException $exception) {
  3577. throw new ApiException(
  3578. sprintf(
  3579. 'Error JSON decoding server response (%s)',
  3580. $request->getUri()
  3581. ),
  3582. $response->getStatusCode(),
  3583. $response->getHeaders(),
  3584. $content
  3585. );
  3586. }
  3587. }
  3588. }
  3589. return [
  3590. ObjectSerializer::deserialize($content, $dataType, []),
  3591. $response->getStatusCode(),
  3592. $response->getHeaders()
  3593. ];
  3594. }
  3595. private function responseWithinRangeCode(
  3596. string $rangeCode,
  3597. int $statusCode
  3598. ): bool {
  3599. $left = (int) ($rangeCode[0].'00');
  3600. $right = (int) ($rangeCode[0].'99');
  3601. return $statusCode >= $left && $statusCode <= $right;
  3602. }
  3603. }