Skip to content
Snippets Groups Projects
Unverified Commit b90c0c54 authored by Mateu Aguiló Bosch's avatar Mateu Aguiló Bosch
Browse files

fix: remove unnecessary example

parent bd5dc2f6
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\api_proxy\Plugin\api_proxy;
use Drupal\api_proxy\Annotation\HttpApi;
use Drupal\api_proxy\Plugin\HttpApiPluginBase;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Form\SubformStateInterface;
use Symfony\Component\HttpFoundation\Response;
/**
* @HttpApi(
* id = "g2-crowd",
* label = @Translation("G2 Crowd"),
* description = @Translation("Proxies requests to the G2 Crowd API."),
* serviceUrl = "https://data.g2.com/api/v1",
* )
*/
final class G2Crowd extends HttpApiPluginBase {
use HttpApiCommonConfigs;
/**
* {@inheritdoc}
*/
public function addMoreConfigurationFormElements(array $form, SubformStateInterface $form_state): array {
$configuration = $this->configuration;
return array_merge(
$form,
['auth_token' => $this->authTokenConfigForm($configuration)]
);
}
/**
* {@inheritdoc}
*/
protected function calculateHeaders(array $headers): array {
$configuration = $this->getConfiguration();
$header = sprintf('Token token=%s', $configuration['auth_token'] ?? '');
return array_merge(
parent::calculateHeaders($headers),
['Authorization' => $header]
);
}
public function changeOutputFromApi(Response $response): Response {
$response->headers->remove('transfer-encoding');
return $response;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment