Add template for fetching database objects.
This commit is contained in:
parent
042adcb382
commit
b6f63cf15b
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Utilities and bindings for HFF's Notion API."
|
description = "Utilities and bindings for HFF's Notion API."
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
@ -76,6 +76,14 @@ proc fetchAllPages*(
|
|||||||
|
|
||||||
if nextCursor.isEmptyOrWhitespace: break
|
if nextCursor.isEmptyOrWhitespace: break
|
||||||
|
|
||||||
|
template fetchDatabaseObject*(notion: NotionClient, dbId: string): untyped =
|
||||||
|
let resp = notion.http.get(notion.apiBaseUrl & "/databases/" & dbId)
|
||||||
|
|
||||||
|
if not resp.status.startsWith("2"):
|
||||||
|
debug resp.body
|
||||||
|
raise newException(HttpRequestError, "API Request failed: " & resp.body)
|
||||||
|
parseJson(resp.body)
|
||||||
|
|
||||||
template fetchPage*(notion: NotionClient, pageId: string): untyped =
|
template fetchPage*(notion: NotionClient, pageId: string): untyped =
|
||||||
let resp = notion.http.get(notion.apiBaseUrl & "/pages/" & pageId)
|
let resp = notion.http.get(notion.apiBaseUrl & "/pages/" & pageId)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user