WebService-Eulerian-Analytics

 view release on metacpan or  search on metacpan

lib/WebService/Eulerian/Analytics.pm  view on Meta::CPAN


=cut

sub faultstring		{ return shift()->_faultdetails_k('string');	}

sub _faultdetails_k {
 my ($self, $k) = @_; 
 return	$self->{_FAULTDETAILS}->{ $k };
}

=pod

=head2 call : generic SOAP call method (private)

This method should not be called directly, use the main classes.

=head3 input

=over 4

=item * name of the method to be called

=item * array of parameters sent to the method call

=back

=head3 output

=over 4

=item * if no error : returns the value of the Response part of the SOAP call

=item * if error : returns undef and set the fault flag to 1 and faultdetails with fault information

=back

=head3 sample

	my $rh_return = $service->call('MyMethodName', 'param1', { hash => 'param2' }, [ 'param3' ]);
	#
	# test if the server generated a fault
	if ( $service->fault ) {
	 # die on fault and display the faultstring
	 die $service->faultstring();
	}
	#
	# no fault : process the returned structure
	use Data::Dumper;
	print Dumper($rh_return);

=cut

sub call {
 my ($self, $method, @a_p) = @_;

 # reset fault methods
 $self->_faultclear();

 # build soap header with auth
 my @a_header   = (
  SOAP::Header->name("apikey")->value($self->{_APIKEY} )->type('')
 );

 # send SOAP request to API host
 my $soap       = SOAP::Lite->proxy(
   $self->_endpoint($self->{_HOST}, $self->{_VERSION}).'/'.$self->{_SERVICE},
   timeout       => $self->{_TIMEOUT}
   );
 my $result	= $soap->call(
   SOAP::Data->name($method)->uri($self->{_SERVICE}) => @a_header, @a_p);

 # check for a fault and return hash detailling fault if any
 if ( $result->fault ) {
  $self->_faultadd({
   code		=> $result->faultcode 	|| 0, 
   string	=> $result->faultstring	|| '', 
  });
  return	undef;
 }
 # no fault : return the generated structure
 return		$result->valueof('//'.$method.'Response/'.$method.'Return');
}

=pod

=head1 SEE ALSO

L<SOAP::Lite>

=head1 AUTHOR

Mathieu Jondet <mathieu@eulerian.com>

=head1 COPYRIGHT

Copyright (c) 2008 Eulerian Technologies Ltd L<http://www.eulerian.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

=cut

1;
__END__



( run in 2.373 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )