Sha256: ba99f3d3466344c70d09eed0102c8877b317cf46095c2d05ef8edca84dc0fd62

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module DiscourseApi
  module API
    module Categories
      # :color and :text_color are RGB hexadecimal strings
      def create_category(args)
        args = API.params(args)
                  .required(:name, :color, :text_color)
                  .optional(:description)
                  .default(parent_category_id: nil)
        response = post("/categories", args)
        response['category']
      end

      def categories(params={})
        response = get('/categories.json', params)
        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

      def category(id)
        response = get("/c/#{id}/show")
        response.body['category']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse_api-0.4.0 lib/discourse_api/api/categories.rb