123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- <?php
- /**
- * CablemodemModelApi
- * PHP version 5
- *
- * @category Class
- * @package Swagger\Client\Cablemodem
- * @author Swagger Codegen team
- * @link https://github.com/swagger-api/swagger-codegen
- */
- /**
- * Cablemodem Flowdat
- *
- * API REST para Flowdat Cablemodem.
- *
- * OpenAPI spec version: 1.0.0
- *
- * Generated by: https://github.com/swagger-api/swagger-codegen.git
- * Swagger Codegen version: 2.4.0-SNAPSHOT
- */
- /**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
- namespace Swagger\Client\Cablemodem\Api;
- use GuzzleHttp\Client;
- use GuzzleHttp\ClientInterface;
- use GuzzleHttp\Exception\RequestException;
- use GuzzleHttp\Psr7\MultipartStream;
- use GuzzleHttp\Psr7\Request;
- use GuzzleHttp\RequestOptions;
- use Swagger\Client\ApiException;
- use Swagger\Client\Cablemodem\Configuration;
- use Swagger\Client\HeaderSelector;
- use Swagger\Client\ObjectSerializer;
- /**
- * CablemodemModelApi Class Doc Comment
- *
- * @category Class
- * @package Swagger\Client\Cablemodem
- * @author Swagger Codegen team
- * @link https://github.com/swagger-api/swagger-codegen
- */
- class CablemodemModelApi
- {
- /**
- * @var ClientInterface
- */
- protected $client;
- /**
- * @var Configuration
- */
- protected $config;
- /**
- * @var HeaderSelector
- */
- protected $headerSelector;
- /**
- * @param ClientInterface $client
- * @param Configuration $config
- * @param HeaderSelector $selector
- */
- public function __construct(
- ClientInterface $client = null,
- Configuration $config = null,
- HeaderSelector $selector = null
- )
- {
- $this->client = $client ?: new Client();
- $this->config = $config ?: new Configuration();
- $this->headerSelector = $selector ?: new HeaderSelector();
- }
- /**
- * @return Configuration
- */
- public function getConfig()
- {
- return $this->config;
- }
- /**
- * Operation getById
- *
- * Obtener modelos de cablemodem por id.
- *
- * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
- *
- * @throws \Swagger\Client\ApiException on non-2xx response
- * @throws \InvalidArgumentException
- * @return \Swagger\Client\Cablemodem\Model\CablemodemModel
- */
- public function getById($id)
- {
- list($response) = $this->getByIdWithHttpInfo($id);
- return $response;
- }
- /**
- * Operation getByIdWithHttpInfo
- *
- * Obtener modelos de cablemodem por id.
- *
- * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
- *
- * @throws \Swagger\Client\ApiException on non-2xx response
- * @throws \InvalidArgumentException
- * @return array of \Swagger\Client\Cablemodem\Model\CablemodemModel, HTTP status code, HTTP response headers (array of strings)
- */
- public function getByIdWithHttpInfo($id)
- {
- $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel';
- $request = $this->getByIdRequest($id);
- try {
- $options = $this->createHttpClientOption();
- try {
- $response = $this->client->send($request, $options);
- } catch (RequestException $e) {
- throw new ApiException(
- "[{$e->getCode()}] {$e->getMessage()}",
- $e->getCode(),
- $e->getResponse() ? $e->getResponse()->getHeaders() : null,
- $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
- );
- }
- $statusCode = $response->getStatusCode();
- if ($statusCode < 200 || $statusCode > 299) {
- throw new ApiException(
- sprintf(
- '[%d] Error connecting to the API (%s)',
- $statusCode,
- $request->getUri()
- ),
- $statusCode,
- $response->getHeaders(),
- $response->getBody()
- );
- }
- $responseBody = $response->getBody();
- if ($returnType === '\SplFileObject') {
- $content = $responseBody; //stream goes to serializer
- } else {
- $content = $responseBody->getContents();
- if ($returnType !== 'string') {
- $content = json_decode($content);
- }
- }
- return [
- ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $content, $returnType, []),
- $response->getStatusCode(),
- $response->getHeaders()
- ];
- } catch (ApiException $e) {
- switch ($e->getCode()) {
- case 200:
- $data = ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $e->getResponseBody(),
- '\Swagger\Client\Cablemodem\Model\CablemodemModel',
- $e->getResponseHeaders()
- );
- $e->setResponseObject($data);
- break;
- }
- throw $e;
- }
- }
- /**
- * Operation getByIdAsync
- *
- * Obtener modelos de cablemodem por id.
- *
- * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Promise\PromiseInterface
- */
- public function getByIdAsync($id)
- {
- return $this->getByIdAsyncWithHttpInfo($id)
- ->then(
- function ($response) {
- return $response[0];
- }
- );
- }
- /**
- * Operation getByIdAsyncWithHttpInfo
- *
- * Obtener modelos de cablemodem por id.
- *
- * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Promise\PromiseInterface
- */
- public function getByIdAsyncWithHttpInfo($id)
- {
- $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel';
- $request = $this->getByIdRequest($id);
- return $this->client
- ->sendAsync($request, $this->createHttpClientOption())
- ->then(
- function ($response) use ($returnType) {
- $responseBody = $response->getBody();
- if ($returnType === '\SplFileObject') {
- $content = $responseBody; //stream goes to serializer
- } else {
- $content = $responseBody->getContents();
- if ($returnType !== 'string') {
- $content = json_decode($content);
- }
- }
- return [
- ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $content, $returnType, []),
- $response->getStatusCode(),
- $response->getHeaders()
- ];
- },
- function ($exception) {
- $response = $exception->getResponse();
- $statusCode = $response->getStatusCode();
- throw new ApiException(
- sprintf(
- '[%d] Error connecting to the API (%s)',
- $statusCode,
- $exception->getRequest()->getUri()
- ),
- $statusCode,
- $response->getHeaders(),
- $response->getBody()
- );
- }
- );
- }
- /**
- * Create request for operation 'getById'
- *
- * @param string $id Id de modelo de cablemodem que quiere obtener. (required)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Psr7\Request
- */
- protected function getByIdRequest($id)
- {
- // verify the required parameter 'id' is set
- if ($id === null || (is_array($id) && count($id) === 0)) {
- throw new \InvalidArgumentException(
- 'Missing the required parameter $id when calling getById'
- );
- }
- $resourcePath = '/cablemodemmodels/{id}.json';
- $formParams = [];
- $queryParams = [];
- $headerParams = [];
- $httpBody = '';
- $multipart = false;
- // path params
- if ($id !== null) {
- $resourcePath = str_replace(
- '{' . 'id' . '}',
- ObjectSerializer::toPathValue($id),
- $resourcePath
- );
- }
- // body params
- $_tempBody = null;
- if ($multipart) {
- $headers = $this->headerSelector->selectHeadersForMultipart(
- ['application/json']
- );
- } else {
- $headers = $this->headerSelector->selectHeaders(
- ['application/json'],
- []
- );
- }
- // for model (json/xml)
- if (isset($_tempBody)) {
- // $_tempBody is the method argument, if present
- $httpBody = $_tempBody;
- // \stdClass has no __toString(), so we should encode it manually
- if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
- $httpBody = \GuzzleHttp\json_encode($httpBody);
- }
- } elseif (count($formParams) > 0) {
- if ($multipart) {
- $multipartContents = [];
- foreach ($formParams as $formParamName => $formParamValue) {
- $multipartContents[] = [
- 'name' => $formParamName,
- 'contents' => $formParamValue
- ];
- }
- // for HTTP post (form)
- $httpBody = new MultipartStream($multipartContents);
- } elseif ($headers['Content-Type'] === 'application/json') {
- $httpBody = \GuzzleHttp\json_encode($formParams);
- } else {
- // for HTTP post (form)
- $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
- }
- }
- // this endpoint requires HTTP basic authentication
- if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
- $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
- }
- $defaultHeaders = [];
- if ($this->config->getUserAgent()) {
- $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
- }
- $headers = array_merge(
- $defaultHeaders,
- $headerParams,
- $headers
- );
- $query = \GuzzleHttp\Psr7\build_query($queryParams);
- return new Request(
- 'GET',
- $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
- $headers,
- $httpBody
- );
- }
- /**
- * Operation getList
- *
- * Obtener modelos de cablemodem por id o nombre.
- *
- * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
- * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
- * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
- * @param int $limit Cantidad de registros por página. (optional, default to 20)
- * @param int $page Número de página a buscar. (optional, default to 0)
- *
- * @throws \Swagger\Client\ApiException on non-2xx response
- * @throws \InvalidArgumentException
- * @return \Swagger\Client\Cablemodem\Model\CablemodemModel[]
- */
- public function getList($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
- {
- list($response) = $this->getListWithHttpInfo($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
- return $response;
- }
- /**
- * Operation getListWithHttpInfo
- *
- * Obtener modelos de cablemodem por id o nombre.
- *
- * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
- * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
- * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
- * @param int $limit Cantidad de registros por página. (optional, default to 20)
- * @param int $page Número de página a buscar. (optional, default to 0)
- *
- * @throws \Swagger\Client\ApiException on non-2xx response
- * @throws \InvalidArgumentException
- * @return array of \Swagger\Client\Cablemodem\Model\CablemodemModel[], HTTP status code, HTTP response headers (array of strings)
- */
- public function getListWithHttpInfo($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
- {
- $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel[]';
- $request = $this->getListRequest($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
- try {
- $options = $this->createHttpClientOption();
- try {
- $response = $this->client->send($request, $options);
- } catch (RequestException $e) {
- throw new ApiException(
- "[{$e->getCode()}] {$e->getMessage()}",
- $e->getCode(),
- $e->getResponse() ? $e->getResponse()->getHeaders() : null,
- $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
- );
- }
- $statusCode = $response->getStatusCode();
- if ($statusCode < 200 || $statusCode > 299) {
- throw new ApiException(
- sprintf(
- '[%d] Error connecting to the API (%s)',
- $statusCode,
- $request->getUri()
- ),
- $statusCode,
- $response->getHeaders(),
- $response->getBody()
- );
- }
- $responseBody = $response->getBody();
- if ($returnType === '\SplFileObject') {
- $content = $responseBody; //stream goes to serializer
- } else {
- $content = $responseBody->getContents();
- if ($returnType !== 'string') {
- $content = json_decode($content);
- }
- }
- return [
- ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $content, $returnType, []),
- $response->getStatusCode(),
- $response->getHeaders()
- ];
- } catch (ApiException $e) {
- switch ($e->getCode()) {
- case 200:
- $data = ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $e->getResponseBody(),
- '\Swagger\Client\Cablemodem\Model\CablemodemModel[]',
- $e->getResponseHeaders()
- );
- $e->setResponseObject($data);
- break;
- }
- throw $e;
- }
- }
- /**
- * Operation getListAsync
- *
- * Obtener modelos de cablemodem por id o nombre.
- *
- * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
- * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
- * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
- * @param int $limit Cantidad de registros por página. (optional, default to 20)
- * @param int $page Número de página a buscar. (optional, default to 0)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Promise\PromiseInterface
- */
- public function getListAsync($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
- {
- return $this->getListAsyncWithHttpInfo($filters_id, $filters_name, $filters_qb_criteria, $limit, $page)
- ->then(
- function ($response) {
- return $response[0];
- }
- );
- }
- /**
- * Operation getListAsyncWithHttpInfo
- *
- * Obtener modelos de cablemodem por id o nombre.
- *
- * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
- * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
- * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
- * @param int $limit Cantidad de registros por página. (optional, default to 20)
- * @param int $page Número de página a buscar. (optional, default to 0)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Promise\PromiseInterface
- */
- public function getListAsyncWithHttpInfo($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
- {
- $returnType = '\Swagger\Client\Cablemodem\Model\CablemodemModel[]';
- $request = $this->getListRequest($filters_id, $filters_name, $filters_qb_criteria, $limit, $page);
- return $this->client
- ->sendAsync($request, $this->createHttpClientOption())
- ->then(
- function ($response) use ($returnType) {
- $responseBody = $response->getBody();
- if ($returnType === '\SplFileObject') {
- $content = $responseBody; //stream goes to serializer
- } else {
- $content = $responseBody->getContents();
- if ($returnType !== 'string') {
- $content = json_decode($content);
- }
- }
- return [
- ObjectSerializer::deserialize(
- $this->getConfig()->getTempFolderPath(),
- $content, $returnType, []),
- $response->getStatusCode(),
- $response->getHeaders()
- ];
- },
- function ($exception) {
- $response = $exception->getResponse();
- $statusCode = $response->getStatusCode();
- throw new ApiException(
- sprintf(
- '[%d] Error connecting to the API (%s)',
- $statusCode,
- $exception->getRequest()->getUri()
- ),
- $statusCode,
- $response->getHeaders(),
- $response->getBody()
- );
- }
- );
- }
- /**
- * Create request for operation 'getList'
- *
- * @param int $filters_id Id del modelo de cablemodem que quiere obtener. (optional)
- * @param string $filters_name Nombre del modelo de cablemodem que quiere obtener. (optional)
- * @param int $filters_qb_criteria Criteria true. (optional, default to 1)
- * @param int $limit Cantidad de registros por página. (optional, default to 20)
- * @param int $page Número de página a buscar. (optional, default to 0)
- *
- * @throws \InvalidArgumentException
- * @return \GuzzleHttp\Psr7\Request
- */
- protected function getListRequest($filters_id = null, $filters_name = null, $filters_qb_criteria = '1', $limit = '20', $page = '0')
- {
- $resourcePath = '/cablemodemmodels.json';
- $formParams = [];
- $queryParams = [];
- $headerParams = [];
- $httpBody = '';
- $multipart = false;
- // query params
- if ($filters_id !== null) {
- $queryParams['filters[id]'] = ObjectSerializer::toQueryValue($filters_id);
- }
- // query params
- if ($filters_name !== null) {
- $queryParams['filters[name]'] = ObjectSerializer::toQueryValue($filters_name);
- }
- // query params
- if ($filters_qb_criteria !== null) {
- $queryParams['filters[qb-criteria]'] = ObjectSerializer::toQueryValue($filters_qb_criteria);
- }
- // query params
- if ($limit !== null) {
- $queryParams['limit'] = ObjectSerializer::toQueryValue($limit);
- }
- // query params
- if ($page !== null) {
- $queryParams['page'] = ObjectSerializer::toQueryValue($page) * ObjectSerializer::toQueryValue($limit);
- }
- // body params
- $_tempBody = null;
- if ($multipart) {
- $headers = $this->headerSelector->selectHeadersForMultipart(
- ['application/json']
- );
- } else {
- $headers = $this->headerSelector->selectHeaders(
- ['application/json'],
- []
- );
- }
- // for model (json/xml)
- if (isset($_tempBody)) {
- // $_tempBody is the method argument, if present
- $httpBody = $_tempBody;
- // \stdClass has no __toString(), so we should encode it manually
- if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
- $httpBody = \GuzzleHttp\json_encode($httpBody);
- }
- } elseif (count($formParams) > 0) {
- if ($multipart) {
- $multipartContents = [];
- foreach ($formParams as $formParamName => $formParamValue) {
- $multipartContents[] = [
- 'name' => $formParamName,
- 'contents' => $formParamValue
- ];
- }
- // for HTTP post (form)
- $httpBody = new MultipartStream($multipartContents);
- } elseif ($headers['Content-Type'] === 'application/json') {
- $httpBody = \GuzzleHttp\json_encode($formParams);
- } else {
- // for HTTP post (form)
- $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
- }
- }
- // this endpoint requires HTTP basic authentication
- if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
- $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
- }
- $defaultHeaders = [];
- if ($this->config->getUserAgent()) {
- $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
- }
- $headers = array_merge(
- $defaultHeaders,
- $headerParams,
- $headers
- );
- $query = \GuzzleHttp\Psr7\build_query($queryParams);
- return new Request(
- 'GET',
- $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
- $headers,
- $httpBody
- );
- }
- /**
- * Create http client option
- *
- * @throws \RuntimeException on file opening failure
- * @return array of http client options
- */
- protected function createHttpClientOption()
- {
- $options = [];
- if ($this->config->getDebug()) {
- $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
- if (!$options[RequestOptions::DEBUG]) {
- throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
- }
- }
- return $options;
- }
- }
|