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

#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



76
77
78
79
80
# File 'lib/disqussion/client/posts.rb', line 76

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..



104
105
106
107
# File 'lib/disqussion/client/posts.rb', line 104

def list(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get('posts/list', 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



120
121
122
123
124
# File 'lib/disqussion/client/posts.rb', line 120

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



137
138
139
140
141
# File 'lib/disqussion/client/posts.rb', line 137

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



154
155
156
157
158
# File 'lib/disqussion/client/posts.rb', line 154

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



171
172
173
174
175
# File 'lib/disqussion/client/posts.rb', line 171

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



188
189
190
191
192
# File 'lib/disqussion/client/posts.rb', line 188

def unhighlight(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[:post] = args.first
  response = post('posts/unhighlight', options)
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.



206
207
208
209
210
211
212
213
214
215
# File 'lib/disqussion/client/posts.rb', line 206

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