Skip to content

Commit

Permalink
[Notion] Fixes for database props
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwsteenbergen committed Aug 3, 2024
1 parent 59f8f11 commit c296b8a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ApiLibs/NotionRest/Block/Quote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public Quote()
}

[JsonProperty("text")]
public List<RichText> Text { get; internal set; }
public List<RichText> Text { get; set; }
}
}
7 changes: 6 additions & 1 deletion ApiLibs/NotionRest/NotionDatabaseProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public class MultiSelectDatabaseProperty : NotionDatabaseProperty
public MultiSelectDatabasePropertyValue MultiSelect { get; set;}
}

public class LastEditedTimeDatabaseProperty : NotionDatabaseProperty
{
}

public class MultiSelectDatabasePropertyValue {
[JsonProperty("options")]
public Option[] Options { get; set; }
Expand Down Expand Up @@ -120,8 +124,9 @@ public override NotionDatabaseProperty ReadJson(JsonReader reader, Type objectTy
"checkbox" => new CheckboxDatabaseProperty(),
"date" => new DateDatabaseProperty(),
"title" => new TitleDatabaseProperty(),
"number" => new NumberDatabaseProperty(),
"last_edited_time" => new LastEditedTimeDatabaseProperty(),
"multi_select" => new MultiSelectDatabaseProperty(),
"number" => new NumberDatabaseProperty(),
"relation" => new RelationDatabaseProperty(),
"rich_text" => new RichTextDatabaseProperty(),
"select" => new SelectDatabaseProperty(),
Expand Down
8 changes: 7 additions & 1 deletion ApiLibs/NotionRest/ReturnClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ public partial class Text
public string Content { get; set; }

[JsonProperty("link")]
public object Link { get; set; }
public TextLink Link { get; set; }
}

public class TextLink {

[JsonProperty("url")]
public string Url { get; set; }
}

public class File : ImageSource
Expand Down
17 changes: 16 additions & 1 deletion ApiLibs/NotionRest/ReturnClassesProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public override NotionProperty ReadJson(JsonReader reader, Type objectType, Noti
"date" => new DateProperty(),
"email" => new EmailProperty(),
"phone_number" => new PhoneProperty(),
"last_edited_time" => new LastEditedTimeProperty(),
_ => throw new ArgumentOutOfRangeException("Cannot convert type " + type + jObject.ToString())
};

Expand Down Expand Up @@ -143,6 +144,13 @@ public void Set(string input)
}
}

public class LastEditedTimeProperty : NotionProperty
{

[JsonProperty("last_edited_time")]
public DateTime LastEdited { get; set; }
}

public class EmailProperty : NotionProperty, INotionProperty<string>
{

Expand Down Expand Up @@ -172,14 +180,21 @@ public void Set(string input)
}

[JsonConverter(typeof(DatePropertyConverter))]
public class DateProperty : NotionProperty
public class DateProperty : NotionProperty, INotionProperty<DateTime?>
{
[JsonProperty("start")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Start { get; set; }

[JsonProperty("end")]
public DateTime? End { get; set; }

public DateTime? Get() => Start;

public void Set(DateTime? input)
{
Start = input;
}
}

public class DateTimeConverter : JsonConverter<DateTime?>
Expand Down

0 comments on commit c296b8a

Please sign in to comment.