Business-CyberSource-Report

 view release on metacpan or  search on metacpan

lib/Business/CyberSource/Report.pm  view on Meta::CPAN


	if ( !defined( $LOADED_REPORT_MODULES ) )
	{
		$LOADED_REPORT_MODULES = {};

		my $main_module_path = __PACKAGE__;
		$main_module_path =~ s/::/\//g;

		foreach my $module ( keys %INC )
		{
			next unless $module =~ m/^\Q$main_module_path\/\E([^\/]+)\.pm/;
			$LOADED_REPORT_MODULES->{ $1 } = undef;
		}
	}

	return [ keys %$LOADED_REPORT_MODULES ];
}


=head2 build()

Create a Business::CyberSource::Report::* object with the correct connection
parameters.

	# Use the factory to get a Business::CyberSource::Report::Test object with
	# the correct connection parameters.
	my $test_report = $report_factory->build( 'SingleTransaction' );

Parameters:

=over

=item *

The submodule name, such as SingleTransaction for
Business::CyberSource::Report::SingleTransaction.

=back

=cut

sub build
{
	my ( $self, $module ) = @_;

	croak 'Please specify the name of the module to build'
		if !defined( $module ) || ( $module eq '' );

	my $class = __PACKAGE__ . '::' . $module;

	# If the module isn't already loaded, do that now.
	if ( scalar( grep { $module eq $_ } @{ $self->list_loaded() || [] } ) == 0 )
	{
		Class::Load::load_optional_class( $class ) || croak "Failed to load $class, double-check the class name";
		$LOADED_REPORT_MODULES->{ $module } = undef;
	}

	my $object = bless(
		# Create a copy of the factory's guts, the object will be a subclass of
		# the factory and will be able to use all the information.
		# Also, we don't want a change in the factory parameters to cascade to
		# the objects previously built, so it makes sense to copy.
		# TBD: copy only a selected subset of the content?
		Storable::dclone( $self ),
		$class,
	);

	return $object;
}


=head1 ACCESSORS

=head2 get_username()

Return the username to use to connect to the service.

	my $username = $report_factory->get_username();

=cut

sub get_username
{
	my ( $self ) = @_;

	return $self->{'username'};
}


=head2 get_password()

Return the password to use to connect to the service.

	my $password = $report_factory->get_password();

=cut

sub get_password
{
	my ( $self ) = @_;

	return $self->{'password'};
}


=head2 get_merchant_id()

Return the merchant ID to use to connect to the service.

	my $merchant_id = $report_factory->get_merchant_id();

=cut

sub get_merchant_id
{
	my ( $self ) = @_;

	return $self->{'merchant_id'};
}




( run in 0.448 second using v1.01-cache-2.11-cpan-56fb94df46f )