Sha256: 31add0db655f4fe55530844378be048305fa861aed0bde3e149c12347b8b4445

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

module Panoptes
  class Client
    module UserGroups
      # Creates a new user group and puts the current user in it as the initial member.
      #
      # @see http://docs.panoptes.apiary.io/#reference/user-group/usergroup-collection/create-a-user-group
      # @param name [String] The name of the user group. Must be unique for the entirity of Zooniverse.
      # @return [Hash] The created user group.
      def create_user_group(name)
        panoptes.post("/user_groups", user_groups: {
          name: name
        })["user_groups"][0]
      end

      def user_groups
        panoptes.get("/user_groups")["user_groups"]
      end

      def join_user_group(user_group_id, user_id, join_token:)
        panoptes.post("/memberships", memberships: {
          join_token: join_token,
          links: {user: user_id, user_group: user_group_id}
        })["memberships"][0]
      end

      def remove_user_from_user_group(user_group_id, user_id)
        panoptes.delete("/user_groups/#{user_group_id}/links/users/#{user_id}")
      end

      def delete_user_group(user_group_id)
        response = panoptes.connection.get("/api/user_groups/#{user_group_id}")
        etag = response.headers["ETag"]

        panoptes.delete("/user_groups/#{user_group_id}", {}, etag: etag)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
panoptes-client-1.0.0.pre1 lib/panoptes/client/user_groups.rb
panoptes-client-1.0.0.pre lib/panoptes/client/user_groups.rb
panoptes-client-0.4.0 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.8 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.7 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.6 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.5 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.4 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.3 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.2 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.1 lib/panoptes/client/user_groups.rb
panoptes-client-0.3.0 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.13 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.12 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.11 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.10 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.9 lib/panoptes/client/user_groups.rb
panoptes-client-0.2.8 lib/panoptes/client/user_groups.rb