Correctly parse a person record when the person is not married.

This commit is contained in:
Jonathan Bernard 2022-04-18 20:38:14 -05:00
parent be482dfe41
commit 7c879a0fca
2 changed files with 7 additions and 3 deletions

View File

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

View File

@ -198,6 +198,8 @@ proc familyFromPage*(page: JsonNode): Family =
lastUpdatedAt: some(parseIso8601(page["last_edited_time"].getStr)))
proc personFromPage*(page: JsonNode): Person =
let marriedToIds = page.getRelationIds("Married To")
result = Person(
id: page["id"].getStr,
preferredName: page.getTitle("Preferred Name"),
@ -211,8 +213,10 @@ proc personFromPage*(page: JsonNode): Person =
relationshipToHff: page.getMultiSelect("Relationship to HFF"),
addresses: page.getRolledupDisplayValues("Full Address"),
addressIds: page.getRelationIds("Address"),
marriedTo: page.getRolledupDisplayValues("Married To (display)")[0],
marriedToId: page.getRelationIds("Married To")[0],
marriedTo: if marriedToIds.len == 0: ""
else: page.getRolledupDisplayValues("Married To (display)")[0],
marriedToId: if marriedToIds.len == 0: ""
else: marriedToIds[0],
anniversary: page.getDateTime("Anniversary"),
parents: page.getRolledupDisplayValues("Parents (display)"),
parentIds: page.getRelationIds("Parents"),