Class: Tenk::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/users/tags.rb

Overview

API methods for listing, adding, and removing tags for users

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Tags

Initialize a Tenk::Users::Tag resource API wrapper for the given client



5
6
7
# File 'lib/users/tags.rb', line 5

def initialize(client)
  @_client = client
end

Instance Method Details

#add(user_id, tag) ⇒ Hashie::Mash

Attach a tag to a user

Parameters:

  • user_id (Integer)

    the id of the user

  • tag (String)

    the string of the tag to attach

Returns:

  • (Hashie::Mash)

    the API response as a Hashie::Mash



21
22
23
# File 'lib/users/tags.rb', line 21

def add(user_id, tag)
  @_client.post("/users/#{user_id}/tags", value: tag)
end

#list(user_id) ⇒ Hashie::Mash

List Tags for a single user

Parameters:

  • user_id (Integer)

    the id of the user

Returns:

  • (Hashie::Mash)

    the API response as a Hashie::Mash

See Also:

  • Users::Tags::ListRequest


13
14
15
# File 'lib/users/tags.rb', line 13

def list(user_id)
  @_client.get("/users/#{user_id}/tags")
end

#remove(user_id, tag_id) ⇒ Hashie::Mash

Remove a tag from a user

Parameters:

  • user_id (Integer)

    the id of the user

  • tag_id (Integer)

    the integer id of the tag

Returns:

  • (Hashie::Mash)

    the API response as a Hashie::Mash



29
30
31
# File 'lib/users/tags.rb', line 29

def remove(user_id, tag_id)
  @_client.delete("/users/#{user_id}/tags/#{tag_id}")
end