-
Notifications
You must be signed in to change notification settings - Fork 51
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
Cleanup client HTTP methods #88
Conversation
@jacegu actually, my proposal is to keep the E.g. def get(path, options = {})
# ...
def post(path, data, options = {})
# ... |
Last commit is the smallest step to make remove the confusion about the unused parameters. From here we can move forward and have the request body as a separate parameter in the request. If we do that the methods with an actual body would look like this: def post(path, data, options = {})
execute :post, path, data, options
end while the methods without it would look like this: def get(path, options = {})
execute :get, path, {}, options
end We would also have to change how we compose the HTTParty request in the Finally we would have to revert all the: attribute.merge(options) inside each endpoint method to have data and options as separate parameters where appropriate. Want to double check first that we want to move forward with this because it will be some work. It may be worth to consider if the change would benefit us when the time to replace HTTParty comes. Thoughts? |
That's how the client would look like with the change @weppos. Still need to undo all the |
# @return [HTTParty::Response] | ||
def delete(path, options = {}) | ||
execute :delete, path, options | ||
execute :delete, path, {}, options |
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.
Although the RFC doesn't mention the data payload for a DELETE
action, it's common practice to consider DELETE
to accept a payload. I would allow it, since I believe we use (or used) it.
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.
Since we are not accepting attributes in the delete methods we would have to change all delete calls from something like:
response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), options)
to (note the extra {}
in place of attributes):
response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), {}, options)
Either that, or add the attributes to each delete endpoint switching:
def delete_contact(account_id, contact_id, options = {})
to
def delete_contact(account_id, contact_id, attributes = {}, options = {})
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.
No, we should not add it to the method signature. We should use
response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), {}, options)
even if a nil
value would seem more appropriate
response = client.delete(Client.versioned("/%s/contacts/%s" % [account_id, contact_id]), nil, options)
So far so good, @jacegu. It definitely looks cleaner to me. |
@weppos you can check where this is going. If you think it's ok we can go back to consider switching the default value of every |
@jacegu I'd leave options default to |
@weppos changing |
@weppos I just had a thought: maybe when you were talking about The pending changes before calling this PR done, are doing what I did for the contacts for every other method that takes |
@jacegu contacts look good to me. What I'd probably change, is to pass I also wonder if it makes sense to set attributes as optional parameters in create/update. It doesn't make sense to create a contact with empty attributes, I'd remove the default value and leave them as mandatory arguments. Does it make sense? |
Missed that! Should had been changed.
I agree. Moving forward with this then. 👍 |
* master: Sync with other clients Revert doc formtting to match the rest of the project Add examples for TLD client use Add command to get extended attributes on a TLD Rename #transfer_out to #transfer_domain_out Rename #transfer to #transfer_domain Rename #renew to #renew_domain Rename #register to #register_domain Rename #check to #check_domain Add method for getting a TLD's details
# @return [HTTParty::Response] | ||
def get(path, options = {}) | ||
execute :get, path, options | ||
execute :get, path, {}, options |
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.
@jacegu I suppose it should be nil here.
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.
Thanks for spotting that. Couldn't get them all 😅
Thanks @jacegu, it definitely looks cleaner now that attributes and options are separated. Besides a |
See b07da4fe4f1fd87aaf7a5900ecbf5b617dbfd8c4
* master: Fix some YARD issues Experiment with V2 static helpers Prepare for the beta rake 11.0 is yanked Remove unused exceptions Temporarily downgrade `rake` Revert 8384639 Consistently refer to the underlying HTTP response as http_response
Following up with the conversation @weppos had in Slack.