Sha256: a72d818b563c472f793a2a8cbb7f69ec6125575f2c078de6b7aa8b350f836e6e

Contents?: true

Size: 833 Bytes

Versions: 20

Compression:

Stored size: 833 Bytes

Contents

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

      def user_badges(username)
        response = get("/user-badges/#{username}.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

20 entries across 20 versions & 1 rubygems

Version Path
discourse_api-1.1.0 lib/discourse_api/api/badges.rb
discourse_api-1.0.0 lib/discourse_api/api/badges.rb
discourse_api-0.48.1 lib/discourse_api/api/badges.rb
discourse_api-0.48.0 lib/discourse_api/api/badges.rb
discourse_api-0.47.0 lib/discourse_api/api/badges.rb
discourse_api-0.46.0 lib/discourse_api/api/badges.rb
discourse_api-0.45.1 lib/discourse_api/api/badges.rb
discourse_api-0.45.0 lib/discourse_api/api/badges.rb
discourse_api-0.44.0 lib/discourse_api/api/badges.rb
discourse_api-0.43.1 lib/discourse_api/api/badges.rb
discourse_api-0.43.0 lib/discourse_api/api/badges.rb
discourse_api-0.42.0 lib/discourse_api/api/badges.rb
discourse_api-0.41.0 lib/discourse_api/api/badges.rb
discourse_api-0.40.0 lib/discourse_api/api/badges.rb
discourse_api-0.39.3 lib/discourse_api/api/badges.rb
discourse_api-0.39.2 lib/discourse_api/api/badges.rb
discourse_api-0.39.1 lib/discourse_api/api/badges.rb
discourse_api-0.39.0 lib/discourse_api/api/badges.rb
discourse_api-0.38.0 lib/discourse_api/api/badges.rb
discourse_api-0.37.0 lib/discourse_api/api/badges.rb