Module: ActiveProject::Adapters::Fizzy::Projects
- Included in:
- ActiveProject::Adapters::FizzyAdapter
- Defined in:
- lib/active_project/adapters/fizzy/projects.rb
Instance Method Summary collapse
-
#create_project(attributes) ⇒ ActiveProject::Resources::Project
Creates a new board in Fizzy.
-
#delete_project(board_id) ⇒ Boolean
Deletes a board in Fizzy.
-
#find_project(board_id) ⇒ ActiveProject::Resources::Project
Finds a specific board by its ID.
-
#list_projects ⇒ Array<ActiveProject::Resources::Project>
Lists boards accessible by the configured credentials.
Instance Method Details
#create_project(attributes) ⇒ ActiveProject::Resources::Project
Creates a new board in Fizzy.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/active_project/adapters/fizzy/projects.rb', line 48 def create_project(attributes) unless attributes[:name] && !attributes[:name].empty? raise ArgumentError, "Missing required attribute for Fizzy board creation: :name" end path = "boards.json" payload = { board: { name: attributes[:name], all_access: attributes.fetch(:all_access, true), auto_postpone_period: attributes[:auto_postpone_period] }.compact } # Fizzy returns 201 Created with Location header, need to fetch the board response = @connection.post(path) do |req| req.body = payload.to_json end # Extract board ID from Location header and fetch it location = response.headers["Location"] if location board_id = location.match(%r{/boards/([^/.]+)})[1] find_project(board_id) else # Fallback: parse response body if available board_data = parse_response(response) map_board_data(board_data) end rescue Faraday::Error => e handle_faraday_error(e) end |
#delete_project(board_id) ⇒ Boolean
Deletes a board in Fizzy.
84 85 86 87 88 |
# File 'lib/active_project/adapters/fizzy/projects.rb', line 84 def delete_project(board_id) path = "boards/#{board_id}.json" make_request(:delete, path) true end |
#find_project(board_id) ⇒ ActiveProject::Resources::Project
Finds a specific board by its ID.
37 38 39 40 41 42 43 |
# File 'lib/active_project/adapters/fizzy/projects.rb', line 37 def find_project(board_id) path = "boards/#{board_id}.json" board_data = make_request(:get, path) return nil unless board_data map_board_data(board_data) end |
#list_projects ⇒ Array<ActiveProject::Resources::Project>
Lists boards accessible by the configured credentials. Handles pagination automatically using the Link header.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_project/adapters/fizzy/projects.rb', line 10 def list_projects all_boards = [] path = "boards.json" loop do response = @connection.get(path) boards_data = parse_response(response) break if boards_data.empty? boards_data.each do |board_data| all_boards << map_board_data(board_data) end next_url = parse_next_link(response.headers["Link"]) break unless next_url path = extract_path_from_url(next_url) end all_boards rescue Faraday::Error => e handle_faraday_error(e) end |