package notion import ( "context" "github.com/jomei/notionapi" ) var client *notionapi.Client var authToken string func Init(token string) { authToken = token client = notionapi.NewClient(notionapi.Token(token)) } func GetClient() *notionapi.Client { return client } func AGetBlock(blockId string) chan struct { Block notionapi.Block Error error } { retval := make(chan struct { Block notionapi.Block Error error }) go func() { block, err := client.Block.Get(context.Background(), notionapi.BlockID(blockId)) retval <- struct { Block notionapi.Block Error error }{block, err} }() return retval } func AGetBlockChildren(blockId string, startCursor string, pageSize int) chan struct { Children []notionapi.Block NextCursor string HasMore bool Error error } { retval := make(chan struct { Children []notionapi.Block NextCursor string HasMore bool Error error }) pagination := notionapi.Pagination{StartCursor: notionapi.Cursor(startCursor), PageSize: pageSize} go func() { children, err := client.Block.GetChildren(context.Background(), notionapi.BlockID(blockId), &pagination) retval <- struct { Children []notionapi.Block NextCursor string HasMore bool Error error }{children.Results, children.NextCursor, children.HasMore, err} }() return retval }