Skip to content

Commit 35347de

Browse files
mdelmansmichaelhall28
authored andcommitted
Fixed: relationship configuration
1 parent 0e2e6b3 commit 35347de

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

python_notion_api/models/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
NumberPropertyConfiguration,
6363
PeoplePropertyConfiguration,
6464
PhoneNumberPropertyConfiguration,
65-
RelationConfigurationObject,
6665
RelationPropertyConfiguration,
6766
RollupConfigurationObject,
6867
RollupPropertyConfiguration,
@@ -220,7 +219,6 @@
220219
"PhoneNumberPropertyConfiguration",
221220
"FormulaConfigurationObject",
222221
"FormulaPropertyConfiguration",
223-
"RelationConfigurationObject",
224222
"RelationPropertyConfiguration",
225223
"RollupConfigurationObject",
226224
"RollupPropertyConfiguration",

python_notion_api/models/configurations.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,45 @@ class FormulaPropertyConfiguration(NotionPropertyConfiguration):
131131
formula: FormulaConfigurationObject
132132

133133

134-
class RelationConfigurationObject(BaseModel):
134+
class RelationPropertyConfiguration(NotionPropertyConfiguration):
135+
@property
136+
def _class_key_field(self):
137+
return self.relation["type"]
138+
139+
_class_map = {
140+
"single_property": "SinglePropertyConfiguration",
141+
"dual_property": "DualPropertyConfiguration",
142+
}
143+
144+
relation: Dict
145+
146+
147+
class SinglePropertyConfigurationObject(BaseModel):
135148
database_id: str
136-
synced_property_name: Optional[str]
137-
synced_property_id: Optional[str]
149+
relation_type: str = typeField
150+
single_property: Dict
138151

139152

140-
class RelationPropertyConfiguration(NotionPropertyConfiguration):
153+
class SinglePropertyConfiguration(RelationPropertyConfiguration):
154+
_class_key_field = None
155+
156+
relation: SinglePropertyConfigurationObject
157+
158+
159+
class SyncedPropertyConfigurationObject(BaseModel):
160+
synced_property_id: str
161+
synced_property_name: str
162+
163+
164+
class DualPropertyConfigurationObject(BaseModel):
165+
database_id: str
166+
dual_property: SyncedPropertyConfigurationObject
167+
168+
169+
class DualPropertyConfiguration(RelationPropertyConfiguration):
141170
_class_key_field = None
142171

143-
relation: RelationConfigurationObject
172+
relation: DualPropertyConfigurationObject
144173

145174

146175
class RollupConfigurationObject(BaseModel):

0 commit comments

Comments
 (0)