Class: Basecampx::Project

Inherits:
Resource show all
Defined in:
lib/basecampx/resources/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#delete, #initialize, parse, #save, #update_attributes

Methods included from Relations

#has_many, #has_one, #mount

Constructor Details

This class inherits a constructor from Basecampx::Resource

Instance Attribute Details

#archivedObject

Returns the value of attribute archived.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def archived
  @archived
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def description
  @description
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def name
  @name
end

#starredObject

Returns the value of attribute starred.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def starred
  @starred
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def updated_at
  @updated_at
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/basecampx/resources/project.rb', line 4

def url
  @url
end

Class Method Details

.allObject



6
7
8
# File 'lib/basecampx/resources/project.rb', line 6

def self.all
  Project.parse Basecampx.request "projects.json"
end

.find(project_id) ⇒ Object



10
11
12
# File 'lib/basecampx/resources/project.rb', line 10

def self.find project_id
  Project.new Basecampx.request "projects/#{project_id}.json"
end

Instance Method Details

#accessesObject

GET /projects/1/accesses.json



50
51
52
# File 'lib/basecampx/resources/project.rb', line 50

def accesses
  Person.parse Basecampx.request "projects/#{self.id}/accesses.json"
end

#attachmentsObject

GET /projects/1/attachments.json



35
36
37
# File 'lib/basecampx/resources/project.rb', line 35

def attachments
  Attachment.parse Basecampx.request "projects/#{self.id}/attachments.json"
end

#document(document_id) ⇒ Object

GET /projects/1/documents/1.json



45
46
47
# File 'lib/basecampx/resources/project.rb', line 45

def document document_id
  Document.new Basecampx.request "projects/#{self.id}/documents/#{document_id}.json"
end

#documentsObject

GET /projects/1/documents.json



40
41
42
# File 'lib/basecampx/resources/project.rb', line 40

def documents
  Document.parse Basecampx.request "projects/#{self.id}/documents.json"
end

#events(since = 1.day.ago) ⇒ Object



30
31
32
# File 'lib/basecampx/resources/project.rb', line 30

def events since=1.day.ago
  Event.parse Basecampx.request "/projects/#{self.id}/events.json?since=#{since.to_time.iso8601}"
end

#message(message_id) ⇒ Object

GET /projects/1/messages/1.json



69
70
71
# File 'lib/basecampx/resources/project.rb', line 69

def message message_id
  Message.parse Basecampx.request "projects/#{self.id}/messages/#{message_id}.json"
end

#revoke_access(person_id) ⇒ Object

DELETE /projects/1/accesses/1.json



60
61
62
63
64
65
66
# File 'lib/basecampx/resources/project.rb', line 60

def revoke_access person_id
  if person_id.class.name == 'Basecampx::Person'
    person_id = person_id.id
  end

  Basecampx.delete "projects/#{self.id}/accesses/#{person_id}.json"
end

#todo(todo_id) ⇒ Object

GET /projects/1/todos/1.json will return the specified todo.



15
16
17
# File 'lib/basecampx/resources/project.rb', line 15

def todo todo_id
  Todo.new Basecampx.request "projects/#{self.id}/todos/#{todo_id}.json"
end

#todo_list(todo_list_id) ⇒ Object

GET /projects/1/todolists/1.json will return the specified todolist including the todos.



26
27
28
# File 'lib/basecampx/resources/project.rb', line 26

def todo_list todo_list_id
  TodoList.new Basecampx.request "projects/#{self.id}/todolists/#{todo_list_id}.json"
end

#todo_lists(completed = false) ⇒ Object

GET /projects/1/todolists.json shows active todolists for this project sorted by position. GET /projects/1/todolists/completed.json shows completed todolists for this project.



21
22
23
# File 'lib/basecampx/resources/project.rb', line 21

def todo_lists completed=false
  TodoList.parse Basecampx.request "projects/#{self.id}/todolists#{completed ? '/completed' : ''}.json"
end