-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement page creation #37
Changes from all commits
06319d2
5e14213
bfbc587
787d1a9
9756257
39c82b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,6 +178,13 @@ impl Properties { | |
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] | ||
pub struct PageCreate { | ||
pub parent: Parent, | ||
pub properties: Properties, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is possible: imagine that the property gets renamed/created/etc between the request to find available properties and the one to create things. Then you're missing a property in spite of requiring the client to give all the known ones. It's not a problem to intentionally exclude some properties as the caller, it just means your row will be missing some properties as well, which is not an error. |
||
pub children: Vec<Block>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] | ||
pub struct Page { | ||
pub id: PageId, | ||
|
@@ -189,6 +196,7 @@ pub struct Page { | |
pub archived: bool, | ||
pub properties: Properties, | ||
pub parent: Parent, | ||
pub url: String, | ||
} | ||
|
||
impl Page { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,5 +54,6 @@ | |
} | ||
] | ||
} | ||
} | ||
}, | ||
"url": "https://www.notion.so/Avocado-b55c9c91384d452b81dbd1ef79372b75" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the
PropertyValue
supplied doesn't have an identifier?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what you mean by not having an identifier? PropertyValue guarantees that the property has its respective id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! What if it doesn't have a property? Then that property is blank in the resulting row. I know this because my program just ignores some properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more coming at a perspective of should the Caller have to know of the
PropertyValue
's identifier before making thecreate_page
call. This would require them to always have to make a GET request first to retrieve them in the case of a database.Frankly, the identifiers for
PropertyValues
from Notion are a bit odd. Notion doesn't allow you to create multiple properties with the same name so the name is effectively the same as the identifier. The API Spec for Create Page even calls out that the key of the Map should be the Name OR identifier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I think maybe the Property thing should be refactored to store an alternative between the two possibilities, maybe? I'm not sure how to best approach it.
One strategy would be a slight abuse: put the name in as the identifier value even though it's not an identifier really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think where my head was at (from the other comment) was that the existing "response" models shouldn't be reused as "request" models.