Class: Logan::Project

Inherits:
Object
  • Object
show all
Includes:
HashConstructed
Defined in:
lib/logan/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashConstructed

#initialize

Instance Attribute Details

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/logan/project.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/logan/project.rb', line 9

def name
  @name
end

Instance Method Details

#all_todolistsArray<Logan::TodoList>

get both active and completed todo lists for this project from Basecamp API

Returns:

  • (Array<Logan::TodoList>)

    array of active and completed todo lists for this project



34
35
36
# File 'lib/logan/project.rb', line 34

def all_todolists
  todolists + completed_todolists
end

#completed_todolistsArray<Logan::TodoList>

get completed todo lists for this project from Basecamp API

Returns:

  • (Array<Logan::TodoList>)

    array of completed todo lists for this project



24
25
26
27
28
29
# File 'lib/logan/project.rb', line 24

def completed_todolists
  completed_response = Logan::Client.get "/projects/#{@id}/todolists/completed.json"
  lists_array = completed_response.parsed_response.map do |h| 
    Logan::TodoList.new h.merge({ :project_id => @id })
  end
end

#create_todolist(todo_list) ⇒ Logan::TodoList

create a todo list in this project via Basecamp API

Parameters:

Returns:



51
52
53
54
55
56
57
58
59
# File 'lib/logan/project.rb', line 51

def create_todolist(todo_list)
  post_params = {
    :body => todo_list.post_json,
    :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})
  }
      
  response = Logan::Client.post "/projects/#{@id}/todolists.json", post_params
  Logan::TodoList.new response.merge({ :project_id => @id })
end

#todolist(list_id) ⇒ Logan::TodoList

get an individual todo list for this project from Basecamp API

Parameters:

  • list_id (String)

    id for the todo list

Returns:



42
43
44
45
# File 'lib/logan/project.rb', line 42

def todolist(list_id)
  response = Logan::Client.get "/projects/#{@id}/todolists/#{list_id}.json"
  Logan::TodoList.new response.parsed_response.merge({ :project_id => @id })
end

#todolistsArray<Logan::TodoList>

get active todo lists for this project from Basecamp API

Returns:



14
15
16
17
18
19
# File 'lib/logan/project.rb', line 14

def todolists
  active_response = Logan::Client.get "/projects/#{@id}/todolists.json"
  lists_array = active_response.parsed_response.map do |h| 
    Logan::TodoList.new h.merge({ :project_id => @id })
  end
end