VLanProfileApi.php 25 KB

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