Module: ActiveProject::Adapters::Fizzy::Columns
- Included in:
- ActiveProject::Adapters::FizzyAdapter
- Defined in:
- lib/active_project/adapters/fizzy/columns.rb
Instance Method Summary collapse
-
#create_list(board_id, attributes) ⇒ Hash
Creates a new column on a board.
-
#delete_list(board_id, column_id) ⇒ Boolean
Deletes a column.
-
#find_list(board_id, column_id) ⇒ Hash
Finds a specific column.
-
#list_lists(board_id) ⇒ Array<Hash>
Lists columns (workflow stages) on a board.
-
#update_list(board_id, column_id, attributes) ⇒ Hash
Updates a column.
Instance Method Details
#create_list(board_id, attributes) ⇒ Hash
Creates a new column on a board.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/active_project/adapters/fizzy/columns.rb', line 28 def create_list(board_id, attributes) unless attributes[:name] && !attributes[:name].empty? raise ArgumentError, "Missing required attribute for Fizzy column creation: :name" end path = "boards/#{board_id}/columns.json" payload = { column: { name: attributes[:name], color: attributes[:color] }.compact } response = @connection.post(path) do |req| req.body = payload.to_json end # Extract column ID from Location header and fetch it location = response.headers["Location"] if location column_id = location.match(%r{/columns/([^/.]+)})[1] find_list(board_id, column_id) else # Fallback: parse response body if available column_data = parse_response(response) map_column_data(column_data, board_id) end rescue Faraday::Error => e handle_faraday_error(e) end |
#delete_list(board_id, column_id) ⇒ Boolean
Deletes a column.
95 96 97 98 99 |
# File 'lib/active_project/adapters/fizzy/columns.rb', line 95 def delete_list(board_id, column_id) path = "boards/#{board_id}/columns/#{column_id}.json" make_request(:delete, path) true end |
#find_list(board_id, column_id) ⇒ Hash
Finds a specific column.
63 64 65 66 67 68 69 |
# File 'lib/active_project/adapters/fizzy/columns.rb', line 63 def find_list(board_id, column_id) path = "boards/#{board_id}/columns/#{column_id}.json" column_data = make_request(:get, path) return nil unless column_data map_column_data(column_data, board_id) end |
#list_lists(board_id) ⇒ Array<Hash>
Lists columns (workflow stages) on a board.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_project/adapters/fizzy/columns.rb', line 10 def list_lists(board_id) path = "boards/#{board_id}/columns.json" response = @connection.get(path) columns_data = parse_response(response) columns_data.map do |column_data| map_column_data(column_data, board_id) end rescue Faraday::Error => e handle_faraday_error(e) end |
#update_list(board_id, column_id, attributes) ⇒ Hash
Updates a column.
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/active_project/adapters/fizzy/columns.rb', line 78 def update_list(board_id, column_id, attributes) path = "boards/#{board_id}/columns/#{column_id}.json" payload = { column: { name: attributes[:name], color: attributes[:color] }.compact } make_request(:put, path, payload.to_json) find_list(board_id, column_id) end |