Class: Disqussion::Categories

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

Instance Method Summary collapse

Methods included from Request

#get, #post

Instance Method Details

#create(*args) ⇒ Hashie::Rash

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

Examples:

Creates a new category "My category" in forum "the88"

Disqussion::Client.categories.create("the88", "My category")

Parameters:

  • forum (String)

    Looks up a forum by ID (aka short name)

  • title (String)

    Maximum length of 50

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    New category infos



17
18
19
20
21
22
23
24
25
# File 'lib/disqussion/client/categories.rb', line 17

def create(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  if args.size == 2
    options.merge!(:forum => args[0], :title => args[1])
    response = post('categories/create', options)
  else
    puts "#{Kernel.caller.first}: categories.create expects 2 arguments: forum, title"
  end
end

#details(*args) ⇒ Hashie::Rash

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

Examples:

Disqussion::Client.categories.details(19122)

Parameters:

  • category (Integer)

    Looks up a category by ID.

Returns:

  • (Hashie::Rash)

    Details on the requested category.



38
39
40
41
42
# File 'lib/disqussion/client/categories.rb', line 38

def details(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[:category] = args.first
  response = get('categories/details', options)
end

#list(*args) ⇒ Hashie::Rash

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

Examples:

Return list of categories within forum 'myforum'

Disqussion::Client.categories.list("myforum", {:cursor => 10, :limit => 10, :order => 'asc'})

Parameters:

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Details on the requested list of categories.



60
61
62
63
# File 'lib/disqussion/client/categories.rb', line 60

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

#listPosts(*args) ⇒ Hashie::Rash

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

Examples:

Return list of posts within category 827231

Disqussion::Client.categories.listPosts(827231, {:cursor => 10, :limit => 10, :order => 'asc'})

Parameters:

  • forum (Integer)

    Category ID.

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Details on the requested list of posts.



84
85
86
87
88
# File 'lib/disqussion/client/categories.rb', line 84

def listPosts(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[:category] = args.first
  response = get('categories/listPosts', options)
end

#listThreads(*args) ⇒ Hashie::Rash

Returns a list of threads within a category 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/categories/listThreads.json

Examples:

Return list of threads within category 827231

Disqussion::Client.categories.listThreads(827231, {:cursor => 10, :limit => 10, :order => 'asc'})

Parameters:

  • forum (Integer)

    Category ID.

  • options (Hash)

    A customizable set of options.

Returns:

  • (Hashie::Rash)

    Details on the requested list of threads.



109
110
111
112
113
# File 'lib/disqussion/client/categories.rb', line 109

def listThreads(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options[:category] = args.first
  response = get('categories/listThreads', options)
end