Skip to content

Commit

Permalink
Fix startDate and endDate for ScheduledSessions and Slots (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
openactive-bot authored Mar 3, 2021
1 parent b25010c commit ee71319
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
8 changes: 4 additions & 4 deletions OpenActive.NET.Test/OrderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public void OrderQuote_EncodeDecode()
"\"orderedItem\":{" +
"\"@type\":\"ScheduledSession\"," +
"\"@id\":\"https://example.com/events/452/subEvents/132\"," +
"\"startDate\":\"2018-10-30T11:00:00+00:00\"," +
"\"identifier\":123," +
"\"endDate\":\"2018-10-30T12:00:00+00:00\"," +
"\"superEvent\":{" +
"\"@type\":\"SessionSeries\"," +
"\"@id\":\"https://example.com/events/452\"," +
Expand Down Expand Up @@ -228,9 +230,7 @@ public void OrderQuote_EncodeDecode()
"}" +
"}," +
"\"duration\":\"PT1H\"," +
"\"eventStatus\":\"https://schema.org/EventScheduled\"," +
"\"startDate\":\"2018-10-30T11:00:00+00:00\"," +
"\"endDate\":\"2018-10-30T12:00:00+00:00\"" +
"\"eventStatus\":\"https://schema.org/EventScheduled\"" +
"}," +
"\"orderItemStatus\":\"https://openactive.io/OrderItemConfirmed\"," +
"\"unitTaxSpecification\":[" +
Expand Down Expand Up @@ -331,7 +331,7 @@ public void Order_Deserialize_Accessors()
Assert.Equal("Geoff", order?.Customer.GivenName);
Assert.Equal("EUCODE", order?.OrderedItem?[0]?.UnitTaxSpecification?[0]?.Identifier.GetClass<List<PropertyValue>>()?[0].Name);
Assert.Equal(new TimeSpan(6,0,0,0), order?.OrderedItem?[0]?.AcceptedOffer?.ValidFromBeforeStartDate);
Assert.Equal(new DateTimeOffset(2018, 10, 30, 11, 00, 00, 00, new TimeSpan()), order?.OrderedItem?[0]?.OrderedItem?.StartDate.GetPrimative<DateTimeOffset>());
Assert.Equal(new DateTimeOffset(2018, 10, 30, 11, 00, 00, 00, new TimeSpan()), ((ScheduledSession)order?.OrderedItem?[0]?.OrderedItem)?.StartDate);
}

[Fact]
Expand Down
27 changes: 26 additions & 1 deletion OpenActive.NET/models/ScheduledSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,38 @@ public override string ToString()
[DataMember(Name = "@type", Order = 1)]
public override string Type => "ScheduledSession";

/// <summary>
/// The start date and time of the event.
/// </summary>
/// <example>
/// <code>
/// "startDate": "2018-01-27T12:00:00Z"
/// </code>
/// </example>
[DataMember(Name = "startDate", EmitDefaultValue = false, Order = 7)]
[JsonConverter(typeof(OpenActiveDateTimeOffsetToISO8601DateTimeValuesConverter))]
public new virtual DateTimeOffset? StartDate { get; set; }

/// <summary>
/// The end date and time of the event.
/// It is recommended that publishers provide either an schema:endDate or a schema:duration for an event.
/// </summary>
/// <example>
/// <code>
/// "endDate": "2018-01-27T12:00:00Z"
/// </code>
/// </example>
[DataMember(Name = "endDate", EmitDefaultValue = false, Order = 8)]
[JsonConverter(typeof(OpenActiveDateTimeOffsetToISO8601DateTimeValuesConverter))]
public new virtual DateTimeOffset? EndDate { get; set; }

[Obsolete("This property is disinherited in this type, and must not be used.", true)]
public override List<Event> SubEvent { get; set; }

/// <summary>
/// Relates a child event to a parent event. Properties describing the parent event can be assumed to apply to the child, unless otherwise specified. A parent event might specify a recurring schedule, of which the child event is one specific instance
/// </summary>
[DataMember(Name = "superEvent", EmitDefaultValue = false, Order = 8)]
[DataMember(Name = "superEvent", EmitDefaultValue = false, Order = 10)]
[JsonConverter(typeof(ValuesConverter))]
public new virtual SingleValues<Uri, Event> SuperEvent { get; set; }
}
Expand Down
8 changes: 7 additions & 1 deletion OpenActive.NET/models/SessionSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ public override string ToString()
[Obsolete("This property is disinherited in this type, and must not be used.", true)]
public override long? RemainingAttendeeCapacity { get; set; }

[Obsolete("This property is disinherited in this type, and must not be used.", true)]
public override SingleValues<string, DateTimeOffset?> StartDate { get; set; }

[Obsolete("This property is disinherited in this type, and must not be used.", true)]
public override SingleValues<string, DateTimeOffset?> EndDate { get; set; }

/// <summary>
/// Relates a parent event to a child event. Properties describing the parent event can be assumed to apply to the child, unless otherwise specified. A child event might be a specific instance of an Event within a schedule
/// </summary>
[DataMember(Name = "subEvent", EmitDefaultValue = false, Order = 9)]
[DataMember(Name = "subEvent", EmitDefaultValue = false, Order = 11)]
[JsonConverter(typeof(ValuesConverter))]
public new virtual List<ScheduledSession> SubEvent { get; set; }
}
Expand Down
12 changes: 6 additions & 6 deletions OpenActive.NET/models/Slot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,19 @@ public override string ToString()
public override string SchedulingNote { get; set; }

/// <summary>
/// The start date and time of the slot. Can be specified as a schema:Date or schema:DateTime
/// The start date and time of the slot.
/// </summary>
/// <example>
/// <code>
/// "startDate": "2018-01-27T12:00:00Z"
/// </code>
/// </example>
[DataMember(Name = "startDate", EmitDefaultValue = false, Order = 39)]
[JsonConverter(typeof(ValuesConverter))]
public override SingleValues<string, DateTimeOffset?> StartDate { get; set; }
[JsonConverter(typeof(OpenActiveDateTimeOffsetToISO8601DateTimeValuesConverter))]
public new virtual DateTimeOffset? StartDate { get; set; }

/// <summary>
/// The end date and time of the slot. Can be specified as a schema:Date or schema:DateTime
/// The end date and time of the slot.
/// It is recommended that publishers provide either an schema:endDate or a schema:duration for an slot.
/// </summary>
/// <example>
Expand All @@ -223,8 +223,8 @@ public override string ToString()
/// </code>
/// </example>
[DataMember(Name = "endDate", EmitDefaultValue = false, Order = 40)]
[JsonConverter(typeof(ValuesConverter))]
public override SingleValues<string, DateTimeOffset?> EndDate { get; set; }
[JsonConverter(typeof(OpenActiveDateTimeOffsetToISO8601DateTimeValuesConverter))]
public new virtual DateTimeOffset? EndDate { get; set; }

[Obsolete("This property is disinherited in this type, and must not be used.", true)]
public override List<Event> SubEvent { get; set; }
Expand Down

0 comments on commit ee71319

Please sign in to comment.