From 3c336bdc459411654b542ae99ec86c8550261d27 Mon Sep 17 00:00:00 2001 From: Paul Schaeflein Date: Wed, 22 Feb 2023 16:46:20 -0600 Subject: [PATCH] Add SitePageVersions --- src/Models/SitePageVersion.cs | 34 ++++++++++ .../ISitePageCollectionRequestBuilder.cs | 7 +- .../SitePages/ISitePageRequestBuilder.cs | 2 + .../ISitePageVersionCollectionPage.cs | 9 +++ .../ISitePageVersionCollectionRequest.cs | 12 ++++ ...SitePageVersionCollectionRequestBuilder.cs | 21 ++++++ .../SitePages/SitePageCollectionRequest.cs | 4 +- .../SitePageCollectionRequestBuilder.cs | 1 - .../SitePages/SitePageRequestBuilder.cs | 8 +++ .../SitePageVersionCollectionPage.cs | 8 +++ .../SitePageVersionCollectionRequest.cs | 39 +++++++++++ ...SitePageVersionCollectionRequestBuilder.cs | 29 ++++++++ test/Graph.Community.Test.csproj | 5 ++ test/Mocks/GetSitePageVersionsResponse.json | 44 ++++++++++++ test/SitePageRequestTests.cs | 68 +++++++++++++++++++ 15 files changed, 282 insertions(+), 9 deletions(-) create mode 100644 src/Models/SitePageVersion.cs create mode 100644 src/Requests/SitePages/ISitePageVersionCollectionPage.cs create mode 100644 src/Requests/SitePages/ISitePageVersionCollectionRequest.cs create mode 100644 src/Requests/SitePages/ISitePageVersionCollectionRequestBuilder.cs create mode 100644 src/Requests/SitePages/SitePageVersionCollectionPage.cs create mode 100644 src/Requests/SitePages/SitePageVersionCollectionRequest.cs create mode 100644 src/Requests/SitePages/SitePageVersionCollectionRequestBuilder.cs create mode 100644 test/Mocks/GetSitePageVersionsResponse.json diff --git a/src/Models/SitePageVersion.cs b/src/Models/SitePageVersion.cs new file mode 100644 index 0000000..4d761c3 --- /dev/null +++ b/src/Models/SitePageVersion.cs @@ -0,0 +1,34 @@ +using System; +using System.Text.Json.Serialization; +using Microsoft.Graph; + +namespace Graph.Community +{ + public class SitePageVersion : BaseItem + { + public new int Id { get; set; } + + //public string CheckInComment { get; set; } + public DateTime Created { get; set; } + public bool IsCurrentVersion { get; set; } + + // Refer to https://github.com/pnp/pnpcore/issues/581 + public string Length { get; set; } + + [JsonIgnore] + public long Size + { + get + { + if (long.TryParse(Length, out var size)) + { + return size; + } + return 0; + } + + } + + public string VersionLabel { get; set; } + } +} diff --git a/src/Requests/SitePages/ISitePageCollectionRequestBuilder.cs b/src/Requests/SitePages/ISitePageCollectionRequestBuilder.cs index da40df9..15f21cb 100644 --- a/src/Requests/SitePages/ISitePageCollectionRequestBuilder.cs +++ b/src/Requests/SitePages/ISitePageCollectionRequestBuilder.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using Microsoft.Graph; namespace Graph.Community { - public interface ISitePageCollectionRequestBuilder + public interface ISitePageCollectionRequestBuilder: IBaseRequestBuilder { /// /// Builds the request. @@ -21,6 +19,5 @@ public interface ISitePageCollectionRequestBuilder ISitePageCollectionRequest Request(IEnumerable