samsymons / RedditKit.rb

[Deprecated] A Ruby wrapper for the reddit API
https://redditkit.com/
MIT License
152 stars 26 forks source link

Fix editusertext action #50

Open siegy22 opened 7 years ago

siegy22 commented 7 years ago

I was experiencing strange behaviour of Client::Miscellaneous#edit method, because it somehow rendered the page (as HTML) when I wanted to edit a comment.

However the comment was edited, the problem was, that the response was a HTML DOM, which then raised a rate limit error because somewhere in that DOM there was "RATELIMIT" written and that matched in Error#from_status_code_and_body.

So I added the api_type key and it worked fine. Plus I added a little guard to verify that options is a hash. When I first used the edit function I just passed the text as the second parameter, which then gave me a silly error that string cannot be converted into Integer.