summaryrefslogtreecommitdiff
path: root/FS/FS/ClientAPI.pm
blob: 902f58b31ba410708f6766564705864ac49b3b33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package FS::ClientAPI;

use strict;
use vars qw(%handler $domain $DEBUG);

$DEBUG = 0;

%handler = ();

#find modules
foreach my $INC ( @INC ) {
  my $glob = "$INC/FS/ClientAPI/*.pm";
  warn "FS::ClientAPI: searching $glob" if $DEBUG;
  foreach my $file ( glob($glob) ) {
    $file =~ /\/(\w+)\.pm$/ or do {
      warn "unrecognized ClientAPI file: $file";
      next
    };
    my $mod = $1;
    warn "using FS::ClientAPI::$mod" if $DEBUG;
    eval "use FS::ClientAPI::$mod;";
    die "error using FS::ClientAPI::$mod: $@" if $@;
  }
}

#---

sub dispatch {
  my ( $self, $name ) = ( shift, shift );
  $name =~ s(/)(::)g;
  my $sub = "FS::ClientAPI::$name";
  no strict 'refs';
  &{$sub}(@_);
}

1;