use 5.14.0;
use strict;
use warnings;

package OpenGbg::Service::Getter {

    our $VERSION = '0.1301'; # VERSION

    use Moose::Role;
    use Kavorka;

    method getter($service_url, $service_name) {
        $service_url = sprintf $service_url, $self->handler->key;
        my $url = $self->handler->base . $self->service_base . $service_url.'format=xml';

        my $response = $self->handler->get($url);

        if(!$response->{'success'}) {
            OpenGbg::Exception::BadResponseFromService->throw(service => ref $self.'::'.$service_name, url => $response->{'url'}, status => $response->{'status'}, reason => $response->{'reason'});
        }
        return $response->{'content'};
    }
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

OpenGbg::Service::Getter

=head1 VERSION

Version 0.1301, released 2015-01-16.

=head1 SOURCE

L<https://github.com/Csson/p5-OpenGbg>

=head1 HOMEPAGE

L<https://metacpan.org/release/OpenGbg>

=head1 AUTHOR

Erik Carlsson <info@code301.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
