POE::Component::Github::Request::Commits - Build HTTP::Request objects for Commits API


POE-Component-Github documentation Contained in the POE-Component-Github distribution.

Index


Code Index:

NAME

Top

POE::Component::Github::Request::Commits - Build HTTP::Request objects for Commits API

DESCRIPTION

Top

Builds HTTP::Request objects for the Commits API.

CONSTRUCTOR

Top

new

Attributes:

  cmd
  user
  repo
  branch
  file
  commit

METHOD

Top

request

Returns a HTTP::Request object based on the data passed to new.

AUTHOR

Top

Chris BinGOs Williams <chris@bingosnet.co.uk>

LICENSE

Top

Copyright © Chris Williams

This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.


POE-Component-Github documentation Contained in the POE-Component-Github distribution.

package POE::Component::Github::Request::Commits;

use strict;
use warnings;
use HTTP::Request::Common;
use vars qw($VERSION);

$VERSION = '0.08';

use Moose;
use Moose::Util::TypeConstraints;

use URI::Escape;

with 'POE::Component::Github::Request::Role';

has cmd => (
  is       => 'ro',
  isa      => enum([qw(
		branch
		file
		commit
              )]),
  required => 1,
);

has user => (
  is       => 'ro',
  default  => '',
);

has repo => (
  is       => 'ro',
  default  => '',
);

has branch => (
  is       => 'ro',
  default  => 'master',
);

has file => (
  is       => 'ro',
  default  => '',
);

has commit => (
  is       => 'ro',
  default  => '',
);

# Commits

sub request {
  my $self = shift;
  # No authenticated requests
  my $url = $self->scheme . join '/', $self->api_url, 'commits';
  if ( $self->cmd =~ /^(branch|file)$/ ) {
     return GET( join('/', $url, 'list', $self->user, $self->repo, $self->branch, ( $self->cmd eq 'file' ? $self->file : () )) );
  }
  if ( $self->cmd eq 'commit' ) {
     return GET( join('/', $url, 'show', $self->user, $self->repo, $self->commit) );
  }
}

no Moose;

__PACKAGE__->meta->make_immutable;

1;
__END__