Sha256: 8826e247b84153558315aa2ce3fd8b7f59ca76671d55456ac61be6bd3ad77e95

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

module DiscourseApi
  module API
    module Categories
      # :color and :text_color are RGB hexadecimal strings
      def create_category(args)
        post("/categories", API.params(args)
                               .required(:name)
                               .optional(:color, :text_color)
                               .default(parent_category_id: nil)
            )
      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

3 entries across 3 versions & 1 rubygems

Version Path
discourse_api-0.3.0 lib/discourse_api/api/categories.rb
discourse_api-0.2.9 lib/discourse_api/api/categories.rb
discourse_api-0.2.8 lib/discourse_api/api/categories.rb