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.34.0 lib/discourse_api/api/badges.rb
discourse_api-0.33.0 lib/discourse_api/api/badges.rb
discourse_api-0.32.0 lib/discourse_api/api/badges.rb
discourse_api-0.31.0 lib/discourse_api/api/badges.rb
discourse_api-0.30.0 lib/discourse_api/api/badges.rb
discourse_api-0.29.0 lib/discourse_api/api/badges.rb
discourse_api-0.28.1 lib/discourse_api/api/badges.rb
discourse_api-0.28.0 lib/discourse_api/api/badges.rb
discourse_api-0.27.0 lib/discourse_api/api/badges.rb
discourse_api-0.26.0 lib/discourse_api/api/badges.rb
discourse_api-0.25.0 lib/discourse_api/api/badges.rb
discourse_api-0.24.0 lib/discourse_api/api/badges.rb
discourse_api-0.23.1 lib/discourse_api/api/badges.rb
discourse_api-0.23.0 lib/discourse_api/api/badges.rb
discourse_api-0.22.0 lib/discourse_api/api/badges.rb
discourse_api-0.20.1 lib/discourse_api/api/badges.rb
discourse_api-0.20.0 lib/discourse_api/api/badges.rb
discourse_api-0.19.0 lib/discourse_api/api/badges.rb
discourse_api-0.18.0 lib/discourse_api/api/badges.rb
discourse_api-0.17.0 lib/discourse_api/api/badges.rb