#################### main pod documentation begin ################### =head1 NAME Zymonic::Decryptor::Message::Report - Zymonic Decryptor Report. =head1 SYNOPSIS This Message allows for the Decryptor generate reports =head1 DESCRIPTION This Message allows for the Decryptor generate reports =head1 USAGE The message should be: { messagetype => 'Report', report_type => 'FilterResults', # any Report subclass report_options => { ... }, #' options to pass through to Report object report_action => 'local_file', # or 'remote_file' or 'email', # if local file directory => '...', filename => '..., # if remote file protocol => '...', host => '...', port => '...', username => '...', password => '...', directory => '...', filename => '..., # if email subject => '...', body => '...', cc => '...', bcc => '...', report_file_name => '...', content_type => '...', } } The response will be: { success => 'true' } or { error => '...' } =head1 BUGS None we're aware of... =head1 SUPPORT As in the license, Zymonic is provided without warranty or support unless purchased separately, however... If you email zymonic-support@zednax.com your issue will be noted and may receive a response. For security issues, please contact zymonic-security@zednax.com and someone will respond within 8 working hours. =head1 AUTHOR Alex Masidlover et al. CPAN ID: MODAUTHOR Zednax Limited alex.masidlover@zednax.com http://www.zednax.com =head1 COPYRIGHT This program is free software licensed under the... Zymonic Public License 1.0 The full text of the license can be found in the LICENSE file included with this module. Other licenses may be acceptable if including parts of Zymonic in larger projects, please contact Zednax for details. =head1 SEE ALSO Zymonic::PaymentGateway perl(1). =cut #################### main pod documentation end ################### package Zymonic::Decryptor::Message::Report; use strict; use warnings; BEGIN { use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = '0.01'; @ISA = qw(Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw(); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } use base 'Zymonic::Decryptor::Message'; use Zymonic::Utils qw(module_exists clean debug); #################### subroutine header begin #################### =head2 respond Usage : Purpose : Returns : Argument : Throws : Comment : See Also : =cut #################### subroutine header end #################### sub respond { my $self = shift; my $in = shift; # Log that the decryptor report was called - include the report_type and report_action $self->{decryptor_server} ->connection_log("Decryptor Report Requested - Type: $in->{report_type} - Action: $in->{report_action}"); # Check for required parameters map { return { error => "No Report $_ specified." } unless $in->{$_}; } qw(report_type report_options report_action); # Make sure we have a correct report action unless ( $in->{report_action} =~ /email|local_file|remote_file/ ) { return { error => 'report_action must be email, local_file or remote_file' }; } # Check we have a valid hash unless ( ref( $in->{report_options} ) eq 'HASH' ) { return { error => 'Report options must be a hash' }; } # Check requested report type exists. my $report_module = "Zymonic::Report::$in->{report_type}"; unless ( module_exists($report_module) ) { return { error => "Report type '$in->{report_type}' does not exist" }; } my $report = $report_module->new( parent => $self, config => $self->{decryptor_server}->{config}, DB => $self->{decryptor_server}->{DB}, %{ $in->{report_options} } ); if ( $in->{report_action} eq 'email' ) { $report->send_email( $in->{to}, $in->{subject}, $in->{body}, $in->{report_file_name}, $in->{cc}, $in->{bcc}, $in->{content_type} ); } elsif ( $in->{report_action} eq 'local_file' ) { $report->file_report( $in->{filename}, $in->{directory}, $in->{appendfile} ); } elsif ( $in->{report_action} eq 'remote_file' ) { $report->remote_file_report( $in->{protocol}, $in->{host}, $in->{port}, $in->{username}, $in->{password}, $in->{filename}, $in->{directory}, [] ); } else { return { error => "Unknown action: $in->{report_action}" }; } return { success => 'true' }; } 1;