|
@@ -36,14 +36,12 @@ class HelloAssoService extends ApiRequestService
|
|
|
HttpClientInterface $client,
|
|
HttpClientInterface $client,
|
|
|
private readonly OrganizationRepository $organizationRepository,
|
|
private readonly OrganizationRepository $organizationRepository,
|
|
|
private readonly EventRepository $eventRepository,
|
|
private readonly EventRepository $eventRepository,
|
|
|
- private readonly string $baseUrl,
|
|
|
|
|
private readonly string $publicAppBaseUrl,
|
|
private readonly string $publicAppBaseUrl,
|
|
|
private readonly string $helloAssoApiBaseUrl,
|
|
private readonly string $helloAssoApiBaseUrl,
|
|
|
private readonly string $helloAssoAuthBaseUrl,
|
|
private readonly string $helloAssoAuthBaseUrl,
|
|
|
private readonly string $helloAssoClientId,
|
|
private readonly string $helloAssoClientId,
|
|
|
private readonly string $helloAssoClientSecret,
|
|
private readonly string $helloAssoClientSecret,
|
|
|
private readonly EntityManagerInterface $entityManager,
|
|
private readonly EntityManagerInterface $entityManager,
|
|
|
- private readonly LoggerInterface $logger
|
|
|
|
|
) {
|
|
) {
|
|
|
parent::__construct($client);
|
|
parent::__construct($client);
|
|
|
}
|
|
}
|
|
@@ -60,8 +58,8 @@ class HelloAssoService extends ApiRequestService
|
|
|
*/
|
|
*/
|
|
|
public function setupOpentalentDomain(): void
|
|
public function setupOpentalentDomain(): void
|
|
|
{
|
|
{
|
|
|
- $accessToken = $this->fetchAccessToken(null);
|
|
|
|
|
- $this->updateDomain($accessToken, 'https://*.opentalent.fr');
|
|
|
|
|
|
|
+ $tokens = $this->fetchAccessToken(null, null);
|
|
|
|
|
+ $this->updateDomain($tokens['access_token'], 'https://*.opentalent.fr');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -202,6 +200,10 @@ class HelloAssoService extends ApiRequestService
|
|
|
$this->entityManager->flush();
|
|
$this->entityManager->flush();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array<string> $routeParts
|
|
|
|
|
+ * @return array<string, mixed>
|
|
|
|
|
+ */
|
|
|
public function getResource(HelloAsso $helloAssoEntity, array $routeParts): array {
|
|
public function getResource(HelloAsso $helloAssoEntity, array $routeParts): array {
|
|
|
if (!$helloAssoEntity->getOrganizationSlug() || !$helloAssoEntity->getToken()) {
|
|
if (!$helloAssoEntity->getOrganizationSlug() || !$helloAssoEntity->getToken()) {
|
|
|
throw new \RuntimeException('HelloAsso entity incomplete');
|
|
throw new \RuntimeException('HelloAsso entity incomplete');
|
|
@@ -235,6 +237,9 @@ class HelloAssoService extends ApiRequestService
|
|
|
return json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
|
return json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @return array<EventForm>
|
|
|
|
|
+ */
|
|
|
public function getHelloAssoEventForms(int $organizationId): array
|
|
public function getHelloAssoEventForms(int $organizationId): array
|
|
|
{
|
|
{
|
|
|
$helloAssoEntity = $this->getHelloAssoEntityFor($organizationId);
|
|
$helloAssoEntity = $this->getHelloAssoEntityFor($organizationId);
|
|
@@ -302,7 +307,7 @@ class HelloAssoService extends ApiRequestService
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Construit un objet EventForm à partir des données retournées par l'api HelloAsso.
|
|
* Construit un objet EventForm à partir des données retournées par l'api HelloAsso.
|
|
|
- * @param array $formData
|
|
|
|
|
|
|
+ * @param array<string, mixed> $formData
|
|
|
* @return EventForm
|
|
* @return EventForm
|
|
|
*/
|
|
*/
|
|
|
protected function makeHelloAssoEventForm(array $formData): EventForm {
|
|
protected function makeHelloAssoEventForm(array $formData): EventForm {
|
|
@@ -413,7 +418,8 @@ class HelloAssoService extends ApiRequestService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Les tokens ont une durée de validité de 30min, on les rafraichit passé 25min.
|
|
// Les tokens ont une durée de validité de 30min, on les rafraichit passé 25min.
|
|
|
- $needsRefreshing = $helloAssoEntity->getRefreshTokenCreatedAt()->add(new \DateInterval('PT25M')) < DatesUtils::new();
|
|
|
|
|
|
|
+ $refreshTokenCreatedAt = \DateTime::createFromInterface($helloAssoEntity->getRefreshTokenCreatedAt());
|
|
|
|
|
+ $needsRefreshing = $refreshTokenCreatedAt->add(new \DateInterval('PT25M')) < DatesUtils::new();
|
|
|
if (!$needsRefreshing) {
|
|
if (!$needsRefreshing) {
|
|
|
return $helloAssoEntity;
|
|
return $helloAssoEntity;
|
|
|
}
|
|
}
|