lib/snoo/links_comments.rb in snoo-0.1.0.pre.8 vs lib/snoo/links_comments.rb in snoo-0.1.0

- old
+ new

@@ -9,39 +9,39 @@ # @param text [String] The comment text, formatted as markdown # @param id [String] The parent object id. Should be a comment or link # @return (see #clear_sessions) def comment text, id logged_in? - post('/api/comment', body: { text: text, thing_id: id, uh: @modhash}) + post('/api/comment', body: { text: text, thing_id: id, uh: @modhash, api_type: 'json'}) end # Deletes a thing from the site # # @param id [String] The thing to target. # @return (see #clear_sessions) def delete id logged_in? - post('/api/del', body: { id: id, uh: @modhash }) + post('/api/del', body: { id: id, uh: @modhash, api_type: 'json' }) end # Edits a thing. # Can be a self post body, or a comment # # @param (see #comment) # @return (see #clear_sessions) def edit text, id logged_in? - post('/api/editusertext', body: {text: text, thing_id: id, uh: @modhash}) + post('/api/editusertext', body: {text: text, thing_id: id, uh: @modhash, api_type: 'json'}) end # Hides a thing # # @param (see #delete) # @return (see #clear_sessions) def hide id logged_in? - post('/api/hide', body: {id: id, uh: @modhash}) + post('/api/hide', body: {id: id, uh: @modhash, api_type: 'json'}) end # Get a listing of things which have the provided URL. # You can use a plain url, or a reddit link id to get reposts of said link # @note Using {Listings#search} is probably better for url lookups @@ -61,29 +61,29 @@ # # @param (see #delete) # @return (see #clear_sessions) def mark_nsfw id logged_in? - post('/api/marknsfw', body: {id: id, uh: @modhash}) + post('/api/marknsfw', body: {id: id, uh: @modhash, api_type: 'json'}) end # Reports a comment or link # # @param (see #delete) # @reutrn (see #comment) def report id logged_in? - post('/api/report', body: {id: id, uh: @modhash}) + post('/api/report', body: {id: id, uh: @modhash, api_type: 'json'}) end # Saves a link # # @param (see #delete) # @return (see #clear_sessions) def save id logged_in? - post('/api/save', body: { id: id, uh: @modhash}) + post('/api/save', body: { id: id, uh: @modhash, api_type: 'json'}) end # Submit a link or self post # # @param title [String] Title of the post @@ -96,11 +96,12 @@ logged_in? post = { title: title, sr: subreddit, uh: @modhash, - kind: (opts[:url] ? "link" : "self") + kind: (opts[:url] ? "link" : "self"), + api_type: 'json' } post.merge! opts post('/api/submit', body: post) end @@ -108,30 +109,30 @@ # # @param (see #delete) # @return (see #clear_sessions) def unhide id logged_in? - post('/api/unhide', body: {id: id, uh: @modhash}) + post('/api/unhide', body: {id: id, uh: @modhash, api_type: 'json'}) end # Un-mark NSFW a thing. # # @param (see #delete) # @return (see #clear_sessions) def unmark_nsfw id logged_in? - post('/api/unmarknsfw', body: {id: id, uh: @modhash}) + post('/api/unmarknsfw', body: {id: id, uh: @modhash, api_type: 'json'}) end alias_method :mark_sfw, :unmark_nsfw # Vote on a comment or link # # @param direction [-1, 0, 1] The direction to vote in. -1 is a downvote, 1 is an upvote, 0 cancels any vote # @param id [String] The thing to target. # @return (see #clear_sessions) def vote direction, id logged_in? - post('/api/vote', body: {id: id, dir: direction, uh: @modhash}) + post('/api/vote', body: {id: id, dir: direction, uh: @modhash, api_type: 'json'}) end # Upvote # An alias for `vote 1, id` #