Sha256: 8f2d18b0cb221d36ae5a692a3b4ac5eb16c38b63033cac58614c367b816e31cc

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module DiscourseApi
  module API
    module Users
      def activate(id)
        put "/admin/users/#{id}/activate", api_key: api_key, api_username: api_username
      end

      def user(username, *args)
        response = get("/users/#{username}.json", args)
        response[:body]['user']
      end

      def update_avatar(username, file)
        put("/users/#{username}/preferences/avatar", { file: file, api_key: api_key })
      end

      def update_email(username, email)
        put("/users/#{username}/preferences/email", { email: email, api_key: api_key })
      end

      def update_user(username, params={})
        put("/users/#{username}", params)
      end

      def update_username(username, new_username)
        put("/users/#{username}/preferences/username", { new_username: new_username, api_key: api_key })
      end

      # Create a user
      def create_user(args={})
        # First retrieve the honeypot values
        response = get("/users/hp.json")
        args[:password_confirmation] = response[:body]['value']
        args[:challenge] = response[:body]['challenge'].reverse

        # POST the args
        post("/users", args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse_api-0.2.4 lib/discourse_api/api/users.rb