GroupsApi.php 160 KB

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