This commit was generated by cvs2svn to compensate for changes in r3241,
[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 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     'paycvv'           => $paycvv,
47     'paydate'          => $paydate,
48     'payname'          => $payname,
49     'invoicing_list'   => $invoicing_list,
50     'referral_custnum' => $referral_custnum,
51     'comments'         => $comments,
52     'pkgpart'          => $pkgpart,
53     'username'         => $username,
54     '_password'        => $password,
55     'sec_phrase'       => $sec_phrase,
56     'popnum'           => $popnum,
57     'agentnum'         => $agentnum, #optional
58   } );
59
60 =head1 DESCRIPTION
61
62 This module provides an API for a remote signup server.
63
64 It needs to be run as the freeside user.  Because of this, the program which
65 calls these subroutines should be written very carefully.
66
67 =head1 SUBROUTINES
68
69 =over 4
70
71 =item signup_info
72
73 Returns three array references of hash references.
74
75 The first set of hash references is of allowable locales.  Each hash reference
76 has the following keys:
77   taxnum
78   state
79   county
80   country
81
82 The second set of hash references is of allowable packages.  Each hash
83 reference has the following keys:
84   pkgpart
85   pkg
86
87 The third set of hash references is of allowable POPs (Points Of Presence).
88 Each hash reference has the following keys:
89   popnum
90   city
91   state
92   ac
93   exch
94
95 (Future expansion: fourth argument is the $init_data hash reference)
96
97 =cut
98
99 #compatibility bit
100 sub signup_info {
101
102   my $init_data = FS::SelfService::signup_info();
103
104   (map { $init_data->{$_} } qw( cust_main_county part_pkg svc_acct_pop ) ),
105   $init_data;
106
107 }
108
109 =item new_customer HASHREF
110
111 Adds a customer to the remote Freeside system.  Requires a hash reference as
112 a paramater with the following keys:
113   first
114   last
115   ss
116   comapny
117   address1
118   address2
119   city
120   county
121   state
122   zip
123   country
124   daytime
125   night
126   fax
127   payby
128   payinfo
129   paycvv
130   paydate
131   payname
132   invoicing_list
133   referral_custnum
134   comments
135   pkgpart
136   username
137   _password
138   sec_phrase
139   popnum
140
141 Returns a scalar error message, or the empty string for success.
142
143 =cut
144
145 #compatibility bit
146 sub new_customer { 
147   my $hash = FS::SelfService::new_customer(@_);
148   $hash->{'error'};
149 }
150
151 =back
152
153 =head1 BUGS
154
155 =head1 SEE ALSO
156
157 L<fs_signupd>, L<FS::cust_main>
158
159 =cut
160
161 1;
162