Sha256: 9d817954638975e5e1ca0d7a8c41871cb8ebf8836328a5c1c1c5007bf19185b5

Contents?: true

Size: 825 Bytes

Versions: 39

Compression:

Stored size: 825 Bytes

Contents

module DiscourseApi
  module API
    module Badges
      def badges
        response = get("/admin/badges.json")
        response.body
      end

      def user_badges(username)
        response = get("/users/#{username}/activity/badges.json")
        response.body['badges']
      end

      def grant_user_badge(params={})
        post("/user_badges", params)
      end

      def create_badge(params={})
        args = API.params(params)
                  .required(:name, :badge_type_id)
                  .optional(:description, :allow_title, :multiple_grant, :icon, :listable,
                            :target_posts, :query, :enabled, :auto_revoke, :badge_grouping_id,
                            :trigger, :show_posts, :image, :long_description)
        post("/admin/badges.json", args)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
discourse_api-0.16.1 lib/discourse_api/api/badges.rb
discourse_api-0.16.0 lib/discourse_api/api/badges.rb
discourse_api-0.15.0 lib/discourse_api/api/badges.rb
discourse_api-0.14.1 lib/discourse_api/api/badges.rb
discourse_api-0.14.0 lib/discourse_api/api/badges.rb
discourse_api-0.13.0 lib/discourse_api/api/badges.rb
discourse_api-0.12.0 lib/discourse_api/api/badges.rb
discourse_api-0.10.1 lib/discourse_api/api/badges.rb
discourse_api-0.10.0 lib/discourse_api/api/badges.rb
discourse_api-0.9.1 lib/discourse_api/api/badges.rb
discourse_api-0.9.0 lib/discourse_api/api/badges.rb
discourse_api-0.8.1 lib/discourse_api/api/badges.rb
discourse_api-0.8.0 lib/discourse_api/api/badges.rb
discourse_api-0.7.0 lib/discourse_api/api/badges.rb
discourse_api-0.6.2 lib/discourse_api/api/badges.rb
discourse_api-0.6.1 lib/discourse_api/api/badges.rb
discourse_api-0.6.0 lib/discourse_api/api/badges.rb
discourse_api-0.5.1 lib/discourse_api/api/badges.rb
discourse_api-0.5.0 lib/discourse_api/api/badges.rb