Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the documentation was wrong #1

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/Service/PolisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@ public function __construct(
) {
}

private function translatePolisLanguageCode(string $languageCode): string
{
return match ($languageCode) {
'rm' => 'rr',
default => $languageCode,
};
}

public function fetchPolisCaseByVotationId(int $id, string $language): PolisCase
{
$votationResponse = $this->client->request('GET', sprintf('/polis-api/v2/votations/%s?lang=%s', $id, $this->translatePolisLanguageCode($language)));
$votationResponse = $this->client->request('GET', sprintf('/polis-api/v2/votations/%s?lang=%s', $id, $language));
$data = $votationResponse->toArray();

$case = [];
Expand Down Expand Up @@ -99,12 +91,12 @@ public function fetchPolisCaseByVotationId(int $id, string $language): PolisCase

public function fetchPolisVotationById(int $id, string $language): PolisVotation
{
return $this->fetchPolisCaseByVotationId($id, $this->translatePolisLanguageCode($language))->votations[0];
return $this->fetchPolisCaseByVotationId($id, $language)->votations[0];
}

public function fetchPolisCaseById(int $id, string $language = 'de'): PolisCase
{
$caseData = $this->client->request('GET', sprintf('/polis-api/v2/cases/%s?lang=%s', $id, $this->translatePolisLanguageCode($language)));
$caseData = $this->client->request('GET', sprintf('/polis-api/v2/cases/%s?lang=%s', $id, $language));
$data = $caseData->toArray();

return $this->denormalizePolisCase($data['Case'][0]);
Expand All @@ -114,7 +106,7 @@ public function fetchPolisCases(string $language = 'de', bool $onlyActive = true
{
$caseData = $this->client->request('GET', sprintf(
'/polis-api/v2/cases?lang=%s&listAllCases=%s',
$this->translatePolisLanguageCode($language),
$language,
$onlyActive ? 'false' : 'true'
));
$data = $caseData->toArray();
Expand Down
Loading