notionapi icon indicating copy to clipboard operation
notionapi copied to clipboard

Common interface for Block, Page, and Database

Open pierce-m opened this issue 1 year ago • 1 comments

It would be very helpful to abstract these objects away in a comment interface, as currently in our code we use a lot of switch/case such as

switch obj.Type{
  case "block":
    return obj.CreatedAt
  case "page":
    return obj.CreatedAt
}

It would be much nicer to be able to do

obj.GetCreatedAt()

simplifying the client code greatly. It seems Blocks have a common Block interface, I am wondering if we can create a common interface shared between Blocks, Pages, and Databases to access these common fields?

pierce-m avatar Oct 02 '23 19:10 pierce-m

Hi! Why not, looks easy to implement

jomei avatar Oct 03 '23 05:10 jomei