Module: Teambition2::API::Tag

Included in:
Client
Defined in:
lib/teambition2/api/tag.rb

Instance Method Summary collapse

Instance Method Details

#create_tag(project_id, tag) ⇒ Object



12
13
14
15
16
17
# File 'lib/teambition2/api/tag.rb', line 12

def create_tag(project_id, tag)
  post('/api/tags', {
    'name' => tag,
    '_projectId' => project_id
    })
end

#tag(tag_id) ⇒ Object



8
9
10
# File 'lib/teambition2/api/tag.rb', line 8

def tag(tag_id)
  get("/api/tags/#{tag_id}")
end

#tag_search(type, id, name, limit: 1) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/teambition2/api/tag.rb', line 19

def tag_search(type, id, name, limit: 1)
  result = tags(type, id).select { |p| p['name'].include?(name) }
  return nil if result.empty?

  case limit
  when 0
    result
  when 1
    result[0]
  else
    result.size >= limit ? result[0..limit] : result
  end
end

#tags(type, id) ⇒ Object



4
5
6
# File 'lib/teambition2/api/tag.rb', line 4

def tags(type, id)
  get("/api/#{type}/#{id}/tags")
end