Skip to content

Commit

Permalink
Merge branch 'master' into feature/docker-image
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk authored Aug 2, 2023
2 parents da48620 + 99b7c40 commit 3310bea
Show file tree
Hide file tree
Showing 31 changed files with 1,035 additions and 750 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/openactive-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fail-fast: false
matrix:
mode: ['random', 'controlled']
profile: ['all-features', 'single-seller', 'no-payment-reconciliation', 'no-auth', 'no-tax-calculation', 'prepayment-always-required']
profile: ['all-features', 'single-seller', 'no-payment-reconciliation', 'no-auth', 'no-tax-calculation', 'prepayment-always-required', 'facilityuse-has-slots']
steps:
- name: Checkout OpenActive.Server.NET
uses: actions/checkout@v2
Expand Down Expand Up @@ -177,7 +177,6 @@ jobs:
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
- framework
runs-on: ubuntu-latest
steps:
# Checkout the repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@
public class AppSettings
{
public string JsonLdIdBaseUrl { get; set; }
public FeatureSettings FeatureFlags { get; set; }
}

/**
* Note feature defaults are set here, and are used for the .NET Framework reference implementation
*/
public class FeatureSettings
{
public bool FacilityUseHasSlots { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Startup(IWebHostEnvironment environment, IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IClientStore, ClientStore>();
services.AddSingleton<FakeBookingSystem>();
services.AddSingleton(x => new FakeBookingSystem(AppSettings.FeatureFlags.FacilityUseHasSlots));

var builder = services.AddIdentityServer(options =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"FeatureFlags": {
"FacilityUseHasSlots": true
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Urls": "https://localhost:5003;http://localhost:5002",
"JsonLdIdBaseUrl": "https://localhost:5001"
"JsonLdIdBaseUrl": "https://localhost:5001",
"FeatureFlags": {
"FacilityUseHasSlots": false
}
}
58 changes: 32 additions & 26 deletions Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public AcmeFacilityUseRpdeGenerator(AppSettings appSettings, FakeBookingSystem f

protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? afterTimestamp, long? afterId)
{
var facilityTypeId = Environment.GetEnvironmentVariable("FACILITY_TYPE_ID") ?? "https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651";
var facilityTypePrefLabel = Environment.GetEnvironmentVariable("FACILITY_TYPE_PREF_LABEL") ?? "Squash Court";

using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
{
var q = db.From<FacilityUseTable>()
Expand Down Expand Up @@ -88,32 +91,26 @@ protected override async Task<List<RpdeItem<FacilityUse>>> GetRpdeItems(long? af
},
IsOpenBookingAllowed = true,
},
Location = new Place
{
Name = "Fake Pond",
Address = new PostalAddress
{
StreetAddress = "1 Fake Park",
AddressLocality = "Another town",
AddressRegion = "Oxfordshire",
PostalCode = "OX1 1AA",
AddressCountry = "GB"
},
Geo = new GeoCoordinates
{
Latitude = result.Item1.LocationLat,
Longitude = result.Item1.LocationLng
}
},
Location = _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId),
Url = new Uri("https://www.example.com/a-session-age"),
FacilityType = new List<Concept> {
new Concept
{
Id = new Uri("https://openactive.io/facility-types#a1f82b7a-1258-4d9a-8dc5-bfc2ae961651"),
PrefLabel = "Squash Court",
Id = new Uri(facilityTypeId),
PrefLabel = facilityTypePrefLabel,
InScheme = new Uri("https://openactive.io/facility-types")
}
}
},
IndividualFacilityUse = result.Item1.IndividualFacilityUses != null ? result.Item1.IndividualFacilityUses.Select(ifu => new OpenActive.NET.IndividualFacilityUse
{
Id = RenderOpportunityId(new FacilityOpportunity
{
OpportunityType = OpportunityType.IndividualFacilityUse,
IndividualFacilityUseId = ifu.Id,
FacilityUseId = result.Item1.Id
}),
Name = ifu.Name
}).ToList() : null,
}
});

