diff translate.pl @ 7:29309bc8d932

initial objects to work with bugzilla web service
author cin
date Fri, 04 Sep 2015 19:41:28 +0300
parents 2a5f38eb25a9
children cc7244ab1b9f
line wrap: on
line diff
--- a/translate.pl	Wed Sep 02 20:43:38 2015 +0300
+++ b/translate.pl	Fri Sep 04 19:41:28 2015 +0300
@@ -122,99 +122,9 @@
 close HIN;
 finish($proc);
 
-#xalan(
-#    in => \*OUT,
-#    out => \*STDOUT,
-#    params => [
-#
-#   ]
-#);
-
-sub xalan {
-	my @params = @_;
-	return system 'java',
-	  -cp => join( ':', @ClassPath ),
-	  "org.apache.xalan.xslt.Process", @params;
-}
-
 package BzRest;
-use fields qw(url apikey);
-use LWP::UserAgent;
-use XMLRPC::Lite;
-use YAML::XS qw(Dump);
-
-use constant { SELF => __PACKAGE__ };
-
-sub new {
-	my $class = shift;
-	$class = ref $class || $class;
-
-	my $inst = fields::new($class);
-	$inst->CTOR(@_);
-
-	return $inst;
-}
-
-sub CTOR {
-	my SELF $this = shift;
-	my %params = @_;
-
-	$this->{url} = $params{url} or die "An url is required";
-	$this->{apikey} = $params{apikey} if $params{apikey};
-}
-
-sub GetBug {
-	my SELF $this = shift;
-	my $id        = shift;
-	my %params    = @_;
 
-	$params{api_key} = $this->{apikey};
 
-	my $bugurl = URI->new_abs( 'rest/bug/' . $id, $this->{url} );
-	$bugurl->query_form( \%params );
-
-	my $agent = LWP::UserAgent->new();
-	my $res   = $agent->get($bugurl);
-
-	return $this->_AssertResponse( $res, $bugurl );
-}
-
-sub GetBugs {
-	my SELF $this = shift;
-
-	return $this->CallXMLRPC( 'Bug.get', shift )->{bugs};
-}
-
-sub CallXMLRPC {
-	my SELF $this = shift;
-	my ( $method, $params ) = @_;
-
-	die "Method must be specified" unless $method;
-	$params ||= {};
-
-	$params->{api_key} = $this->{apikey};
-	my $url = URI->new_abs( 'xmlrpc.cgi', $this->{url} );
-
-	my $result = XMLRPC::Lite->proxy($url)->call( $method, $params );
-
-	die $result->fault if $result->fault;
-	return $result->result;
-}
-
-sub _AssertResponse {
-	my SELF $this = shift;
-	my ( $res, $url ) = @_;
-
-	die "Failed to get any response: " . $url unless $res;
-
-	die "Failed to fetch: " . $url . ": " . $res->code unless $res->is_success;
-
-	my $bug = JSON->new()->utf8()->decode( $res->content );
-
-	die "Bugzilla failed: " . $bug->{message} if $bug->{error};
-
-	return $bug->{bugs};
-}
 
 __END__