remove old test files
[freeside.git] / FS / FS / ClientAPI.pm
1 package FS::ClientAPI;
2
3 use strict;
4 use base 'Exporter';
5 use vars qw( @EXPORT_OK %handler $domain $DEBUG $me );
6 use FS::UID qw( dbh );
7
8 @EXPORT_OK = qw( load_clientapi_modules );
9
10 $DEBUG = 0;
11 $me = '[FS::ClientAPI]';
12
13 %handler = ();
14
15 sub load_clientapi_modules {
16
17   #find modules
18   foreach my $INC ( @INC ) {
19     my $glob = "$INC/FS/ClientAPI/*.pm";
20     warn "FS::ClientAPI: searching $glob" if $DEBUG;
21     foreach my $file ( glob($glob) ) {
22       $file =~ /\/(\w+)\.pm$/ or do {
23         warn "unrecognized ClientAPI file: $file";
24         next
25       };
26       my $mod = $1;
27       warn "using FS::ClientAPI::$mod" if $DEBUG;
28       eval "use FS::ClientAPI::$mod;";
29       die "error using FS::ClientAPI::$mod: $@" if $@;
30     }
31   }
32
33 }
34
35 sub dispatch {
36   my ( $self, $name ) = ( shift, shift );
37   $name =~ s(/)(::)g;
38   my $sub = "FS::ClientAPI::$name";
39
40   dbh->{'private_profile'} = {};
41
42   warn "$me dispatch: calling $sub with args @_\n" if $DEBUG;
43   no strict 'refs';
44   my $rv = &{$sub}(@_);
45
46   warn dbh->sprintProfile if dbh->can('sprintProfile');
47   dbh->{'private_profile'} = {};
48
49   $rv;
50 }
51
52 1;
53