Expand Down Expand Up @@ -149,7 +146,7 @@ protected override async Task<List<RpdeItem<Slot>>> GetRpdeItems(long? afterTime
.Take(RpdePageSize)
.Select(x => new RpdeItem<Slot>
{
Kind = RpdeKind.FacilityUseSlot,
Kind = _appSettings.FeatureFlags.FacilityUseHasSlots ? RpdeKind.FacilityUseSlot : RpdeKind.IndividualFacilityUseSlot,
Id = x.Id,
Modified = x.Modified,
State = x.Deleted ? RpdeState.Deleted : RpdeState.Updated,
Expand All @@ -160,14 +157,22 @@ protected override async Task<List<RpdeItem<Slot>>> GetRpdeItems(long? afterTime
// constant as power of configuration through underlying class grows (i.e. as new properties are added)
Id = RenderOpportunityId(new FacilityOpportunity
{
OpportunityType = OpportunityType.FacilityUseSlot,
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
FacilityUseId = x.FacilityUseId,
SlotId = x.Id
SlotId = x.Id,
IndividualFacilityUseId = !_appSettings.FeatureFlags.FacilityUseHasSlots ? x.IndividualFacilityUseId : null,
}),
FacilityUse = RenderOpportunityId(new FacilityOpportunity
FacilityUse = _appSettings.FeatureFlags.FacilityUseHasSlots ?
RenderOpportunityId(new FacilityOpportunity
{
OpportunityType = OpportunityType.FacilityUse,
FacilityUseId = x.FacilityUseId
})
: RenderOpportunityId(new FacilityOpportunity
{
OpportunityType = OpportunityType.IndividualFacilityUse,
IndividualFacilityUseId = x.IndividualFacilityUseId,
FacilityUseId = x.FacilityUseId,
}),
Identifier = x.Id,
StartDate = (DateTimeOffset)x.Start,
Expand All @@ -180,9 +185,10 @@ protected override async Task<List<RpdeItem<Slot>>> GetRpdeItems(long? afterTime
Id = RenderOfferId(new FacilityOpportunity
{
OfferId = 0,
OpportunityType = OpportunityType.FacilityUseSlot,
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
FacilityUseId = x.FacilityUseId,
SlotId = x.Id
SlotId = x.Id,
IndividualFacilityUseId = !_appSettings.FeatureFlags.FacilityUseHasSlots ? x.IndividualFacilityUseId : null,
}),
Price = x.Price,
PriceCurrency = "GBP",
Expand Down
43 changes: 7 additions & 36 deletions Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public AcmeSessionSeriesRpdeGenerator(AppSettings appSettings, FakeBookingSystem

protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long? afterTimestamp, long? afterId)
{
var activityId = Environment.GetEnvironmentVariable("ACTIVITY_ID") ?? "https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83";
var activityPrefLabel = Environment.GetEnvironmentVariable("ACTIVITY_PREF_LABEL") ?? "Jet Skiing";

using (var db = _fakeBookingSystem.Database.Mem.Database.Open())
{
var q = db.From<ClassTable>()
Expand Down Expand Up @@ -171,47 +174,15 @@ protected override async Task<List<RpdeItem<SessionSeries>>> GetRpdeItems(long?
AllowCustomerCancellationFullRefund = result.Item1.AllowCustomerCancellationFullRefund
}
},
Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : new Place
{
Name = "Fake Pond",
Address = new PostalAddress
{
StreetAddress = "1 Fake Park",
AddressLocality = "Another town",
AddressRegion = "Oxfordshire",
PostalCode = "OX1 1AA",
AddressCountry = "GB"
},
Geo = new GeoCoordinates
{
Latitude = result.Item1.LocationLat,
Longitude = result.Item1.LocationLng,
}
},
AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : new Place
{
Name = "Fake Pond",
Address = new PostalAddress
{
StreetAddress = "1 Fake Park",
AddressLocality = "Another town",
AddressRegion = "Oxfordshire",
PostalCode = "OX1 1AA",
AddressCountry = "GB"
},
Geo = new GeoCoordinates
{
Latitude = result.Item1.LocationLat,
Longitude = result.Item1.LocationLng,
}
},
Location = result.Item1.AttendanceMode == AttendanceMode.Online ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId),
AffiliatedLocation = result.Item1.AttendanceMode == AttendanceMode.Offline ? null : _fakeBookingSystem.Database.GetPlaceById(result.Item1.PlaceId),
Url = new Uri("https://www.example.com/a-session-age"),
Activity = new List<Concept>
{
new Concept
{
Id = new Uri("https://openactive.io/activity-list#c07d63a0-8eb9-4602-8bcc-23be6deb8f83"),
PrefLabel = "Jet Skiing",
Id = new Uri(activityId),
PrefLabel = activityPrefLabel,
InScheme = new Uri("https://openactive.io/activity-list")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class FacilityOpportunity : IBookableIdComponents
public long? FacilityUseId { get; set; }
public long? SlotId { get; set; }
public long? OfferId { get; set; }
public long? IndividualFacilityUseId { get; set; }

public override bool Equals(object obj)
{
Expand All @@ -27,7 +28,8 @@ public override bool Equals(object obj)
return OpportunityType == other.OpportunityType &&
FacilityUseId == other.FacilityUseId &&
SlotId == other.SlotId &&
OfferId == other.OfferId;
OfferId == other.OfferId &&
IndividualFacilityUseId == other.IndividualFacilityUseId;
}

public override int GetHashCode()
Expand All @@ -39,6 +41,7 @@ public override int GetHashCode()
hashCode = (hashCode * 397) ^ FacilityUseId.GetHashCode();
hashCode = (hashCode * 397) ^ SlotId.GetHashCode();
hashCode = (hashCode * 397) ^ OfferId.GetHashCode();
hashCode = (hashCode * 397) ^ IndividualFacilityUseId.GetHashCode();
// ReSharper enable NonReadonlyMemberInGetHashCode
return hashCode;
}
Expand Down
2 changes: 2 additions & 0 deletions Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ public class FeatureSettings
{
public bool EnableTokenAuth { get; set; } = true;
public bool SingleSeller { get; set; } = false;
public bool CustomBuiltSystem { get; set; } = false;
public bool PaymentReconciliationDetailValidation { get; set; } = true;
public bool OnlyFreeOpportunities { get; set; } = false;
public bool PrepaymentAlwaysRequired { get; set; } = false;
public bool FacilityUseHasSlots { get; set; } = false;
}

public class PaymentSettings
Expand Down
Loading

0 comments on commit 3310bea

Please sign in to comment.