diff --git a/Src/Notion.Client/Models/ExternalFile.cs b/Src/Notion.Client/Models/File/ExternalFile.cs similarity index 100% rename from Src/Notion.Client/Models/ExternalFile.cs rename to Src/Notion.Client/Models/File/ExternalFile.cs diff --git a/Src/Notion.Client/Models/File/ExternalFileWithName.cs b/Src/Notion.Client/Models/File/ExternalFileWithName.cs new file mode 100644 index 00000000..e06b0b63 --- /dev/null +++ b/Src/Notion.Client/Models/File/ExternalFileWithName.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class ExternalFileWithName : FileObjectWithName + { + public override string Type => "external"; + + [JsonProperty("external")] + public Info External { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/FileObject.cs b/Src/Notion.Client/Models/File/FileObject.cs similarity index 100% rename from Src/Notion.Client/Models/FileObject.cs rename to Src/Notion.Client/Models/File/FileObject.cs diff --git a/Src/Notion.Client/Models/File/FileObjectWithName.cs b/Src/Notion.Client/Models/File/FileObjectWithName.cs new file mode 100644 index 00000000..a7381929 --- /dev/null +++ b/Src/Notion.Client/Models/File/FileObjectWithName.cs @@ -0,0 +1,17 @@ +using JsonSubTypes; +using Newtonsoft.Json; + +namespace Notion.Client +{ + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(UploadedFileWithName), "file")] + [JsonSubtypes.KnownSubType(typeof(ExternalFileWithName), "external")] + public abstract class FileObjectWithName + { + [JsonProperty("type")] + public virtual string Type { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + } +} diff --git a/Src/Notion.Client/Models/UploadedFile.cs b/Src/Notion.Client/Models/File/UploadedFile.cs similarity index 100% rename from Src/Notion.Client/Models/UploadedFile.cs rename to Src/Notion.Client/Models/File/UploadedFile.cs diff --git a/Src/Notion.Client/Models/File/UploadedFileWithName.cs b/Src/Notion.Client/Models/File/UploadedFileWithName.cs new file mode 100644 index 00000000..e1510459 --- /dev/null +++ b/Src/Notion.Client/Models/File/UploadedFileWithName.cs @@ -0,0 +1,22 @@ +using System; +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class UploadedFileWithName : FileObjectWithName + { + public override string Type => "file"; + + [JsonProperty("file")] + public Info File { get; set; } + + public class Info + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("expiry_time")] + public DateTime ExpiryTime { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs index bd144643..5eef91f6 100644 --- a/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs +++ b/Src/Notion.Client/Models/PropertyValue/FilesPropertyValue.cs @@ -6,11 +6,6 @@ public class FilesPropertyValue : PropertyValue { public override PropertyValueType Type => PropertyValueType.Files; - public List Files { get; set; } - } - - public class FileValue - { - public string Name { get; set; } + public List Files { get; set; } } }