params = $params; $this->httpClient = $httpClient; $this->requestStack = $requestStack; $this->respondService = $respondService; $this->token = $this->requestStack->getCurrentRequest()->headers->get('x-auth-token'); } public function list() { if ($this->params->get($this->enabled)) { $response = $this->httpClient->data( 'GET', $this->params->get($this->domain) . '/element_type.json', [ 'headers' => [ 'x-auth-token' => $this->token, ], ] ); return $this->respondService->checkProviderResponse($response); } else { throw new UnprocessableEntityMaestroException($this->module, $this->keyModule, $this->methodModule); } } /** * @return mixed */ public function read(int $elementTypeId) { if ($this->params->get($this->enabled)) { $response = $this->httpClient->data( 'GET', $this->params->get($this->domain) . '/element_type/' . $elementTypeId . '.json', [ 'headers' => [ 'x-auth-token' => $this->token, ], ] ); return $this->respondService->checkProviderResponse($response); } else { throw new UnprocessableEntityMaestroException($this->module, $this->keyModule, $this->methodModule); } } public function readMultiple(array $idElementTypes) { if ($this->params->get($this->enabled)) { $response = $this->httpClient->data( 'POST', $this->params->get($this->domain) . '/element_type/read/multiple.json', [ 'headers' => [ 'x-auth-token' => $this->token, ], 'json' => [ 'ids' => $idElementTypes, ], ] ); return $this->respondService->checkProviderResponse($response); } else { throw new UnprocessableEntityMaestroException($this->module, $this->keyModule, $this->methodModule); } } }