diff --git a/BrixelAPI.SpaceAPI/Domain/SpaceStateAggregate/SpaceState.cs b/BrixelAPI.SpaceAPI/Domain/SpaceStateAggregate/SpaceState.cs index ece8b7f..0c38c70 100644 --- a/BrixelAPI.SpaceAPI/Domain/SpaceStateAggregate/SpaceState.cs +++ b/BrixelAPI.SpaceAPI/Domain/SpaceStateAggregate/SpaceState.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using Schema; +using Schema.v14; namespace BrixelAPI.SpaceState.Domain.SpaceStateAggregate; @@ -18,7 +20,6 @@ public static SpaceState GetConfiguredSpaceAPI() { return new SpaceState() { - ApiCompatibility = ["0.14"], Space = "Brixel", Logo = "https://www.brixel.be/wp-content/uploads/2015/09/Logo_small_transparant.png", Url = "http://brixel.be", diff --git a/BrixelAPI.SpaceAPI/Features/GetFullStatus/GetFullStatusResponse.cs b/BrixelAPI.SpaceAPI/Features/GetFullStatus/GetFullStatusResponse.cs index 354eb4f..9de087e 100644 --- a/BrixelAPI.SpaceAPI/Features/GetFullStatus/GetFullStatusResponse.cs +++ b/BrixelAPI.SpaceAPI/Features/GetFullStatus/GetFullStatusResponse.cs @@ -1,4 +1,5 @@ using System.Linq; +using Schema.v14; namespace BrixelAPI.SpaceState.Features.GetFullStatus { @@ -6,7 +7,6 @@ public class GetFullStatusResponse : SpaceApi { public GetFullStatusResponse(Domain.SpaceStateAggregate.SpaceState spaceState) { - ApiCompatibility = spaceState.ApiCompatibility; Space = spaceState.Space; Logo = spaceState.Logo; Url = spaceState.Url; diff --git a/BrixelAPI.SpaceAPI/Schema/Schema.cs b/BrixelAPI.SpaceAPI/Schema/v14/Schema.cs similarity index 94% rename from BrixelAPI.SpaceAPI/Schema/Schema.cs rename to BrixelAPI.SpaceAPI/Schema/v14/Schema.cs index 7aa070f..5101446 100644 --- a/BrixelAPI.SpaceAPI/Schema/Schema.cs +++ b/BrixelAPI.SpaceAPI/Schema/v14/Schema.cs @@ -1,130 +1,125 @@ -// -// -// To parse this JSON data, add NuGet 'System.Text.Json' then do: -// -// using SpaceApi; -// -// var coordinate = Coordinate.FromJson(jsonString); +using System; -using System; -using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; using System.Globalization; -/// -/// SpaceAPI v14 -/// -public partial class SpaceApi +namespace Schema.v14 { /// - /// The versions your SpaceAPI endpoint supports - /// - [JsonPropertyName("api_compatibility")] - public string[] ApiCompatibility { get; set; } - - /// - /// URL(s) of webcams in your space - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("cam")] - public string[] Cam { get; set; } - - /// - /// Contact information about your space - /// - [JsonPropertyName("contact")] - public Contact Contact { get; set; } - - /// - /// Events which happened recently in your space and which could be interesting to the - /// public, like 'User X has entered/triggered/did something at timestamp Z' - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("events")] - public Event[] Events { get; set; } - - /// - /// Feeds where users can get updates of your space - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("feeds")] - public Feeds Feeds { get; set; } - - /// - /// Arbitrary links that you'd like to share - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("links")] - public Link[] Links { get; set; } - - /// - /// Position data such as a postal address or geographic coordinates - /// - [JsonPropertyName("location")] - public Location Location { get; set; } - - /// - /// URL to your space logo - /// - [JsonPropertyName("logo")] - public string Logo { get; set; } - - /// - /// A list of the different membership plans your hackerspace might have. Set the value - /// according to your billing process. For example, if your membership fee is 10€ per month, - /// but you bill it yearly (aka. the member pays the fee once per year), set the amount to - /// 120 an the billing_interval to yearly. - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("membership_plans")] - public MembershipPlan[] MembershipPlans { get; set; } - - /// - /// Your project sites (links to GitHub, wikis or wherever your projects are hosted) + /// SpaceAPI v14 /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("projects")] - public string[] Projects { get; set; } - - /// - /// Data of various sensors in your space (e.g. temperature, humidity, amount of Club-Mate - /// left, …). The only canonical property is the temp property, additional sensor - /// types may be defined by you. In this case, you are requested to share your definition for - /// inclusion in this specification. - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("sensors")] - public Sensors Sensors { get; set; } - - /// - /// The name of your space - /// - [JsonPropertyName("space")] - public string Space { get; set; } - - /// - /// A flag indicating if the hackerspace uses SpaceFED, a federated login scheme so that - /// visiting hackers can use the space WiFi with their home space credentials. - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("spacefed")] - public Spacefed Spacefed { get; set; } - - /// - /// A collection of status-related data: actual open/closed status, icons, last change - /// timestamp etc. - /// - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - [JsonPropertyName("state")] - public State State { get; set; } - - /// - /// URL to your space website - /// - [JsonPropertyName("url")] - public string Url { get; set; } + public class SpaceApi + { + /// + /// The versions your SpaceAPI endpoint supports + /// + [JsonPropertyName("api_compatibility")] + public string[] ApiCompatibility => ["14"]; + + /// + /// URL(s) of webcams in your space + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("cam")] + public string[] Cam { get; set; } + + /// + /// Contact information about your space + /// + [JsonPropertyName("contact")] + public Contact Contact { get; set; } + + /// + /// Events which happened recently in your space and which could be interesting to the + /// public, like 'User X has entered/triggered/did something at timestamp Z' + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("events")] + public Event[] Events { get; set; } + + /// + /// Feeds where users can get updates of your space + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("feeds")] + public Feeds Feeds { get; set; } + + /// + /// Arbitrary links that you'd like to share + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("links")] + public Link[] Links { get; set; } + + /// + /// Position data such as a postal address or geographic coordinates + /// + [JsonPropertyName("location")] + public Location Location { get; set; } + + /// + /// URL to your space logo + /// + [JsonPropertyName("logo")] + public string Logo { get; set; } + + /// + /// A list of the different membership plans your hackerspace might have. Set the value + /// according to your billing process. For example, if your membership fee is 10€ per month, + /// but you bill it yearly (aka. the member pays the fee once per year), set the amount to + /// 120 an the billing_interval to yearly. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("membership_plans")] + public MembershipPlan[] MembershipPlans { get; set; } + + /// + /// Your project sites (links to GitHub, wikis or wherever your projects are hosted) + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("projects")] + public string[] Projects { get; set; } + + /// + /// Data of various sensors in your space (e.g. temperature, humidity, amount of Club-Mate + /// left, …). The only canonical property is the temp property, additional sensor + /// types may be defined by you. In this case, you are requested to share your definition for + /// inclusion in this specification. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("sensors")] + public Sensors Sensors { get; set; } + + /// + /// The name of your space + /// + [JsonPropertyName("space")] + public string Space { get; set; } + + /// + /// A flag indicating if the hackerspace uses SpaceFED, a federated login scheme so that + /// visiting hackers can use the space WiFi with their home space credentials. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("spacefed")] + public Spacefed Spacefed { get; set; } + + /// + /// A collection of status-related data: actual open/closed status, icons, last change + /// timestamp etc. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [JsonPropertyName("state")] + public State State { get; set; } + + /// + /// URL to your space website + /// + [JsonPropertyName("url")] + public string Url { get; set; } + } } ///