Module: Redd::Client::Authenticated::LinksComments
- Included in:
- Redd::Client::Authenticated
- Defined in:
- lib/redd/client/authenticated/links_comments.rb
Instance Method Summary collapse
- #add_comment(thing, text) ⇒ Object (also: #reply)
- #delete(thing) ⇒ Object
- #downvote(thing) ⇒ Object
- #edit(thing, text) ⇒ Object
- #hide(thing) ⇒ Object
- #mark_as_nsfw(thing) ⇒ Object
- #report(thing) ⇒ Object
- #save(thing, category = nil) ⇒ Object
- #submit(title, kind, text_or_url, captcha = nil, identifier = nil, options = {}) ⇒ Object
- #unhide(thing) ⇒ Object
- #unmark_as_nsfw(thing) ⇒ Object (also: #mark_as_safe)
- #unsave(thing) ⇒ Object
- #unvote(thing) ⇒ Object (also: #clear_vote)
- #upvote(thing) ⇒ Object
- #vote(thing, direction) ⇒ Object private
Instance Method Details
#add_comment(thing, text) ⇒ Object Also known as:
TODO:
return the edited object.
32 33 34 35 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 32 def add_comment(thing, text) fullname = extract_fullname(thing) post "/api/comment", api_type: "json", text: text, thing_id: fullname end |
#delete(thing) ⇒ Object
39 40 41 42 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 39 def delete(thing) fullname = extract_fullname(thing) post "/api/del", id: fullname end |
#downvote(thing) ⇒ Object
94 95 96 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 94 def downvote(thing) vote(thing, -1) end |
#edit(thing, text) ⇒ Object
TODO:
return the edited object.
45 46 47 48 49 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 45 def edit(thing, text) fullname = extract_fullname(thing) post "/api/editusertext", api_type: "json", text: text, thing_id: fullname end |
#hide(thing) ⇒ Object
51 52 53 54 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 51 def hide(thing) fullname = extract_fullname(thing) post "/api/hide", id: fullname end |
#mark_as_nsfw(thing) ⇒ Object
61 62 63 64 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 61 def mark_as_nsfw(thing) fullname = extract_fullname(thing) post "/api/marknsfw", id: fullname end |
#report(thing) ⇒ Object
73 74 75 76 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 73 def report(thing) fullname = extract_fullname(thing) post "/api/report", id: fullname end |
#save(thing, category = nil) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 78 def save(thing, category = nil) fullname = extract_fullname(thing) params = {id: fullname} params << {category: category} if category post "/api/save", params end |
#submit(title, kind, text_or_url, captcha = nil, identifier = nil, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 5 def submit( title, kind, text_or_url, captcha = nil, identifier = nil, = {} ) # Set required parameters params = { api_type: "json", extension: "json", title: title, kind: kind } # Set url or selftext depending on kind case kind.to_sym when :self params[:text] = text_or_url when :link params[:url] = text_or_url end # Optional captcha params << {captcha: captcha, iden: identifier} if captcha # Fill in the rest of the options params << post "/api/submit", params end |
#unhide(thing) ⇒ Object
56 57 58 59 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 56 def unhide(thing) fullname = extract_fullname(thing) post "/api/unhide", id: fullname end |
#unmark_as_nsfw(thing) ⇒ Object Also known as: mark_as_safe
66 67 68 69 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 66 def unmark_as_nsfw(thing) fullname = extract_fullname(thing) post "/api/unmarknsfw", id: fullname end |
#unsave(thing) ⇒ Object
85 86 87 88 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 85 def unsave(thing) fullname = extract_fullname(thing) post "/api/unsave", id: fullname end |
#unvote(thing) ⇒ Object Also known as: clear_vote
98 99 100 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 98 def unvote(thing) vote(thing, 0) end |
#upvote(thing) ⇒ Object
90 91 92 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 90 def upvote(thing) vote(thing, 1) end |
#vote(thing, direction) ⇒ Object (private)
106 107 108 109 |
# File 'lib/redd/client/authenticated/links_comments.rb', line 106 def vote(thing, direction) fullname = extract_fullname(thing) post "/api/vote", id: fullname, dir: direction end |