-
Notifications
You must be signed in to change notification settings - Fork 2
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 documents.create #20
Conversation
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.
Didn't had a look at the code, but only about the CI improvement.
Did you saw #18?
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.
Code looks good so far 👌 Didn't tested it but should work 😉
Just a few nitpitting questions/comments.
Thanks for the efford and the contribution 👍
documents.go
Outdated
// title: The title of the document (optional, set to empty string to omit). | ||
// text: The content text of the document. | ||
// publish: A boolean indicating whether the document should be published. | ||
func (cl *DocumentsClient) Create(collectionID CollectionID, title string, text string, publish bool, parentDocumentId ParentDocumentID, templateId TemplateID, template bool) *DocumentsClientCreate { |
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.
Do we already want to go with such a complicated strucutre?
We need it earlier or later anyways, but so far we just went with the basics create collection(name)
, that's it.
Just wanted to questions this, no changes requested.
Also, is it common to have so many parameters in go (in a single line)? 🤔
If is so, I like the Kotlin code style to have each param in its own line:
func (cl *DocumentsClient) Create(
collectionID CollectionID,
title string,
text string,
....,
But I have no strong opinion on that and don't know whats "the way" to go.
@rsjethani ? 🙂
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.
Do we already want to go with such a complicated strucutre?
- We (Sre) have a ticket, which needs us to be able to create a document with these features (only template + templateID where added as an extra, since it would be half implemented anyways)
Multiline parameters:
No Idea, I'd also be in favor of the kotlin way :)
We could probably go with any of these: https://realm.github.io/SwiftLint/multiline_parameters.html
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 Go, there is no discussion. gofmt
and you take that. :)
Regarding the signature: It's pretty long indeed, maybe you can set some sensible defaults and override those with something like func (cl *DocumentsClient) SetTemplateId(TemplateID)
?
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.
@zadjadr
Multi-line parameters are usually not preferred, they are usually a code smell hinting that code restructuring can reduce number of parameters required. A very straight forward approach is to only ask for mandatory parameters. In this case you should take only title
and collection id
as compulsory values. For optional values you can have option methods
which configure optional behavior. BTW you cannot have create method on DocumentsClient, you need a new type DocumentsClientCreate
to maintain consistency across api usage. Following is how the API call can look like eventually:
client.Documents().Create(title, collection id).Text("doc text").Do(...)
Observe: Text
is an example of a option method which allows configuring optional behavior. If we do not want to set text for the document then that call can be omitted.
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.
Yep, looks good to me 👍
Nice work. 🚀
@rsjethani please have a final look at this 🙏 |
I resolved the conflicts with upstream/main |
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.
Just two smaller comments.
However, I wil going to merge this as we should finally get things done.
Improvements can be still done later 👍
I will create a follow-up issues for those things to be evaluated.
DocumentUrlID string | ||
CollectionID string | ||
DocumentID string | ||
ParentDocumentID string |
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.
Not sure if if we need this as an extra type..
Maybe DocumentId
is enough, but naming it parentDocumentId
🤷
CreatedAt time.Time `json:"createdAt"` | ||
CreatedBy interface{} `json:"createdBy"` | ||
UpdatedAt time.Time `json:"updatedAt"` | ||
UpdatedBy interface{} `json:"updatedBy"` |
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.
We could already create a User
model 🤷
Implements https://www.getoutline.com/developers#tag/Documents/paths/~1documents.create/post and improves the pipeline
Related: #5