Sha256: 6e35a26a7460e8e2466f687e0e131da0a1aaf41966d2c7f565bc5e5bbb9a5afa

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 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("/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

2 entries across 2 versions & 1 rubygems

Version Path
discourse_api-0.36.0 lib/discourse_api/api/badges.rb
discourse_api-0.35.0 lib/discourse_api/api/badges.rb