From 020687a66b8b6e53c68e50d14719f1cdf02e2975 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 15 Feb 2022 21:03:12 +0000 Subject: [PATCH] protocol change: supply list name in the list of lists the idea is that an app would want to have the name early in order to be able to display the list of available shopping lists, and later, after the user selects a shopping list, it would retrieve the items also, it makes more sense this way since the lists_version thing is a property of the list of shopping lists and is changed upon a list rename --- doc/protocol.md | 6 +++--- lib/App/LazyShoppingList/API/v1.pm | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/protocol.md b/doc/protocol.md index ae7bad5..e0cf516 100644 --- a/doc/protocol.md +++ b/doc/protocol.md @@ -14,8 +14,9 @@ GET /list Returns a JSON object with the following keys: - - `lists`: a list of shopping list URIs. Referred to as `/list/$list_id` - below. + - `lists`: a list of objects with the following keys: + - `uri`: tjhe list URIs. Referred to as `/list/$list_id` below. + - `name`: list name as entered by users - `lists_version`: a number that is incremented by 1 each time the list of shopping lists changes. Changes include adding, removing and renaming a shopping list, but not changes to individual shopping list items. @@ -25,7 +26,6 @@ GET /list/$list_id Returns a JSON object with the following keys: - - `name`: list name, as entered by users - `items`: a list of shopping list item objects with keys: - `uri`: the URI of the individual list item - `description`: item description diff --git a/lib/App/LazyShoppingList/API/v1.pm b/lib/App/LazyShoppingList/API/v1.pm index 46995e8..8a30acb 100644 --- a/lib/App/LazyShoppingList/API/v1.pm +++ b/lib/App/LazyShoppingList/API/v1.pm @@ -34,7 +34,8 @@ get '/list' => sub { { order_by => { -asc => 'name' } } )->all ) { - push @{ $r{lists} }, uri_for( "/list/" . $list->id ); + push @{ $r{lists} }, + { uri => uri_for( "/list/" . $list->id ), name => $list->name }; } $dbh->txn_commit; -- 2.39.5