$r{version} = $item->version;
$r{list_version} = $list->version;
+ return \%r;
+};
+
+# delete shopping list
+del '/list/:list_id' => sub {
+ my $list_id = route_parameters->get('list_id');
+ length($list_id) and $list_id =~ /^\d{1,18}$/
+ or return invalid_input('bad list ID');
+
+ my $dbh = get_database;
+
+ my %r = (
+ lists_version => get_lists_version($dbh),
+ );
+
+ my $list = $dbh->resultset('ShoppingList')->find($list_id);
+ if ($list) {
+ $list->delete;
+ $r{lists_version} = increment_lists_version($dbh)
+ }
return \%r;
};