Class: BatchBook::Person

Inherits:
Base
  • Object
show all
Defined in:
lib/batchbook.rb

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#add_location(params = {}) ⇒ Object

Add a Location to a Person POST test.batchbook.com/service/people/#id/locations.xml Field Description location Location Name (‘work’, ‘home’, etc.) - REQUIRED location Email Address location Website URL location Phone Number location Cell Phone Number location Fax Number location Street Address location Street Address 2 location City location State location Postal Code location Country



108
109
110
111
# File 'lib/batchbook.rb', line 108

def add_location(params = {})
  params.update(:label => 'home') unless params[:label].present?
  self.post(:locations, :location => params)
end

#add_supertag(name, params = {}) ⇒ Object

TODO : Fix supertags Add a SuperTag to a Person

Add a SuperTag to a Person the same way you add a regular tag to it, via PUT test.batchbook.com/service/people/#id/add_tag/#super_tag_name.xml. Remove a SuperTag from a Person DELETE test.batchbook.com/service/people/#id/super_tags/#super_tag_name.xml

Raises:



129
130
131
132
133
134
135
136
# File 'lib/batchbook.rb', line 129

def add_supertag name, params = {}
  raise Error, "Tag name not specified.  Usage:  person.add_supertag('tag_name')" unless name

  self.put(:add_tag, :tag => name)
  unless params.empty?
    self.put("super_tags/#{name.gsub(/ /, '%20')}", :super_tag => params)
  end
end

#add_tag(name) ⇒ Object

Raises:



138
139
140
141
# File 'lib/batchbook.rb', line 138

def add_tag name
  raise Error, "Tag name not specified.  Usage:  person.add_tag('tag_name')" unless name
  self.put(:add_tag, :tag => name)
end

#add_tags(names = []) ⇒ Object

Raises:



143
144
145
146
# File 'lib/batchbook.rb', line 143

def add_tags names = []
  raise Error, "Tag name not specified.  Usage:  person.add_tag('tag_name')" unless names
  self.put(:add_tag, :tags => names)
end

#affiliationsObject



161
162
163
# File 'lib/batchbook.rb', line 161

def affiliations
  Affiliation.find(:all, :params => {:person_id => self.id})      
end

#comment(id) ⇒ Object



157
158
159
# File 'lib/batchbook.rb', line 157

def comment(id)
  comments(id)
end

#comments(scope = :all) ⇒ Object



153
154
155
# File 'lib/batchbook.rb', line 153

def comments(scope = :all)
  Comment.find(scope, :params => {:person_id => self.id})
end

#communicationsObject



165
166
167
# File 'lib/batchbook.rb', line 165

def communications
  Communication.find(:all, :params => {:person_id => self.id})
end

#location(label) ⇒ Object

Raises:



88
89
90
91
# File 'lib/batchbook.rb', line 88

def location label
  raise Error, "Location label not specified.  Usage:  person.location('label_name')" unless label
  self.get('locations', :label => label)
end

#locationsObject



84
85
86
# File 'lib/batchbook.rb', line 84

def locations
  self.get('locations')
end

#remove_tag(name) ⇒ Object

Raises:



148
149
150
151
# File 'lib/batchbook.rb', line 148

def remove_tag name
  raise Error, "Tag name not specified.  Usage:  person.remove_tag('tag_name')" unless name
  self.delete(:remove_tag, :tag => name)
end

#supertag(name) ⇒ Object

Raises:



117
118
119
120
# File 'lib/batchbook.rb', line 117

def supertag name
  raise Error, "SuperTag name not specified.  Usage:  person.supertag('tag_name')" unless name
  self.get('super_tags', :name => name)
end

#supertagsObject



113
114
115
# File 'lib/batchbook.rb', line 113

def supertags
  self.get('super_tags')
end

#tagsObject



80
81
82
# File 'lib/batchbook.rb', line 80

def tags
  Tag.find(:all, :params => {:contact_id => id})
end

#todosObject



169
170
171
# File 'lib/batchbook.rb', line 169

def todos
  Todo.find(:all, :params => {:person_id => self.id})
end