Class: Insightly::Tag

Inherits:
ReadOnly show all
Defined in:
lib/insightly/tag.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ReadOnly

#==, build, #config, #get_collection, #initialize, #process, #remote_data

Methods inherited from Base

#==, all, api_field, build, #config, custom_fields, #get_collection, #initialize, #load, #process, #reload, #remote_data, #remote_id, #to_json, #url_base

Constructor Details

This class inherits a constructor from Insightly::ReadOnly

Class Method Details

.contact_tagsObject



14
15
16
17
18
# File 'lib/insightly/tag.rb', line 14

def self.contact_tags

  self.tags_by_type("Contacts")

end

.email_tagsObject



30
31
32
33
# File 'lib/insightly/tag.rb', line 30

def self.email_tags
  self.tags_by_type("Emails")

end

.opportunity_tagsObject



23
24
25
26
# File 'lib/insightly/tag.rb', line 23

def self.opportunity_tags
  self.tags_by_type("Opportunities")

end

.organisation_tagsObject



19
20
21
22
# File 'lib/insightly/tag.rb', line 19

def self.organisation_tags
  self.tags_by_type("Organisations")

end

.project_tagsObject



27
28
29
# File 'lib/insightly/tag.rb', line 27

def self.project_tags
  self.tags_by_type("Projects")
end

.tags_by_type(type) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/insightly/tag.rb', line 34

def self.tags_by_type(type)
  item = self.new
  list = []
  item.get_collection("#{item.url_base}/#{type}").each do |d|
    list << self.new.build(d)
  end
  list
end

Instance Method Details

#build(data) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/insightly/tag.rb', line 6

def build(data)
  if data.respond_to? :keys
    @data = data
  else
    @data = {"TAG_NAME" => data}
  end
  self
end