class Disqussion::Posts
Public Instance Methods
Approves a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. You must be a moderator on the selected post’s forum. @return [Hashie::Rash] Approved post id @example Approves post with ID 198230
Disqussion::Client.posts.approve(198230)
@see: disqus.com/api/3.0/posts/approve.json
# File lib/disqussion/client/posts.rb, line 14 def approve(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/approve', options) end
Creates a new post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: false @limited: false @param message [String] Message. @param options [Hash] A customizable set of options. @option options [Integer] :parent Defaults to null. Looks up a post by ID @option options [Integer] :thread Defaults to null. Looks up a thread by ID @option options [String] :author_email Defaults to null. Email address (defined by RFC 5322) @option options [String] :author_name Defaults to null @option options [String] :state Defaults to null. Choices: unapproved, approved, spam, killed @option options [String] :author_url Defaults to null. URL (defined by RFC 3986) @option options [Datetime] :date Defaults to null. Unix timestamp (or ISO datetime standard) @option options [String] :ip_address Defaults to null. IP address (defined by RFC 5322) @return [Hashie::Rash] New post infos @example Creates a new post ‘hello world’ in 167820 167820
Disqussion::Client.posts.create("hello world", :thread => 167820)
@see: disqus.com/api/3.0/posts/create.json
# File lib/disqussion/client/posts.rb, line 40 def create(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:message] = args.first response = post('posts/create', options) end
Returns post details. @accessibility: public key, secret key @methods: GET @format: json, jsonp @authenticated: false @limited: false @param post [Integer] Post ID @param options [Hash] A customizable set of options. @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread. @return [Hashie::Rash] Details on the requested post. @example Return extended information for post 193673
Disqussion::Client.posts.details(193673)
@see: disqus.com/api/3.0/posts/details.json
# File lib/disqussion/client/posts.rb, line 59 def details(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = get('posts/details', options) end
Returns the hierarchal tree of a post (all parents). @accessibility: public key, secret key @methods: GET @format: json, jsonp @authenticated: false @limited: false @param post [Integer] Post ID @param options [Hash] A customizable set of options. @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread. @option options [Integer] :depth. Defaults to 10. Minimum value of 1 and maximum value of 10. @return [Hashie::Rash] hierarchal tree of a post (all parents). @example Return hierarchal tree for post 193673
Disqussion::Client.posts.getContext(193673)
@see: disqus.com/api/3.0/posts/getContext.json
# File lib/disqussion/client/posts.rb, line 79 def getContext(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = get('posts/getContext', options) end
Highlights a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. @return [Hashie::Rash] Highlighted post id @example Highlights post with ID 198230
Disqussion::Client.posts.highlight(198230)
@see: disqus.com/api/3.0/posts/highlight.json
# File lib/disqussion/client/posts.rb, line 96 def highlight(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/highlight', options) end
Returns a list of posts ordered by the date created. @accessibility: public key, secret key @methods: GET @format: json, jsonp, rss @authenticated: false @limited: false @param options [Hash] A customizable set of options. @option options [Array, String] :category allow multiple. Defaults to null. Looks up a category by ID @option options [Array, String] :thread allow multiple. Defaults to null. Looks up a thread by ID @option options [Array, String] :forum allow multiple. Defaults to null. Defaults to all forums you moderate if no other filters are specified. Looks up a forum by ID (aka short name) @option options [Datetime, Timestamp] :since Defaults to null. Unix timestamp (or ISO datetime standard). @option options [String, Array] :related allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread @option options [Integer] :cursor. Defaults to null @option options [Integer] :limit. Defaults to 25. Maximum length of 100 @option options [Integer] :offset. Defaults to 0. Deprecated: Please see documentation on cursors @option options [Integer] :query. Defaults to null. @option options [String, Array] :include allows multiple. Defaults to [“approved”]. Choices: unapproved, approved, spam, deleted, flagged, highlighted @option options [String] :order. Defaults to “desc”. Choices: asc, desc @return [Hashie::Rash] Returns a list of posts ordered by the date created.. @example Return list of posts for thread 193673
Disqussion::Client.posts.list(:thread => 193673)
@see: disqus.com/api/3.0/posts/list.json
# File lib/disqussion/client/posts.rb, line 124 def list(*args) options = args.last.is_a?(Hash) ? args.pop : {} response = get('posts/list', options) end
Returns a list of the most popular posts @accessibility: public key, secret key @methods: GET @format: json, jsonp, rss @authenticated: false @limited: false @option options [String] :category. Defaults to null @option options [String] :interval. Defaults to “7d”. Choices: 1h, 6h, 12h, 1d, 3d, 7d, 30d, 60d, 90d @option options [Array, String] :thread allow multiple. Defaults to null. Looks up a thread by ID @option options [String] :forum. Defaults to null. Defaults to all forums you moderate. Use :all to retrieve all forums. @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null(Deprecated) @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread @option options [Integer] :limit. Defaults to 25. Maximum value of 100 @option options [Integer] :offset. Defaults to 0 @option options [String] :query, Defualts to null @option options [String, Array] :include. Allows multiple. Defaults to [“approved”]. Choices: unapproved, approved, spam, deleted, flagged @option options [String] :order. Defaults to “popular”. Choices: popular, best @example list popular posts with forum bobross
Disqussion::Client.posts.listPopular("bobross")
@see: disqus.com/api/3.0/posts/listPopular.json
# File lib/disqussion/client/posts.rb, line 150 def listPopular(*args) options = args.last.is_a?(Hash) ? args.pop : {} response = get('posts/listPopular', options) end
Deletes the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. @return [Hashie::Rash] Removed post id @example Deletes post with ID 198230
Disqussion::Client.posts.remove(198230)
@see: disqus.com/api/3.0/posts/remove.json
# File lib/disqussion/client/posts.rb, line 166 def remove(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/remove', options) end
Reports
a post (flagging). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: false @limited: false @param post [Integer] Looks up a post by ID. @return [Hashie::Rash] Reported post id @example Deletes post with ID 198230
Disqussion::Client.posts.report(198230)
@see: disqus.com/api/3.0/posts/report.json
# File lib/disqussion/client/posts.rb, line 183 def report(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/report', options) end
Undeletes the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. @return [Hashie::Rash] restored post id @example Undeletes post with ID 198230
Disqussion::Client.posts.restore(198230)
@see: disqus.com/api/3.0/posts/restore.json
# File lib/disqussion/client/posts.rb, line 200 def restore(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/restore', options) end
Marks the requested post(s) as spam. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. @return [Hashie::Rash] Marked as spam post id @example Reports
as spam post with ID 198230
Disqussion::Client.posts.spam(198230)
@see: disqus.com/api/3.0/posts/spam.json
# File lib/disqussion/client/posts.rb, line 217 def spam(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/spam', options) end
Unhighlights the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Array, Integer] allows multiple. Looks up a post by ID. @return [Hashie::Rash] Unhighlighted post id @example Unhighlights the requested post(s).
Disqussion::Client.posts.unhighlight(198230)
@see: disqus.com/api/3.0/posts/unhighlight.json
# File lib/disqussion/client/posts.rb, line 234 def unhighlight(*args) options = args.last.is_a?(Hash) ? args.pop : {} options[:post] = args.first response = post('posts/unhighlight', options) end
Updates information on a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param post [Integer] Looks up a post by ID.
@param message [String] String of the message @return [Hashie::Rash] Updated information on the post. @example Message for post ID 12345678
Disqussion::Client.posts.update(12345678,"Hello")
@see: disqus.com/api/3.0/posts/update.json
# File lib/disqussion/client/posts.rb, line 252 def update(*args) options = args.last.is_a?(Hash) ? args.pop : {} if args.length == 2 options.merge!(:post => args[0]) options.merge!(:message => args[1]) response = post('posts/update', options) else puts "#{Kernel.caller.first}: posts.update expects 2 arguments: post ID and message" end end
Register a vote for a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @param vote [Integer] Choices: -1, 0, 1 @param post [Integer] Looks up a post by ID. @return [Hashie::Rash] Details on the post. @example Vote for post ID 12345678
Disqussion::Client.posts.vote(1, 12345678)
@see: disqus.com/api/3.0/posts/vote.json
# File lib/disqussion/client/posts.rb, line 275 def vote(*args) options = args.last.is_a?(Hash) ? args.pop : {} if args.length == 2 options.merge!(:vote => args[0]) options.merge!(:post => args[1]) response = post('posts/vote', options) else puts "#{Kernel.caller.first}: posts.vote expects 2 arguments: vote([-1..1]), posts ID" end end