CablemodemModelApi.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <?php
  2. /**
  3. * CablemodemModelApi
  4. * PHP version 5
  5. *
  6. * @category Class
  7. * @package Swagger\Client\Cablemodem
  8. * @author Swagger Codegen team
  9. * @link https://github.com/swagger-api/swagger-codegen
  10. */
  11. /**
  12. * Cablemodem Flowdat
  13. *
  14. * API REST para Flowdat Cablemodem.
  15. *
  16. * OpenAPI spec version: 1.0.0
  17. *
  18. * Generated by: https://github.com/swagger-api/swagger-codegen.git
  19. * Swagger Codegen version: 2.4.0-SNAPSHOT
  20. */
  21. /**
  22. * NOTE: This class is auto generated by the swagger code generator program.
  23. * https://github.com/swagger-api/swagger-codegen
  24. * Do not edit the class manually.
  25. */
  26. namespace Swagger\Client\Cablemodem\Api;
  27. use GuzzleHttp\Client;
  28. use GuzzleHttp\ClientInterface;
  29. use GuzzleHttp\Exception\RequestException;
  30. use GuzzleHttp\Psr7\MultipartStream;
  31. use GuzzleHttp\Psr7\Request;
  32. use GuzzleHttp\RequestOptions;
  33. use Swagger\Client\ApiException;
  34. use Swagger\Client\Cablemodem\Configuration;
  35. use Swagger\Client\HeaderSelector;
  36. use Swagger\Client\ObjectSerializer;
  37. /**
  38. * CablemodemModelApi Class Doc Comment
  39. *
  40. * @category Class
  41. * @package Swagger\Client\Cablemodem
  42. * @author Swagger Codegen team
  43. * @link https://github.com/swagger-api/swagger-codegen
  44. */
  45. class CablemodemModelApi
  46. {
  47. /**
  48. * @var ClientInterface
  49. */
  50. protected $client;
  51. /**
  52. * @var Configuration
  53. */
  54. protected $config;
  55. /**
  56. * @var HeaderSelector
  57. */
  58. protected $headerSelector;
  59. /**
  60. * @param ClientInterface $client
  61. * @param Configuration $config
  62. * @param HeaderSelector $selector
  63. */
  64. public function __construct(
  65. ClientInterface $client = null,
  66. Configuration $config = null,
  67. HeaderSelector $selector = null
  68. )
  69. {
  70. $this->client = $client ?: new Client();
  71. $this->config = $config ?: new Configuration();
  72. $this->headerSelector = $selector ?: new HeaderSelector();
  73. }
  74. /**
  75. * @return Configuration
  76. */
  77. public function getConfig()
  78. {
  79. return $this->config;
  80. }
  81. /**
  82. * Operation getById
  83. *
  84. * Obtener modelos de cablemodem por id.
  85. *
  86. * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
  87. *
  88. * @throws \Swagger\Client\ApiException on non-2xx response
  89. * @throws \InvalidArgumentException
  90. * @return \Swagger\Client\Cablemodem\Model\CablemodemModel
  91. */
  92. public function getById($id)
  93. {
  94. list($response) = $this->getByIdWithHttpInfo($id);
  95. return $response;
  96. }
  97. /**
  98. * Operation getByIdWithHttpInfo
  99. *
  100. * Obtener modelos de cablemodem por id.
  101. *
  102. * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
  103. *
  104. * @throws \Swagger\Client\ApiException on non-2xx response
  105. * @throws \InvalidArgumentException
  106. * @return array of \Swagger\Client\Cablemodem\Model\CablemodemModel, HTTP status code, HTTP response headers (array of strings)
  107. */
  108. public function getByIdWithHttpInfo($id)
  109. {
  110. $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel';
  111. $request = $this->getByIdRequest($id);
  112. try {
  113. $options = $this->createHttpClientOption();
  114. try {
  115. $response = $this->client->send($request, $options);
  116. } catch (RequestException $e) {
  117. throw new ApiException(
  118. "[{$e->getCode()}] {$e->getMessage()}",
  119. $e->getCode(),
  120. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  121. $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
  122. );
  123. }
  124. $statusCode = $response->getStatusCode();
  125. if ($statusCode < 200 || $statusCode > 299) {
  126. throw new ApiException(
  127. sprintf(
  128. '[%d] Error connecting to the API (%s)',
  129. $statusCode,
  130. $request->getUri()
  131. ),
  132. $statusCode,
  133. $response->getHeaders(),
  134. $response->getBody()
  135. );
  136. }
  137. $responseBody = $response->getBody();
  138. if ($returnType === '\SplFileObject') {
  139. $content = $responseBody; //stream goes to serializer
  140. } else {
  141. $content = $responseBody->getContents();
  142. if ($returnType !== 'string') {
  143. $content = json_decode($content);
  144. }
  145. }
  146. return [
  147. ObjectSerializer::deserialize(
  148. $this->getConfig()->getTempFolderPath(),
  149. $content, $returnType, []),
  150. $response->getStatusCode(),
  151. $response->getHeaders()
  152. ];
  153. } catch (ApiException $e) {
  154. switch ($e->getCode()) {
  155. case 200:
  156. $data = ObjectSerializer::deserialize(
  157. $this->getConfig()->getTempFolderPath(),
  158. $e->getResponseBody(),
  159. '\Swagger\Client\Cablemodem\Model\CablemodemModel',
  160. $e->getResponseHeaders()
  161. );
  162. $e->setResponseObject($data);
  163. break;
  164. }
  165. throw $e;
  166. }
  167. }
  168. /**
  169. * Operation getByIdAsync
  170. *
  171. * Obtener modelos de cablemodem por id.
  172. *
  173. * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
  174. *
  175. * @throws \InvalidArgumentException
  176. * @return \GuzzleHttp\Promise\PromiseInterface
  177. */
  178. public function getByIdAsync($id)
  179. {
  180. return $this->getByIdAsyncWithHttpInfo($id)
  181. ->then(
  182. function ($response) {
  183. return $response[0];
  184. }
  185. );
  186. }
  187. /**
  188. * Operation getByIdAsyncWithHttpInfo
  189. *
  190. * Obtener modelos de cablemodem por id.
  191. *
  192. * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
  193. *
  194. * @throws \InvalidArgumentException
  195. * @return \GuzzleHttp\Promise\PromiseInterface
  196. */
  197. public function getByIdAsyncWithHttpInfo($id)
  198. {
  199. $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel';
  200. $request = $this->getByIdRequest($id);
  201. return $this->client
  202. ->sendAsync($request, $this->createHttpClientOption())
  203. ->then(
  204. function ($response) use ($returnType) {
  205. $responseBody = $response->getBody();
  206. if ($returnType === '\SplFileObject') {
  207. $content = $responseBody; //stream goes to serializer
  208. } else {
  209. $content = $responseBody->getContents();
  210. if ($returnType !== 'string') {
  211. $content = json_decode($content);
  212. }
  213. }
  214. return [
  215. ObjectSerializer::deserialize(
  216. $this->getConfig()->getTempFolderPath(),
  217. $content, $returnType, []),
  218. $response->getStatusCode(),
  219. $response->getHeaders()
  220. ];
  221. },
  222. function ($exception) {
  223. $response = $exception->getResponse();
  224. $statusCode = $response->getStatusCode();
  225. throw new ApiException(
  226. sprintf(
  227. '[%d] Error connecting to the API (%s)',
  228. $statusCode,
  229. $exception->getRequest()->getUri()
  230. ),
  231. $statusCode,
  232. $response->getHeaders(),
  233. $response->getBody()
  234. );
  235. }
  236. );
  237. }
  238. /**
  239. * Create request for operation 'getById'
  240. *
  241. * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
  242. *
  243. * @throws \InvalidArgumentException
  244. * @return \GuzzleHttp\Psr7\Request
  245. */
  246. protected function getByIdRequest($id)
  247. {
  248. // verify the required parameter 'id' is set
  249. if ($id === null || (is_array($id) && count($id) === 0)) {
  250. throw new \InvalidArgumentException(
  251. 'Missing the required parameter $id when calling getById'
  252. );
  253. }
  254. $resourcePath = '/cablemodemmodels/{id}.json';
  255. $formParams = [];
  256. $queryParams = [];
  257. $headerParams = [];
  258. $httpBody = '';
  259. $multipart = false;
  260. // path params
  261. if ($id !== null) {
  262. $resourcePath = str_replace(
  263. '{' . 'id' . '}',
  264. ObjectSerializer::toPathValue($id),
  265. $resourcePath
  266. );
  267. }
  268. // body params
  269. $_tempBody = null;
  270. if ($multipart) {
  271. $headers = $this->headerSelector->selectHeadersForMultipart(
  272. ['application/json']
  273. );
  274. } else {
  275. $headers = $this->headerSelector->selectHeaders(
  276. ['application/json'],
  277. []
  278. );
  279. }
  280. // for model (json/xml)
  281. if (isset($_tempBody)) {
  282. // $_tempBody is the method argument, if present
  283. $httpBody = $_tempBody;
  284. // \stdClass has no __toString(), so we should encode it manually
  285. if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
  286. $httpBody = \GuzzleHttp\json_encode($httpBody);
  287. }
  288. } elseif (count($formParams) > 0) {
  289. if ($multipart) {
  290. $multipartContents = [];
  291. foreach ($formParams as $formParamName => $formParamValue) {
  292. $multipartContents[] = [
  293. 'name' => $formParamName,
  294. 'contents' => $formParamValue
  295. ];
  296. }
  297. // for HTTP post (form)
  298. $httpBody = new MultipartStream($multipartContents);
  299. } elseif ($headers['Content-Type'] === 'application/json') {
  300. $httpBody = \GuzzleHttp\json_encode($formParams);
  301. } else {
  302. // for HTTP post (form)
  303. $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
  304. }
  305. }
  306. // this endpoint requires HTTP basic authentication
  307. if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
  308. $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
  309. }
  310. $defaultHeaders = [];
  311. if ($this->config->getUserAgent()) {
  312. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  313. }
  314. $headers = array_merge(
  315. $defaultHeaders,
  316. $headerParams,
  317. $headers
  318. );
  319. $query = \GuzzleHttp\Psr7\build_query($queryParams);
  320. return new Request(
  321. 'GET',
  322. $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
  323. $headers,
  324. $httpBody
  325. );
  326. }
  327. /**
  328. * Operation getList
  329. *
  330. * Obtener modelos de cablemodem por id o nombre.
  331. *
  332. * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
  333. * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
  334. * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
  335. * @param int $limit Cantidad de registros por página. (optional, default to 20)
  336. * @param int $page Número de página a buscar. (optional, default to 0)
  337. *
  338. * @throws \Swagger\Client\ApiException on non-2xx response
  339. * @throws \InvalidArgumentException
  340. * @return \Swagger\Client\Cablemodem\Model\CablemodemModel[]
  341. */
  342. public function getList($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
  343. {
  344. list($response) = $this->getListWithHttpInfo($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
  345. return $response;
  346. }
  347. /**
  348. * Operation getListWithHttpInfo
  349. *
  350. * Obtener modelos de cablemodem por id o nombre.
  351. *
  352. * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
  353. * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
  354. * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
  355. * @param int $limit Cantidad de registros por página. (optional, default to 20)
  356. * @param int $page Número de página a buscar. (optional, default to 0)
  357. *
  358. * @throws \Swagger\Client\ApiException on non-2xx response
  359. * @throws \InvalidArgumentException
  360. * @return array of \Swagger\Client\Cablemodem\Model\CablemodemModel[], HTTP status code, HTTP response headers (array of strings)
  361. */
  362. public function getListWithHttpInfo($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
  363. {
  364. $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel[]';
  365. $request = $this->getListRequest($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
  366. try {
  367. $options = $this->createHttpClientOption();
  368. try {
  369. $response = $this->client->send($request, $options);
  370. } catch (RequestException $e) {
  371. throw new ApiException(
  372. "[{$e->getCode()}] {$e->getMessage()}",
  373. $e->getCode(),
  374. $e->getResponse() ? $e->getResponse()->getHeaders() : null,
  375. $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
  376. );
  377. }
  378. $statusCode = $response->getStatusCode();
  379. if ($statusCode < 200 || $statusCode > 299) {
  380. throw new ApiException(
  381. sprintf(
  382. '[%d] Error connecting to the API (%s)',
  383. $statusCode,
  384. $request->getUri()
  385. ),
  386. $statusCode,
  387. $response->getHeaders(),
  388. $response->getBody()
  389. );
  390. }
  391. $responseBody = $response->getBody();
  392. if ($returnType === '\SplFileObject') {
  393. $content = $responseBody; //stream goes to serializer
  394. } else {
  395. $content = $responseBody->getContents();
  396. if ($returnType !== 'string') {
  397. $content = json_decode($content);
  398. }
  399. }
  400. return [
  401. ObjectSerializer::deserialize(
  402. $this->getConfig()->getTempFolderPath(),
  403. $content, $returnType, []),
  404. $response->getStatusCode(),
  405. $response->getHeaders()
  406. ];
  407. } catch (ApiException $e) {
  408. switch ($e->getCode()) {
  409. case 200:
  410. $data = ObjectSerializer::deserialize(
  411. $this->getConfig()->getTempFolderPath(),
  412. $e->getResponseBody(),
  413. '\Swagger\Client\Cablemodem\Model\CablemodemModel[]',
  414. $e->getResponseHeaders()
  415. );
  416. $e->setResponseObject($data);
  417. break;
  418. }
  419. throw $e;
  420. }
  421. }
  422. /**
  423. * Operation getListAsync
  424. *
  425. * Obtener modelos de cablemodem por id o nombre.
  426. *
  427. * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
  428. * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
  429. * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
  430. * @param int $limit Cantidad de registros por página. (optional, default to 20)
  431. * @param int $page Número de página a buscar. (optional, default to 0)
  432. *
  433. * @throws \InvalidArgumentException
  434. * @return \GuzzleHttp\Promise\PromiseInterface
  435. */
  436. public function getListAsync($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
  437. {
  438. return $this->getListAsyncWithHttpInfo($filters_id, $filters_name, $filters_qb_criteria, $limit, $page)
  439. ->then(
  440. function ($response) {
  441. return $response[0];
  442. }
  443. );
  444. }
  445. /**
  446. * Operation getListAsyncWithHttpInfo
  447. *
  448. * Obtener modelos de cablemodem por id o nombre.
  449. *
  450. * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
  451. * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
  452. * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
  453. * @param int $limit Cantidad de registros por página. (optional, default to 20)
  454. * @param int $page Número de página a buscar. (optional, default to 0)
  455. *
  456. * @throws \InvalidArgumentException
  457. * @return \GuzzleHttp\Promise\PromiseInterface
  458. */
  459. public function getListAsyncWithHttpInfo($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
  460. {
  461. $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel[]';
  462. $request = $this->getListRequest($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
  463. return $this->client
  464. ->sendAsync($request, $this->createHttpClientOption())
  465. ->then(
  466. function ($response) use ($returnType) {
  467. $responseBody = $response->getBody();
  468. if ($returnType === '\SplFileObject') {
  469. $content = $responseBody; //stream goes to serializer
  470. } else {
  471. $content = $responseBody->getContents();
  472. if ($returnType !== 'string') {
  473. $content = json_decode($content);
  474. }
  475. }
  476. return [
  477. ObjectSerializer::deserialize(
  478. $this->getConfig()->getTempFolderPath(),
  479. $content, $returnType, []),
  480. $response->getStatusCode(),
  481. $response->getHeaders()
  482. ];
  483. },
  484. function ($exception) {
  485. $response = $exception->getResponse();
  486. $statusCode = $response->getStatusCode();
  487. throw new ApiException(
  488. sprintf(
  489. '[%d] Error connecting to the API (%s)',
  490. $statusCode,
  491. $exception->getRequest()->getUri()
  492. ),
  493. $statusCode,
  494. $response->getHeaders(),
  495. $response->getBody()
  496. );
  497. }
  498. );
  499. }
  500. /**
  501. * Create request for operation 'getList'
  502. *
  503. * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
  504. * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
  505. * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
  506. * @param int $limit Cantidad de registros por página. (optional, default to 20)
  507. * @param int $page Número de página a buscar. (optional, default to 0)
  508. *
  509. * @throws \InvalidArgumentException
  510. * @return \GuzzleHttp\Psr7\Request
  511. */
  512. protected function getListRequest($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
  513. {
  514. $resourcePath = '/cablemodemmodels.json';
  515. $formParams = [];
  516. $queryParams = [];
  517. $headerParams = [];
  518. $httpBody = '';
  519. $multipart = false;
  520. // query params
  521. if ($filters_id !== null) {
  522. $queryParams['filters[id]'] = ObjectSerializer::toQueryValue($filters_id);
  523. }
  524. // query params
  525. if ($filters_name !== null) {
  526. $queryParams['filters[name]'] = ObjectSerializer::toQueryValue($filters_name);
  527. }
  528. // query params
  529. if ($filters_qb_criteria !== null) {
  530. $queryParams['filters[qb-criteria]'] = ObjectSerializer::toQueryValue($filters_qb_criteria);
  531. }
  532. // query params
  533. if ($limit !== null) {
  534. $queryParams['limit'] = ObjectSerializer::toQueryValue($limit);
  535. }
  536. // query params
  537. if ($page !== null) {
  538. $queryParams['page'] = ObjectSerializer::toQueryValue($page) * ObjectSerializer::toQueryValue($limit);
  539. }
  540. // body params
  541. $_tempBody = null;
  542. if ($multipart) {
  543. $headers = $this->headerSelector->selectHeadersForMultipart(
  544. ['application/json']
  545. );
  546. } else {
  547. $headers = $this->headerSelector->selectHeaders(
  548. ['application/json'],
  549. []
  550. );
  551. }
  552. // for model (json/xml)
  553. if (isset($_tempBody)) {
  554. // $_tempBody is the method argument, if present
  555. $httpBody = $_tempBody;
  556. // \stdClass has no __toString(), so we should encode it manually
  557. if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
  558. $httpBody = \GuzzleHttp\json_encode($httpBody);
  559. }
  560. } elseif (count($formParams) > 0) {
  561. if ($multipart) {
  562. $multipartContents = [];
  563. foreach ($formParams as $formParamName => $formParamValue) {
  564. $multipartContents[] = [
  565. 'name' => $formParamName,
  566. 'contents' => $formParamValue
  567. ];
  568. }
  569. // for HTTP post (form)
  570. $httpBody = new MultipartStream($multipartContents);
  571. } elseif ($headers['Content-Type'] === 'application/json') {
  572. $httpBody = \GuzzleHttp\json_encode($formParams);
  573. } else {
  574. // for HTTP post (form)
  575. $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
  576. }
  577. }
  578. // this endpoint requires HTTP basic authentication
  579. if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
  580. $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
  581. }
  582. $defaultHeaders = [];
  583. if ($this->config->getUserAgent()) {
  584. $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
  585. }
  586. $headers = array_merge(
  587. $defaultHeaders,
  588. $headerParams,
  589. $headers
  590. );
  591. $query = \GuzzleHttp\Psr7\build_query($queryParams);
  592. return new Request(
  593. 'GET',
  594. $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
  595. $headers,
  596. $httpBody
  597. );
  598. }
  599. /**
  600. * Create http client option
  601. *
  602. * @throws \RuntimeException on file opening failure
  603. * @return array of http client options
  604. */
  605. protected function createHttpClientOption()
  606. {
  607. $options = [];
  608. if ($this->config->getDebug()) {
  609. $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
  610. if (!$options[RequestOptions::DEBUG]) {
  611. throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
  612. }
  613. }
  614. return $options;
  615. }
  616. }