1 package FS::SignupClient;
4 use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket);
11 @ISA = qw( Exporter );
12 @EXPORT_OK = qw( signup_info new_customer );
14 $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket";
16 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
17 $ENV{'SHELL'} = '/bin/sh';
18 $ENV{'IFS'} = " \t\n";
21 $ENV{'BASH_ENV'} = '';
23 my $freeside_uid = scalar(getpwnam('freeside'));
24 die "not running as the freeside user\n" if $> != $freeside_uid;
28 FS::SignupClient - Freeside signup client API
32 use FS::SignupClient qw( signup_info new_customer );
34 ( $locales, $packages, $pops ) = signup_info;
36 $error = new_customer ( {
40 'comapny' => $company,
41 'address1' => $address1,
42 'address2' => $address2,
47 'country' => $country,
48 'daytime' => $daytime,
52 'payinfo' => $payinfo,
53 'paydate' => $paydate,
54 'payname' => $payname,
55 'invoicing_list' => $invoicing_list,
56 'pkgpart' => $pkgpart,
57 'username' => $username,
58 '_password' => $password,
64 This module provides an API for a remote signup server.
66 It needs to be run as the freeside user. Because of this, the program which
67 calls these subroutines should be written very carefully.
75 Returns three array references of hash references.
77 The first set of hash references is of allowable locales. Each hash reference
78 has the following keys:
84 The second set of hash references is of allowable packages. Each hash
85 reference has the following keys:
89 The third set of hash references is of allowable POPs (Points Of Presence).
90 Each hash reference has the following keys:
100 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
101 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
102 print SOCK "signup_info\n";
105 chop ( my $n_cust_main_county = <SOCK> );
106 my @cust_main_county = map {
107 chop ( my $taxnum = <SOCK> );
108 chop ( my $state = <SOCK> );
109 chop ( my $county = <SOCK> );
110 chop ( my $country = <SOCK> );
115 'country' => $country,
117 } 1 .. $n_cust_main_county;
119 chop ( my $n_part_pkg = <SOCK> );
121 chop ( my $pkgpart = <SOCK> );
122 chop ( my $pkg = <SOCK> );
124 'pkgpart' => $pkgpart,
129 chop ( my $n_svc_acct_pop = <SOCK> );
130 my @svc_acct_pop = map {
131 chop ( my $popnum = <SOCK> );
132 chop ( my $city = <SOCK> );
133 chop ( my $state = <SOCK> );
134 chop ( my $ac = <SOCK> );
135 chop ( my $exch = <SOCK> );
136 chop ( my $loc = <SOCK> );
145 } 1 .. $n_svc_acct_pop;
149 \@cust_main_county, \@part_pkg, \@svc_acct_pop;
152 =item new_customer HASHREF
154 Adds a customer to the remote Freeside system. Requires a hash reference as
155 a paramater with the following keys:
180 Returns a scalar error message, or the empty string for success.
187 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
188 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
189 print SOCK "new_customer\n";
191 print SOCK join("\n", map { $hashref->{$_} } qw(
192 first last ss company address1 address2 city county state zip country
193 daytime night fax payby payinfo paydate payname invoicing_list
194 pkgpart username _password popnum
198 chop( my $error = <SOCK> );
206 $Id: SignupClient.pm,v 1.2 2000-01-28 22:49:28 ivan Exp $
212 L<fs_signupd>, L<FS::SignupServer>, L<FS::cust_main>