Module: ActiveProject::Adapters::Trello::Projects
- Included in:
- ActiveProject::Adapters::TrelloAdapter
- Defined in:
- lib/active_project/adapters/trello/projects.rb
Instance Method Summary collapse
-
#create_project(attributes) ⇒ ActiveProject::Resources::Project
Creates a new board in Trello.
-
#delete_project(board_id) ⇒ Boolean
Deletes a board in Trello.
-
#find_project(board_id) ⇒ ActiveProject::Resources::Project
Finds a specific Trello Board by its ID.
-
#list_projects ⇒ Array<ActiveProject::Resources::Project>
Lists Trello boards accessible by the configured token.
Instance Method Details
#create_project(attributes) ⇒ ActiveProject::Resources::Project
Creates a new board in Trello.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/active_project/adapters/trello/projects.rb', line 45 def create_project(attributes) unless attributes[:name] && !attributes[:name].empty? raise ArgumentError, "Missing required attribute for Trello board creation: :name" end path = "boards/" query_params = { name: attributes[:name], desc: attributes[:description], defaultLists: attributes.fetch(:default_lists, true) }.compact board_data = make_request(:post, path, nil, query_params) Resources::Project.new(self, id: board_data["id"], key: nil, name: board_data["name"], adapter_source: :trello, raw_data: board_data) end |
#delete_project(board_id) ⇒ Boolean
Deletes a board in Trello. WARNING: This is a permanent deletion.
74 75 76 77 78 |
# File 'lib/active_project/adapters/trello/projects.rb', line 74 def delete_project(board_id) path = "/boards/#{board_id}" make_request(:delete, path) true end |
#find_project(board_id) ⇒ ActiveProject::Resources::Project
Finds a specific Trello Board by its ID.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_project/adapters/trello/projects.rb', line 29 def find_project(board_id) path = "boards/#{board_id}" query = { fields: "id,name,desc" } board_data = make_request(:get, path, nil, query) Resources::Project.new(self, id: board_data["id"], key: nil, name: board_data["name"], adapter_source: :trello, raw_data: board_data) end |
#list_projects ⇒ Array<ActiveProject::Resources::Project>
Lists Trello boards accessible by the configured token.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_project/adapters/trello/projects.rb', line 9 def list_projects path = "members/me/boards" query = { fields: "id,name,desc" } boards_data = make_request(:get, path, nil, query) return [] unless boards_data.is_a?(Array) boards_data.map do |board_data| Resources::Project.new(self, id: board_data["id"], key: nil, name: board_data["name"], adapter_source: :trello, raw_data: board_data) end end |