move signup server functions to self-service server. fix provisioning &
[freeside.git] / fs_signup / FS-SignupClient / SignupClient.pm
1 package FS::SignupClient;
2
3 use strict;
4 use vars qw($VERSION @ISA @EXPORT_OK); # $fs_signupd_socket);
5 use Exporter;
6 #use Socket;
7 #use FileHandle;
8 #use IO::Handle;
9 #use Storable qw(nstore_fd fd_retrieve);
10 use FS::SelfService qw( new_customer ); #qw( signup_info );
11
12 $VERSION = '0.04';
13
14 @ISA = qw( Exporter );
15 @EXPORT_OK = qw( signup_info new_customer );
16
17 =head1 NAME
18
19 FS::SignupClient - Freeside signup client API
20
21 =head1 SYNOPSIS
22
23   use FS::SignupClient qw( signup_info new_customer );
24
25   #this is the backwards-compatibility bit
26   ( $locales, $packages, $pops, $real_signup_info ) = signup_info;
27
28   #this is compatible with FS::SelfService::new_customer
29   $error = new_customer ( {
30     'first'            => $first,
31     'last'             => $last,
32     'ss'               => $ss,
33     'comapny'          => $company,
34     'address1'         => $address1,
35     'address2'         => $address2,
36     'city'             => $city,
37     'county'           => $county,
38     'state'            => $state,
39     'zip'              => $zip,
40     'country'          => $country,
41     'daytime'          => $daytime,
42     'night'            => $night,
43     'fax'              => $fax,
44     'payby'            => $payby,
45     'payinfo'          => $payinfo,
46     'paydate'          => $paydate,
47     'payname'          => $payname,
48     'invoicing_list'   => $invoicing_list,
49     'referral_custnum' => $referral_custnum,
50     'comments'         => $comments,
51     'pkgpart'          => $pkgpart,
52     'username'         => $username,
53     '_password'        => $password,
54     'sec_phrase'       => $sec_phrase,
55     'popnum'           => $popnum,
56     'agentnum'         => $agentnum, #optional
57   } );
58
59 =head1 DESCRIPTION
60
61 This module provides an API for a remote signup server.
62
63 It needs to be run as the freeside user.  Because of this, the program which
64 calls these subroutines should be written very carefully.
65
66 =head1 SUBROUTINES
67
68 =over 4
69
70 =item signup_info
71
72 Returns three array references of hash references.
73
74 The first set of hash references is of allowable locales.  Each hash reference
75 has the following keys:
76   taxnum
77   state
78   county
79   country
80
81 The second set of hash references is of allowable packages.  Each hash
82 reference has the following keys:
83   pkgpart
84   pkg
85
86 The third set of hash references is of allowable POPs (Points Of Presence).
87 Each hash reference has the following keys:
88   popnum
89   city
90   state
91   ac
92   exch
93
94 (Future expansion: fourth argument is the $init_data hash reference)
95
96 =cut
97
98 #compatibility bit
99 sub signup_info {
100
101   my $init_data = FS::SelfService::signup_info();
102
103   (map { $init_data->{$_} } qw( cust_main_county part_pkg svc_acct_pop ) ),
104   $init_data;
105
106 }
107
108 =item new_customer HASHREF
109
110 Adds a customer to the remote Freeside system.  Requires a hash reference as
111 a paramater with the following keys:
112   first
113   last
114   ss
115   comapny
116   address1
117   address2
118   city
119   county
120   state
121   zip
122   country
123   daytime
124   night
125   fax
126   payby
127   payinfo
128   paydate
129   payname
130   invoicing_list
131   referral_custnum
132   comments
133   pkgpart
134   username
135   _password
136   sec_phrase
137   popnum
138
139 Returns a scalar error message, or the empty string for success.
140
141 =back
142
143 =head1 BUGS
144
145 =head1 SEE ALSO
146
147 L<fs_signupd>, L<FS::cust_main>
148
149 =cut
150
151 1;
152