#!/usr/bin/env perl
#
# This script utilises the standard Open311 way of getting updates on reports
# (by fetching all reports for a body and looking for updates). If possible,
# please use the extension explained at
# https://github.com/mysociety/FixMyStreet/wiki/Open311-FMS---Proposed-differences-to-Open311
# and the fetch/send-comments scripts.

use strict;
use warnings;
use v5.14;

BEGIN {
    use File::Basename qw(dirname);
    use File::Spec;
    my $d = dirname(File::Spec->rel2abs($0));
    require "$d/../setenv.pl";
}

use Getopt::Long::Descriptive;
use Open311::GetUpdates;

my ($opts, $usage) = describe_options(
    '%c %o',
    ['body|b:s', 'body name to only fetch this body' ],
    ['verbose|v', 'more verbose output'],
    ['help|h', "print usage message and exit" ],
);
$usage->die if $opts->help;

my %params = (
    verbose => $opts->verbose,
    body => $opts->body,
);

my $updates = Open311::GetUpdates->new(%params);
$updates->fetch;
