Sha256: 5c0a8f3d4c86780f8d0ac01074e34f5d702f7f69e80d47496d2a67f957db2392

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

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