Skip to content

Commit 1cbc00f

Browse files
authored
feat: Use env vars to override generated activity / facilityType (#198)
1 parent 6564d5e commit 1cbc00f

6 files changed

Lines changed: 30 additions & 12 deletions

File tree

Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public AcmeFacilityUseRpdeGenerator(AppSettings appSettings, FakeBookingSystem f
2626

2727
protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? afterTimestamp, long? afterId)
2828
{
29+
var facilityTypeId = Environment.GetEnvironmentVariable("FACILITY_TYPE_ID") ?? "https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651";
30+
var facilityTypePrefLabel = Environment.GetEnvironmentVariable("FACILITY_TYPE_PREF_LABEL") ?? "Squash Court";
31+
2932
using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
3033
{
3134
var q = db.From<FacilityUseTable>()
@@ -93,8 +96,8 @@ protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? af
9396
FacilityType = new List<Concept> {
9497
new Concept
9598
{
96-
Id = new Uri("https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651"),
97-
PrefLabel = "Squash Court",
99+
Id = new Uri(facilityTypeId),
100+
PrefLabel = facilityTypePrefLabel,
98101
InScheme = new Uri("https://openactive.io/facility-types")
99102
}
100103
}

Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public AcmeSessionSeriesRpdeGenerator(AppSettings appSettings, FakeBookingSystem
8585

8686
protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long? afterTimestamp, long? afterId)
8787
{
88+
var activityId = Environment.GetEnvironmentVariable("ACTIVITY_ID") ?? "https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83";
89+
var activityPrefLabel = Environment.GetEnvironmentVariable("ACTIVITY_PREF_LABEL") ?? "Jet Skiing";
90+
8891
using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
8992
{
9093
var q = db.From<ClassTable>()
@@ -178,8 +181,8 @@ protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long?
178181
{
179182
new Concept
180183
{
181-
Id = new Uri("https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83"),
182-
PrefLabel = "Jet Skiing",
184+
Id = new Uri(activityId),
185+
PrefLabel = activityPrefLabel,
183186
InScheme = new Uri("https://openactive.io/activity-list")
184187
}
185188
}

Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula
288288
// Similar to the RPDE logic, this needs to render and return an new hypothetical OrderItem from the database based on the supplied opportunity IDs
289289
protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpportunity>> orderItemContexts, StoreBookingFlowContext flowContext, OrderStateContext stateContext)
290290
{
291+
var facilityTypeId = Environment.GetEnvironmentVariable("FACILITY_TYPE_ID") ?? "https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651";
292+
var facilityTypePrefLabel = Environment.GetEnvironmentVariable("FACILITY_TYPE_PREF_LABEL") ?? "Squash Court";
293+
291294
// Note the implementation of this method must also check that this OrderItem is from the Seller specified by context.SellerId (this is not required if using a Single Seller)
292295

293296
// Additionally this method must check that there are enough spaces in each entry
@@ -343,8 +346,8 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
343346
FacilityType = new List<Concept> {
344347
new Concept
345348
{
346-
Id = new Uri("https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651"),
347-
PrefLabel = "Squash Court",
349+
Id = new Uri(facilityTypeId),
350+
PrefLabel = facilityTypePrefLabel,
348351
InScheme = new Uri("https://openactive.io/facility-types")
349352
}
350353
}

Examples/BookingSystem.AspNetFramework/Feeds/FacilitiesFeeds.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public AcmeFacilityUseRpdeGenerator(AppSettings appSettings, FakeBookingSystem f
2626

2727
protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? afterTimestamp, long? afterId)
2828
{
29+
var facilityTypeId = Environment.GetEnvironmentVariable("FACILITY_TYPE_ID") ?? "https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651";
30+
var facilityTypePrefLabel = Environment.GetEnvironmentVariable("FACILITY_TYPE_PREF_LABEL") ?? "Squash Court";
31+
2932
using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
3033
{
3134
var q = db.From<FacilityUseTable>()
@@ -93,8 +96,8 @@ protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? af
9396
FacilityType = new List<Concept> {
9497
new Concept
9598
{
96-
Id = new Uri("https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651"),
97-
PrefLabel = "Squash Court",
99+
Id = new Uri(facilityTypeId),
100+
PrefLabel = facilityTypePrefLabel,
98101
InScheme = new Uri("https://openactive.io/facility-types")
99102
}
100103
}

Examples/BookingSystem.AspNetFramework/Feeds/SessionsFeeds.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public AcmeSessionSeriesRpdeGenerator(AppSettings appSettings, FakeBookingSystem
8585

8686
protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long? afterTimestamp, long? afterId)
8787
{
88+
var activityId = Environment.GetEnvironmentVariable("ACTIVITY_ID") ?? "https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83";
89+
var activityPrefLabel = Environment.GetEnvironmentVariable("ACTIVITY_PREF_LABEL") ?? "Jet Skiing";
90+
8891
using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
8992
{
9093
var q = db.From<ClassTable>()
@@ -178,8 +181,8 @@ protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long?
178181
{
179182
new Concept
180183
{
181-
Id = new Uri("https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83"),
182-
PrefLabel = "Jet Skiing",
184+
Id = new Uri(activityId),
185+
PrefLabel = activityPrefLabel,
183186
InScheme = new Uri("https://openactive.io/activity-list")
184187
}
185188
}

Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ protected override async Task TriggerTestAction(OpenBookingSimulateAction simula
288288
// Similar to the RPDE logic, this needs to render and return an new hypothetical OrderItem from the database based on the supplied opportunity IDs
289289
protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpportunity>> orderItemContexts, StoreBookingFlowContext flowContext, OrderStateContext stateContext)
290290
{
291+
var facilityTypeId = Environment.GetEnvironmentVariable("FACILITY_TYPE_ID") ?? "https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651";
292+
var facilityTypePrefLabel = Environment.GetEnvironmentVariable("FACILITY_TYPE_PREF_LABEL") ?? "Squash Court";
293+
291294
// Note the implementation of this method must also check that this OrderItem is from the Seller specified by context.SellerId (this is not required if using a Single Seller)
292295

293296
// Additionally this method must check that there are enough spaces in each entry
@@ -343,8 +346,8 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
343346
FacilityType = new List<Concept> {
344347
new Concept
345348
{
346-
Id = new Uri("https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651"),
347-
PrefLabel = "Squash Court",
349+
Id = new Uri(facilityTypeId),
350+
PrefLabel = facilityTypePrefLabel,
348351
InScheme = new Uri("https://openactive.io/facility-types")
349352
}
350353
}

0 commit comments

Comments
 (0)