Add create and update dates to Delivery API response (#14427)
Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
@@ -10,6 +10,6 @@ public sealed class ApiContentBuilder : ApiContentBuilderBase<IApiContent>, IApi
|
||||
{
|
||||
}
|
||||
|
||||
protected override IApiContent Create(IPublishedContent content, Guid id, string name, string contentType, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
=> new ApiContent(id, name, contentType, route, properties);
|
||||
protected override IApiContent Create(IPublishedContent content, string name, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
=> new ApiContent(content.Key, name, content.ContentType.Alias, content.CreateDate, content.UpdateDate, route, properties);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class ApiContentBuilderBase<T>
|
||||
_outputExpansionStrategyAccessor = outputExpansionStrategyAccessor;
|
||||
}
|
||||
|
||||
protected abstract T Create(IPublishedContent content, Guid id, string name, string contentType, IApiContentRoute route, IDictionary<string, object?> properties);
|
||||
protected abstract T Create(IPublishedContent content, string name, IApiContentRoute route, IDictionary<string, object?> properties);
|
||||
|
||||
public virtual T? Build(IPublishedContent content)
|
||||
{
|
||||
@@ -34,9 +34,7 @@ public abstract class ApiContentBuilderBase<T>
|
||||
|
||||
return Create(
|
||||
content,
|
||||
content.Key,
|
||||
_apiContentNameProvider.GetName(content),
|
||||
content.ContentType.Alias,
|
||||
route,
|
||||
properties);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public sealed class ApiContentResponseBuilder : ApiContentBuilderBase<IApiConten
|
||||
: base(apiContentNameProvider, apiContentRouteBuilder, outputExpansionStrategyAccessor)
|
||||
=> _apiContentRouteBuilder = apiContentRouteBuilder;
|
||||
|
||||
protected override IApiContentResponse Create(IPublishedContent content, Guid id, string name, string contentType, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
protected override IApiContentResponse Create(IPublishedContent content, string name, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
{
|
||||
var routesByCulture = new Dictionary<string, IApiContentRoute>();
|
||||
|
||||
@@ -35,6 +35,6 @@ public sealed class ApiContentResponseBuilder : ApiContentBuilderBase<IApiConten
|
||||
routesByCulture[publishedCultureInfo.Culture] = cultureRoute;
|
||||
}
|
||||
|
||||
return new ApiContentResponse(id, name, contentType, route, properties, routesByCulture);
|
||||
return new ApiContentResponse(content.Key, name, content.ContentType.Alias, content.CreateDate, content.UpdateDate, route, properties, routesByCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,20 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
|
||||
public class ApiContent : ApiElement, IApiContent
|
||||
{
|
||||
public ApiContent(Guid id, string name, string contentType, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
public ApiContent(Guid id, string name, string contentType, DateTime createDate, DateTime updateDate, IApiContentRoute route, IDictionary<string, object?> properties)
|
||||
: base(id, contentType, properties)
|
||||
{
|
||||
Name = name;
|
||||
CreateDate = createDate;
|
||||
UpdateDate = updateDate;
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public DateTime CreateDate { get; }
|
||||
|
||||
public DateTime UpdateDate { get; }
|
||||
|
||||
public IApiContentRoute Route { get; }
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace Umbraco.Cms.Core.Models.DeliveryApi;
|
||||
|
||||
public class ApiContentResponse : ApiContent, IApiContentResponse
|
||||
{
|
||||
public ApiContentResponse(Guid id, string name, string contentType, IApiContentRoute route, IDictionary<string, object?> properties, IDictionary<string, IApiContentRoute> cultures)
|
||||
: base(id, name, contentType, route, properties)
|
||||
public ApiContentResponse(Guid id, string name, string contentType, DateTime createDate, DateTime updateDate, IApiContentRoute route, IDictionary<string, object?> properties, IDictionary<string, IApiContentRoute> cultures)
|
||||
: base(id, name, contentType, createDate, updateDate, route, properties)
|
||||
=> Cultures = cultures;
|
||||
|
||||
// a little DX; by default this dictionary will be serialized as the first part of the response due to the inner workings of the serializer.
|
||||
|
||||
@@ -4,5 +4,9 @@ public interface IApiContent : IApiElement
|
||||
{
|
||||
string? Name { get; }
|
||||
|
||||
public DateTime CreateDate { get; }
|
||||
|
||||
public DateTime UpdateDate { get; }
|
||||
|
||||
IApiContentRoute Route { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user