Class: Disqussion::Posts

Inherits:
Client
  • Object
show all
Defined in:
lib/disqussion/client/posts.rb

Instance Method Summary collapse

Methods included from Request

#get, #post

Instance Method Details

#approve(*args) ⇒ Hashie::Rash

Approves a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/approve.json

Examples:

Approves post with ID 198230

Disqussion::Client.posts.approve(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID. You must be a moderator on the selected post's forum.

Returns:

  • (Hashie::Rash)

    Approved post id



14
15
16
17
18
# 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

#create(*args) ⇒ Hashie::Rash

Creates a new post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: false @limited: false @see: http://disqus.com/api/3.0/posts/create.json

Examples:

Creates a new post 'hello world' in 167820 167820

Disqussion::Client.posts.create("hello world", :thread => 167820)

Parameters:

  • message (String)

    Message.

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    New post infos



40
41
42
43
44
# 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

#details(*args) ⇒ Hashie::Rash

Returns post details. @accessibility: public key, secret key @methods: GET @format: json, jsonp @authenticated: false @limited: false @see: http://disqus.com/api/3.0/posts/details.json

Examples:

Return extended information for post 193673

Disqussion::Client.posts.details(193673)

Parameters:

  • post (Integer)

    Post ID

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Details on the requested post.



59
60
61
62
63
# 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

#getContext(*args) ⇒ Hashie::Rash

Returns the hierarchal tree of a post (all parents). @accessibility: public key, secret key @methods: GET @format: json, jsonp @authenticated: false @limited: false @see: http://disqus.com/api/3.0/posts/getContext.json

Examples:

Return hierarchal tree for post 193673

Disqussion::Client.posts.getContext(193673)

Parameters:

  • post (Integer)

    Post ID

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    hierarchal tree of a post (all parents).



79
80
81
82
83
# 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

#highlight(*args) ⇒ Hashie::Rash

Highlights a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/highlight.json

Examples:

Highlights post with ID 198230

Disqussion::Client.posts.highlight(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Highlighted post id



96
97
98
99
100
# 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

#list(*args) ⇒ Hashie::Rash

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 @see: http://disqus.com/api/3.0/posts/list.json

Examples:

Return list of posts for thread 193673

Disqussion::Client.posts.list(:thread => 193673)

Parameters:

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Returns a list of posts ordered by the date created..



124
125
126
127
# 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

#listPopular(*args) ⇒ Object

Returns a list of the most popular posts @accessibility: public key, secret key @methods: GET @format: json, jsonp, rss @authenticated: false @limited: false @see: http://disqus.com/api/3.0/posts/listPopular.json

Examples:

list popular posts with forum bobross

Disqussion::Client.posts.listPopular("bobross")

Parameters:

  • options (Hash)

    a customizable set of options



150
151
152
153
# 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

#remove(*args) ⇒ Hashie::Rash

Deletes the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/remove.json

Examples:

Deletes post with ID 198230

Disqussion::Client.posts.remove(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Removed post id



166
167
168
169
170
# 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

#report(*args) ⇒ Hashie::Rash

Reports a post (flagging). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: false @limited: false @see: http://disqus.com/api/3.0/posts/report.json

Examples:

Deletes post with ID 198230

Disqussion::Client.posts.report(198230)

Parameters:

  • post (Integer)

    Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Reported post id



183
184
185
186
187
# 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

#restore(*args) ⇒ Hashie::Rash

Undeletes the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/restore.json

Examples:

Undeletes post with ID 198230

Disqussion::Client.posts.restore(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    restored post id



200
201
202
203
204
# 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

#spam(*args) ⇒ Hashie::Rash

Marks the requested post(s) as spam. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/spam.json

Examples:

Reports as spam post with ID 198230

Disqussion::Client.posts.spam(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Marked as spam post id



217
218
219
220
221
# 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

#unhighlight(*args) ⇒ Hashie::Rash

Unhighlights the requested post(s). @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/unhighlight.json

Examples:

Unhighlights the requested post(s).

Disqussion::Client.posts.unhighlight(198230)

Parameters:

  • post (Array, Integer)

    allows multiple. Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Unhighlighted post id



234
235
236
237
238
# 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

#update(*args) ⇒ Hashie::Rash

Updates information on a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/update.json

Examples:

Message for post ID 12345678

Disqussion::Client.posts.update(12345678,"Hello")

Parameters:

  • post (Integer)

    Looks up a post by ID.

  • message (String)

    String of the message

Returns:

  • (Hashie::Rash)

    Updated information on the post.



252
253
254
255
256
257
258
259
260
261
# 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

#vote(*args) ⇒ Hashie::Rash

Register a vote for a post. @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/posts/vote.json

Examples:

Vote for post ID 12345678

Disqussion::Client.posts.vote(1, 12345678)

Parameters:

  • vote (Integer)

    Choices: -1, 0, 1

  • post (Integer)

    Looks up a post by ID.

Returns:

  • (Hashie::Rash)

    Details on the post.



275
276
277
278
279
280
281
282
283
284
# 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