2 Commits
0.3.0 ... 0.3.2

3 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "0.3.0"
version = "0.3.2"
author = "Jonathan Bernard"
description = "Utilities and bindings for HFF's Notion API."
license = "GPL-3.0-or-later"

View File

@ -76,6 +76,14 @@ proc fetchAllPages*(
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 =
let resp = notion.http.get(notion.apiBaseUrl & "/pages/" & pageId)

View File

@ -151,7 +151,7 @@ func toPage*(p: Person): JsonNode =
"Anniversary": makeDateProp(p.anniversary),
"Parents": makeRelationProp(p.parentIds),
"Children": makeRelationProp(p.childIds),
"API Permissions": makeMultiSelectProp(p.apiPermissions),
"System: API Permissions": makeMultiSelectProp(p.apiPermissions),
}
}
@ -208,7 +208,7 @@ proc personFromPage*(page: JsonNode): Person =
childIds: page.getRelationIds("Children"),
createdAt: some(parseIso8601(page["created_time"].getStr)),
lastUpdatedAt: some(parseIso8601(page["last_edited_time"].getStr)),
apiPermissions: page.getMultiSelect("API Permissions"))
apiPermissions: page.getMultiSelect("System: API Permissions"))
func syncRecordFromPage*(page: JsonNode): SyncRecord =
result = SyncRecord(