From: Damyan Ivanov Date: Tue, 15 Feb 2022 21:03:12 +0000 (+0000) Subject: protocol change: supply list name in the list of lists X-Git-Url: https://git.ktnx.net/?p=lsl.git;a=commitdiff_plain;h=020687a66b8b6e53c68e50d14719f1cdf02e2975 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 --- 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;