1 package FS::SignupClient;
4 use vars qw($VERSION @ISA @EXPORT_OK $fs_signupd_socket);
12 @ISA = qw( Exporter );
13 @EXPORT_OK = qw( signup_info new_customer );
15 $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket";
17 $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin';
18 $ENV{'SHELL'} = '/bin/sh';
19 $ENV{'IFS'} = " \t\n";
22 $ENV{'BASH_ENV'} = '';
24 my $freeside_uid = scalar(getpwnam('freeside'));
25 die "not running as the freeside user\n" if $> != $freeside_uid;
29 FS::SignupClient - Freeside signup client API
33 use FS::SignupClient qw( signup_info new_customer );
35 ( $locales, $packages, $pops ) = signup_info;
37 $error = new_customer ( {
41 'comapny' => $company,
42 'address1' => $address1,
43 'address2' => $address2,
48 'country' => $country,
49 'daytime' => $daytime,
53 'payinfo' => $payinfo,
54 'paydate' => $paydate,
55 'payname' => $payname,
56 'invoicing_list' => $invoicing_list,
57 'pkgpart' => $pkgpart,
58 'username' => $username,
59 '_password' => $password,
65 This module provides an API for a remote signup server.
67 It needs to be run as the freeside user. Because of this, the program which
68 calls these subroutines should be written very carefully.
76 Returns three array references of hash references.
78 The first set of hash references is of allowable locales. Each hash reference
79 has the following keys:
85 The second set of hash references is of allowable packages. Each hash
86 reference has the following keys:
90 The third set of hash references is of allowable POPs (Points Of Presence).
91 Each hash reference has the following keys:
101 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
102 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
103 print SOCK "signup_info\n";
106 chop ( my $n_cust_main_county = <SOCK> );
107 my @cust_main_county = map {
108 chop ( my $taxnum = <SOCK> );
109 chop ( my $state = <SOCK> );
110 chop ( my $county = <SOCK> );
111 chop ( my $country = <SOCK> );
116 'country' => $country,
118 } 1 .. $n_cust_main_county;
120 chop ( my $n_part_pkg = <SOCK> );
122 chop ( my $pkgpart = <SOCK> );
123 chop ( my $pkg = <SOCK> );
125 'pkgpart' => $pkgpart,
130 chop ( my $n_svc_acct_pop = <SOCK> );
131 my @svc_acct_pop = map {
132 chop ( my $popnum = <SOCK> );
133 chop ( my $city = <SOCK> );
134 chop ( my $state = <SOCK> );
135 chop ( my $ac = <SOCK> );
136 chop ( my $exch = <SOCK> );
137 chop ( my $loc = <SOCK> );
146 } 1 .. $n_svc_acct_pop;
150 \@cust_main_county, \@part_pkg, \@svc_acct_pop;
153 =item new_customer HASHREF
155 Adds a customer to the remote Freeside system. Requires a hash reference as
156 a paramater with the following keys:
181 Returns a scalar error message, or the empty string for success.
188 socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!";
189 connect(SOCK, sockaddr_un($fs_signupd_socket)) or die "connect: $!";
190 print SOCK "new_customer\n";
192 print SOCK join("\n", map { $hashref->{$_} } qw(
193 first last ss company address1 address2 city county state zip country
194 daytime night fax payby payinfo paydate payname invoicing_list
195 pkgpart username _password popnum
199 chop( my $error = <SOCK> );
207 $Id: SignupClient.pm,v 1.3 2000-02-02 07:44:00 ivan Exp $
213 L<fs_signupd>, L<FS::SignupServer>, L<FS::cust_main>