From da2d0d1779e39cc155444612bf79ce311559f776 Mon Sep 17 00:00:00 2001 From: Danny Adams Date: Sat, 21 Jan 2023 19:54:37 -0500 Subject: [PATCH] Update /internal/connector/support/m365Support.go Issue #2169: Serialization logic for SitePageable data types. --- src/internal/connector/support/m365Support.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/internal/connector/support/m365Support.go b/src/internal/connector/support/m365Support.go index c75787045..4abeda28c 100644 --- a/src/internal/connector/support/m365Support.go +++ b/src/internal/connector/support/m365Support.go @@ -74,6 +74,18 @@ func CreateListFromBytes(bytes []byte) (models.Listable, error) { return list, nil } +// CreatePageFromBytes transforms given bytes in models.SitePageable object +func CreatePageFromBytes(bytes []byte) (models.SitePageable, error) { + parsable, err := CreateFromBytes(bytes, models.CreateSitePageFromDiscriminatorValue) + if err != nil { + return nil, errors.Wrap(err, "createing m365 sharepoint.Page object from provided bytes") + } + + page := parsable.(models.SitePageable) + + return page, nil +} + func HasAttachments(body models.ItemBodyable) bool { if body.GetContent() == nil || body.GetContentType() == nil || *body.GetContentType() == models.TEXT_BODYTYPE || len(*body.GetContent()) == 0 {