lastorel / pytion

Unofficial Python client for official Notion API
GNU General Public License v3.0
44 stars 3 forks source link

AttributeError: 'PropertyValue' object has no attribute 'value' #5

Closed lastorel closed 2 years ago

lastorel commented 2 years ago

.get_page_property("title") triggers that exception. While requesting /properties/title I can see unexpected list format:

2021-12-11 18:21:09,694 - pytion.query - DEBUG - STATUS CODE: 200
2021-12-11 18:21:09,694 - pytion.query - DEBUG - CONTENT: b'{"object":"list","results":[{"object":"property_item","type":"title","title":{"type":"text","text":{"content":"\xd0\x92\xd1\x81\xd0\xb5\xd0\xbc \xd0\xbf\xd0\xbe\xd0\xba\xd0\xb0","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"\xd0\x92\xd1\x81\xd0\xb5\xd0\xbc \xd0\xbf\xd0\xbe\xd0\xba\xd0\xb0","href":null}}],"next_cursor":null,"has_more":false}'
lastorel commented 2 years ago

Same thing happens with rich_text type, rollup type, relation type, people type,

lastorel commented 2 years ago

Expected answers:

2021-12-11 18:33:46,398 - pytion.query - DEBUG - STATUS CODE: 200
2021-12-11 18:33:46,398 - pytion.query - DEBUG - CONTENT: b'{"object":"property_item","type":"files","files":[]}'
2021-12-11 18:33:44,101 - pytion.query - DEBUG - STATUS CODE: 200
2021-12-11 18:33:44,101 - pytion.query - DEBUG - CONTENT: b'{"object":"property_item","type":"last_edited_time","last_edited_time":"2021-11-04T16:47:00.000Z"}'

relation - list (always) rich_text - list (always) people - list (always) title - list (always) rollup - list AND rollup result if not empty

lastorel commented 2 years ago

rollup - API returns validation error if content is None. relation - API should return relation key in dict like in Retrieve a page. But it returns list format with results key: Retrieving page

type: relation
relation:
  - relation dict 1
  - relation dict 2

Retrieving a page property item

object: list
results:
  - relation dict 1
  - relation dict 2

From docs:

Each individual property_item properties will have a type and under the the key with the value for type, an object that identifies the property value

I wanna to resolve which type of properties i receive without searching deeper. But I see a list only. Inconsistent view. It is not trivial to create processor for that changes.