Acme-Free-API-Ye

 view release on metacpan or  search on metacpan

lib/Acme/Free/API/Ye.pm  view on Meta::CPAN

package Acme::Free::API::Ye;

use strict;
use warnings;

our $VERSION = '1.0.2';

use HTTP::Tiny;
use JSON            qw/decode_json/;
use Util::H2O::More qw/baptise d2o/;

use constant {
    BASEURL => "https://api.kanye.rest",
};

sub new {
    my $pkg  = shift;
    my $self = baptise { ua => HTTP::Tiny->new }, $pkg;
    return $self;
}

sub get {
    my $self = shift;
    my $resp = d2o $self->ua->get(BASEURL);
    return d2o decode_json $resp->content;
}

sub quote {
    my $self = shift;
    return $self->get->quote;
}

1;

__END__

=head1 NAME

Acme::Free::API::Ye - Perl API client for the Kanye Rest Quote API service, L<https://kanye.rest/>.

This module provides the client, "ye", that is available via C<PATH> after install.

=head1 SYNOPSIS

  #!/usr/bin/env perl
    
  use strict;
  use warnings;
  
  use Acme::Free::API::Ye qw//;
  
  my $ye = Acme::Free::API::Ye->new;

  printf "%s\n", $ye->quote;

=head2 C<ye> Commandline Client

After installing this module, simply run the command C<ye> without any arguments, and it will print
a random Kanye Rest quote to C<STDOUT>.

  shell> ye
  If I don't scream, if I don't say something then no one's going to say anything. 
  shell> ye
  Culture is the most powerful force in humanity under God
  shell>

=head1 DESCRIPTION

Contributed as part of the B<FreePublicPerlAPIs> Project described at,



( run in 0.882 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )