Class: Disqussion::Threads

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

Instance Method Summary collapse

Methods included from Request

#get, #post

Instance Method Details

#close(*args) ⇒ Hashie::Rash

Closes a thread @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/threads/close.json

Examples:

Closes thread 12345678

Disqussion::Client.threads.close(12345678)

Parameters:

  • thread (Array, Integer)

    allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    a customizable set of options

Returns:

  • (Hashie::Rash)

    ID of the closed thread.



15
16
17
18
19
20
# File 'lib/disqussion/client/threads.rb', line 15

def close(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = post('threads/close', options)
end

#details(*args) ⇒ Hashie::Rash

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

Examples:

Return extended information for forum 'myforum'

Disqussion::Client.threads.details("mythread")

Parameters:

  • thread (Integer)

    Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Details on the requested threads.



36
37
38
39
40
41
# File 'lib/disqussion/client/threads.rb', line 36

def details(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = get('threads/details', options)
end

#list(*args) ⇒ Hashie::Rash

Returns a list of threads sorted 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/threads/list.json

Examples:

Return extended information for forum 'myforum'

Disqussion::Client.threads.list(:forum => "the88")

Parameters:

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    List of threads.



64
65
66
67
# File 'lib/disqussion/client/threads.rb', line 64

def list(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get('threads/list', options)
end

#listMostLiked(*args) ⇒ Hashie::Rash

Returns a list of threads sorted by number of likes. @accessibility: public key, secret key @methods: GET @format: json, jsonp, rss @authenticated: false @limited: false @see: http://disqus.com/api/3.0/threads/listMostLiked.json

Examples:

Return extended information for forum 'myforum'

Disqussion::Client.threads.listMostLiked()

Parameters:

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    List of the most liked threads.



86
87
88
89
# File 'lib/disqussion/client/threads.rb', line 86

def listMostLiked(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get('threads/listMostLiked', options)
end

#listPosts(*args) ⇒ Hashie::Rash

Returns a list of posts within a thread. @accessibility: public key, secret key @methods: GET @format: json, jsonp, rss @authenticated: false @limited: false @see: http://disqus.com/api/3.0/threads/listPosts.json

Examples:

Return extended information for forum 'myforum'

Disqussion::Client.threads.list()

Parameters:

  • thread (Integer)

    Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    List of threads post.



111
112
113
114
115
116
# File 'lib/disqussion/client/threads.rb', line 111

def listPosts(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = get('threads/listPosts', options)
end

#open(*args) ⇒ Hashie::Rash

Opens a thread @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/threads/open.json

Examples:

Opens thread 12345678

Disqussion::Client.threads.open(12345678)

Parameters:

  • thread (Array, Integer)

    allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    a customizable set of options

Returns:

  • (Hashie::Rash)

    ID of the opened thread.



130
131
132
133
134
135
# File 'lib/disqussion/client/threads.rb', line 130

def open(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = post('threads/open', options)
end

#remove(*args) ⇒ Hashie::Rash

Removes a thread @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/threads/remove.json

Examples:

Removes thread 12345678

Disqussion::Client.threads.remove(12345678)

Parameters:

  • thread (Array, Integer)

    allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    a customizable set of options

Returns:

  • (Hashie::Rash)

    ID of the deleted thread.



149
150
151
152
153
154
# File 'lib/disqussion/client/threads.rb', line 149

def remove(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = post('threads/remove', options)
end

#restore(*args) ⇒ Hashie::Rash

Restores a thread @accessibility: public key, secret key @methods: POST @format: json, jsonp @authenticated: true @limited: false @see: http://disqus.com/api/3.0/threads/restore.json

Examples:

Removes thread 12345678

Disqussion::Client.threads.restore(12345678)

Parameters:

  • thread (Array, Integer)

    allows multiple. Looks up a thread by ID. You must be a moderator on the selected thread's forum. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    a customizable set of options

Returns:

  • (Hashie::Rash)

    ID of the restored thread.



168
169
170
171
172
173
# File 'lib/disqussion/client/threads.rb', line 168

def restore(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  thread = args.first
  options.merge!(:thread => thread) if ([:ident, :link] & options.keys).empty?
  response = post('threads/restore', options)
end

#vote(*args) ⇒ Hashie::Rash

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

Examples:

Removes thread 12345678

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

Parameters:

  • thread (Integer)

    Choices: -1, 0, 1

  • thread (Integer)

    Looks up a thread by ID. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'.

  • options (Hash)

    a customizable set of options

Returns:

  • (Hashie::Rash)

    Details on the thread.



188
189
190
191
192
193
194
195
196
197
# File 'lib/disqussion/client/threads.rb', line 188

def vote(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  if args.length == 2
    options.merge!(:vote => args[0])
    options.merge!(:thread => args[1]) if ([:ident, :link] & options.keys).empty?
    response = post('threads/vote', options)
  else
    puts "#{Kernel.caller.first}: threads.vote expects 2 arguments: vote([-1..1]), thread (you may pass use the 'ident' or 'link' query types instead of an thread ID by including :forum)"
  end
end