#!perl

use strict;
use warnings;

use Try::Tiny::SmartCatch;
use Business::Fixflo::Client;
use Business::Fixflo::Property;
use Data::Dumper;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{FIXFLO_DEBUG} = 1;

try sub {
	my $ff_property = Business::Fixflo::Property->new(
		client => Business::Fixflo::Client->new(
			'base_url'      => 'https://demo9eastside-property.test.fixflo.com',
			'api_key'       => 'MsBxomMrdxszeuhA3ZpuLmHv7mwTbtUYevI6NJZiMRsHiFUbv8Gn2aTgUV4099pS',
			'custom_domain' => 'demo9eastside-property',
		),
		ExternalPropertyRef => "PP174872",
	);

	$ff_property = $ff_property->get;

	my @tickets;

	my $paginator = $ff_property->Issues;
	while ( my @issues = $paginator->next ) {
		foreach my $issue ( @issues ) {
			print STDERR Dumper($issue);
			$issue->get;
			push @tickets, $issue;
		}
	}

	warn Dumper \@tickets;
},
catch_default sub {
	warn $_;
};
