Skip to content

Commit 7cfc9cc

Browse files
authored
Merge pull request #362 from os2display/feature/352-support-other-api-versions
#352 Feature: Make API version configurable
2 parents e3dc076 + 25c9bc1 commit 7cfc9cc

4 files changed

Lines changed: 37 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- [#362](https://github.com/os2display/display-api-service/pull/362)
10+
- Added new API version field and variable to handle new feature from issue #352.
11+
712
- [#385](https://github.com/os2display/display-api-service/pull/385)
813
- Replaced PSR-6 caching with Symfony `CacheInterface::get()` in
914
`FeedService` and `EventDatabaseApiV2FeedType` for stampede prevention.
@@ -29,9 +34,12 @@ All notable changes to this project will be documented in this file.
2934

3035
## [2.6.1] - 2026-03-06
3136

32-
- [#347](https://github.com/os2display/display-api-service/pull/347)
33-
- Added onFlush listener to handle ManyToMany collection changes for relations checksum propagation.
34-
- Added command to refresh relation checksums.
37+
### Added
38+
39+
- [#347](https://github.com/os2display/display-api-service/pull/347):
40+
Added onFlush listener to handle ManyToMany collection changes for
41+
relations checksum propagation.
42+
- [#347](https://github.com/os2display/display-api-service/pull/347): Added command to refresh relation checksums.
3543

3644
## [2.6.0] - 2025-12-05
3745

@@ -41,7 +49,7 @@ All notable changes to this project will be documented in this file.
4149
- Fix date parsing issue in BRND booking feed type
4250
- [#313](https://github.com/os2display/display-api-service/pull/313)
4351
- Add BRND booking feed type
44-
52+
4553
## [2.5.2] - 2025-09-25
4654

4755
- [#260](https://github.com/os2display/display-api-service/pull/260)

src/Feed/BrndFeedType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public function getRequiredSecrets(): array
168168
'type' => 'string',
169169
'exposeValue' => false,
170170
],
171+
'api_version' => [
172+
'type' => 'string',
173+
'exposeValue' => true,
174+
],
171175
];
172176
}
173177

@@ -197,6 +201,11 @@ public function getSchema(): array
197201
'api_auth_key' => [
198202
'type' => 'string',
199203
],
204+
'api_version' => [
205+
'type' => 'string',
206+
'pattern' => '^\d+(\.\d+)?$',
207+
'default' => '1.0',
208+
],
200209
],
201210
'required' => ['api_base_uri', 'company_id', 'api_auth_key'],
202211
];

src/Feed/SourceType/Brnd/ApiClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ private function getInfomonitorBookingsDetailsData(
9494
try {
9595
$client = $this->getApiClient($feedSource);
9696

97-
return $client->request('POST', '/v1.0/get-infomonitor-bookings-details', [
97+
$versionPath = '/v'.$secrets->apiVersion;
98+
99+
return $client->request('POST', $versionPath.'/get-infomonitor-bookings-details', [
98100
'json' => [
99101
'companyID' => $secrets->companyId,
100102
'associationID' => $sportCenterId,
@@ -164,7 +166,8 @@ private function fetchToken(FeedSource $feedSource): string
164166
} else {
165167
try {
166168
$secrets = new SecretsDTO($feedSource);
167-
$response = $this->client->request('POST', $secrets->apiBaseUri.'/v1.0/generate-token', [
169+
$versionPath = '/v'.$secrets->apiVersion;
170+
$response = $this->client->request('POST', $secrets->apiBaseUri.$versionPath.'/generate-token', [
168171
'headers' => [
169172
'Content-Type' => 'application/json',
170173
'Accept' => '*/*',

src/Feed/SourceType/Brnd/SecretsDTO.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
public string $apiBaseUri;
1212
public string $apiAuthKey;
1313
public string $companyId;
14+
public string $apiVersion;
1415

1516
public function __construct(FeedSource $feedSource)
1617
{
@@ -29,7 +30,15 @@ public function __construct(FeedSource $feedSource)
2930
}
3031

3132
$this->apiBaseUri = rtrim((string) $secrets['api_base_uri'], '/');
32-
$this->companyId = $secrets['company_id'];
33-
$this->apiAuthKey = $secrets['api_auth_key'];
33+
$this->companyId = (string) $secrets['company_id'];
34+
$this->apiAuthKey = (string) $secrets['api_auth_key'];
35+
36+
$version = $secrets['api_version'] ?? '1.0';
37+
38+
if (!is_string($version) || 1 !== preg_match('/^\d+(\.\d+)?$/', $version)) {
39+
throw new \RuntimeException('Invalid api_version. Expected format like "1.0" or "2.0".');
40+
}
41+
42+
$this->apiVersion = $version;
3443
}
3544
}

0 commit comments

Comments
 (0)