Sha256: a45c5c117aa6c454d46464ef331c98ed4f7b542f008c052d761c97e1f4754604

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

module DiscourseApi
  module API
    module Categories
      # :color and :text_color are RGB hexadecimal strings
      def create_category(name:, color:, text_color:, parent_category_id: nil)
        post("/categories",
             name: name,
             color: color,
             text_color: text_color,
             parent_category_id: parent_category_id)
      end

      def categories(*args)
        response = get('/categories.json', args)
        response[:body]['category_list']['categories']
      end

      def category_latest_topics(category_slug)
        response = get("/category/#{category_slug}/l/latest.json")
        response[:body]['topic_list']['topics']
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse_api-0.2.7 lib/discourse_api/api/categories.rb
discourse_api-0.2.5 lib/discourse_api/api/categories.rb