use strict;
our $VERSION = '0.001'; # TRIAL VERSION
use Moo;
use JSON::Tiny 'decode_json';
has 'url' => (
is => 'ro',
);
sub competition {
my ( $self, %args ) = @_;
return { error => 'id parameter is required' } unless defined $args{id};
my $url
= $self->url
. '?params[action]=general.get_one'
. '&params[module]=competition'
. '&params[id]='
. $args{id};
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new( GET => $url );
my $response = $ua->request($request);
return decode_json $response->content
if $response->code == 200;
return { error => 'Error retreiving competitor info' };
}
1;