-
Notifications
You must be signed in to change notification settings - Fork 436
First pass at options builder #212
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
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.
Overall I think I like the way it reads, would need more time to play with it.
The one thing I don't like is the .build()
part of the API. It feels very Java.
Is there a way for it to always be ready to send (builds after every update or the endpoint logic calls build on the 'requestmodel' for you?
@@ -25,6 +28,35 @@ class Direction: | |||
Desc = 'desc' | |||
Asc = 'asc' | |||
|
|||
class Builder: | |||
def __init__(self): | |||
self.__pagenumber = 1 |
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'm not sure the __
is necessary (it invokes name mangling to avoid inheritance problems but here I think you can just make it the _
... it's more 'polite' form :P
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.
The double underscore was needed to disambiguate with the call to _pagenumber that I was specifically handling. If I don't do this, it actually fails
How about the contract for the Filters/Request Options/etc is that we call |
@RussTheAerialist I like that contract |
I think I am a bit confused. If I don't call _build() and so still have a Builder object, what do I call to actually get a RequestOptions object? I need to call something, right? Also, if we don't have a "build" method, then why did I call it a Builder? |
I think @RussTheAerialist is proposing you just create a Then, the contract for endpoints is to call |
Closing for inactivity |
Not ready to actually submit this but I find our current syntax for building a filter / sort set ... yucky. I implemented a simple builder pattern. "_" prefixed methods have special meaning. For all other methods, the name is the property you are filtering on and the 2 params are an operator and value. I just accept simple strings that actually look like the operator. I imagine later I can add "_include" when we expose fields. You can see in the sample that it makes it much easier to read. All of our samples only have one filter so it isn't so bad but it would get bad quickly if you did any more