Module: ActiveProject::Adapters::Fizzy::Columns

Included in:
ActiveProject::Adapters::FizzyAdapter
Defined in:
lib/active_project/adapters/fizzy/columns.rb

Instance Method Summary collapse

Instance Method Details

#create_list(board_id, attributes) ⇒ Hash

Creates a new column on a board.

Parameters:

  • board_id (String)

    The board ULID.

  • attributes (Hash)

    Column attributes.

    • :name [String] Required. The column name.

    • :color [String] Optional. CSS var color (e.g., “var(–color-card-4)”).

Returns:

  • (Hash)

    The created column hash.



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.

Parameters:

  • board_id (String)

    The board ULID.

  • column_id (String)

    The column ULID.

Returns:

  • (Boolean)

    True if successfully deleted.



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.

Parameters:

  • board_id (String)

    The board ULID.

  • column_id (String)

    The column ULID.

Returns:

  • (Hash)

    The column hash.



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.

Parameters:

  • board_id (String)

    The board ULID.

Returns:

  • (Array<Hash>)

    An array of column hashes.



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.

Parameters:

  • board_id (String)

    The board ULID.

  • column_id (String)

    The column ULID.

  • attributes (Hash)

    Attributes to update.

    • :name [String] The column name.

    • :color [String] CSS var color.

Returns:

  • (Hash)

    The updated column hash.



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