Module: Basecamp

Defined in:
lib/basecamp.rb

Defined Under Namespace

Classes: Attachment, Category, Comment, Company, Connection, Message, Project, Record, Resource, TimeEntry, TodoItem, TodoList

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.passwordObject (readonly)

Returns the value of attribute password.



311
312
313
# File 'lib/basecamp.rb', line 311

def password
  @password
end

.siteObject (readonly)

Returns the value of attribute site.



311
312
313
# File 'lib/basecamp.rb', line 311

def site
  @site
end

.use_sslObject (readonly)

Returns the value of attribute use_ssl.



311
312
313
# File 'lib/basecamp.rb', line 311

def use_ssl
  @use_ssl
end

.userObject (readonly)

Returns the value of attribute user.



311
312
313
# File 'lib/basecamp.rb', line 311

def user
  @user
end

Instance Attribute Details

#use_xmlObject

Returns the value of attribute use_xml.



308
309
310
# File 'lib/basecamp.rb', line 308

def use_xml
  @use_xml
end

Class Method Details

.connectionObject



326
327
328
# File 'lib/basecamp.rb', line 326

def connection
  @connection || raise('No connection established')
end

.establish_connection!(site, user, password, use_ssl = false) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/basecamp.rb', line 313

def establish_connection!(site, user, password, use_ssl = false)
  @site     = site
  @user     = user
  @password = password
  @use_ssl  = use_ssl

  Resource.user = user
  Resource.password = password
  Resource.site = (use_ssl ? "https" : "http") + "://" + site

  @connection = Connection.new(self)
end

.get_tokenObject



330
331
332
333
334
# File 'lib/basecamp.rb', line 330

def get_token
  response = @connection.get('/me.xml')
  xml = XmlSimple.xml_in(response.body)
  xml['token'][0]
end

Instance Method Details

#complete_milestone(id) ⇒ Object

Complete the milestone with the given id



395
396
397
# File 'lib/basecamp.rb', line 395

def complete_milestone(id)
  record "/milestones/complete/#{id}"
end

#create_milestone(project_id, data) ⇒ Object

Create a new milestone for the given project. data must be hash of the values to set, including title, deadline, responsible_party, and notify.



371
372
373
# File 'lib/basecamp.rb', line 371

def create_milestone(project_id, data)
  create_milestones(project_id, [data]).first
end

#create_milestones(project_id, milestones) ⇒ Object

As #create_milestone, but can create multiple milestones in a single request. The milestones parameter must be an array of milestone values as described in #create_milestone.



378
379
380
# File 'lib/basecamp.rb', line 378

def create_milestones(project_id, milestones)
  records "milestone", "/projects/#{project_id}/milestones/create", :milestone => milestones
end

#delete_milestone(id) ⇒ Object

Destroys the milestone with the given id.



390
391
392
# File 'lib/basecamp.rb', line 390

def delete_milestone(id)
  record "/milestones/delete/#{id}"
end

#initializeObject



337
338
339
# File 'lib/basecamp.rb', line 337

def initialize
  @use_xml = false
end

#milestones(project_id, find = 'all') ⇒ Object

Returns a list of all milestones for the given project, optionally filtered by whether they are completed, late, or upcoming.



364
365
366
# File 'lib/basecamp.rb', line 364

def milestones(project_id, find = 'all')
  records "milestone", "/projects/#{project_id}/milestones/list", :find => find
end

#people(company_id, project_id = nil) ⇒ Object

Return an array of the people in the given company. If the project-id is given, only people who have access to the given project will be returned.



347
348
349
350
351
# File 'lib/basecamp.rb', line 347

def people(company_id, project_id=nil)
  url = project_id ? "/projects/#{project_id}" : ""
  url << "/contacts/people/#{company_id}"
  records "person", url
end

#person(id) ⇒ Object

Return information about the person with the given id



354
355
356
# File 'lib/basecamp.rb', line 354

def person(id)
  record "/contacts/person/#{id}"
end

#uncomplete_milestone(id) ⇒ Object

Uncomplete the milestone with the given id



400
401
402
# File 'lib/basecamp.rb', line 400

def uncomplete_milestone(id)
  record "/milestones/uncomplete/#{id}"
end

#update_milestone(id, data, move = false, move_off_weekends = false) ⇒ Object

Updates an existing milestone.



383
384
385
386
387
# File 'lib/basecamp.rb', line 383

def update_milestone(id, data, move = false, move_off_weekends = false)
  record "/milestones/update/#{id}", :milestone => data,
    :move_upcoming_milestones => move,
    :move_upcoming_milestones_off_weekends => move_off_weekends
end