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
-
.password ⇒ Object
readonly
Returns the value of attribute password.
-
.site ⇒ Object
readonly
Returns the value of attribute site.
-
.use_ssl ⇒ Object
readonly
Returns the value of attribute use_ssl.
-
.user ⇒ Object
readonly
Returns the value of attribute user.
Instance Attribute Summary collapse
-
#use_xml ⇒ Object
Returns the value of attribute use_xml.
Class Method Summary collapse
- .connection ⇒ Object
- .establish_connection!(site, user, password, use_ssl = false) ⇒ Object
- .get_token ⇒ Object
Instance Method Summary collapse
-
#complete_milestone(id) ⇒ Object
Complete the milestone with the given id.
-
#create_milestone(project_id, data) ⇒ Object
Create a new milestone for the given project.
-
#create_milestones(project_id, milestones) ⇒ Object
As #create_milestone, but can create multiple milestones in a single request.
-
#delete_milestone(id) ⇒ Object
Destroys the milestone with the given id.
- #initialize ⇒ Object
-
#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.
-
#people(company_id, project_id = nil) ⇒ Object
Return an array of the people in the given company.
-
#person(id) ⇒ Object
Return information about the person with the given id.
-
#uncomplete_milestone(id) ⇒ Object
Uncomplete the milestone with the given id.
-
#update_milestone(id, data, move = false, move_off_weekends = false) ⇒ Object
Updates an existing milestone.
Class Attribute Details
.password ⇒ Object (readonly)
Returns the value of attribute password.
311 312 313 |
# File 'lib/basecamp.rb', line 311 def password @password end |
.site ⇒ Object (readonly)
Returns the value of attribute site.
311 312 313 |
# File 'lib/basecamp.rb', line 311 def site @site end |
.use_ssl ⇒ Object (readonly)
Returns the value of attribute use_ssl.
311 312 313 |
# File 'lib/basecamp.rb', line 311 def use_ssl @use_ssl end |
.user ⇒ Object (readonly)
Returns the value of attribute user.
311 312 313 |
# File 'lib/basecamp.rb', line 311 def user @user end |
Instance Attribute Details
#use_xml ⇒ Object
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
.connection ⇒ Object
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_token ⇒ Object
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 |
#initialize ⇒ Object
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 |