X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=inline;f=FS%2FFS%2FAPI.pm;h=7d0f10efb5322de514006dc3a950a7c730ffbb78;hb=1aa2f26487209054ed82f38130c73015635b5705;hp=c107621cdad2320e65e3f4a57181b0b4f2a8c72b;hpb=eb472623cd8d18ee2d142ae6d61acd465c268e6e;p=freeside.git diff --git a/FS/FS/API.pm b/FS/FS/API.pm index c107621cd..7d0f10efb 100644 --- a/FS/FS/API.pm +++ b/FS/FS/API.pm @@ -41,14 +41,64 @@ Enter cash refund. #--- -#generally, the more useful data from the cust_main record the better. - - # "2 way syncing" ? start with non-sync pulling info here, then if necessary # figure out how to trigger something when those things change # long-term: package changes? + +=item new_customer + +=cut + +#certainly false laziness w/ClientAPI::Signup new_customer/new_customer_minimal +# but approaching this from a clean start / back-office perspective +# i.e. no package/service, no immediate credit card run, etc. + +sub new_customer { + my( $class, %opt ) = @_; + my $conf = new FS::Conf; + return { 'error' => 'Incorrect shared secret' } + unless $opt{secret} eq $conf->config('api_shared_secret'); + + #default agentnum like signup_server-default_agentnum? + + #same for refnum like signup_server-default_refnum + + my $cust_main = new FS::cust_main ( { + 'agentnum' => $agentnum, + 'refnum' => $opt{refnum} + || $conf->config('signup_server-default_refnum'), + 'payby' => 'BILL', + + map { $_ => $opt{$_} } qw( + agentnum refnum agent_custid referral_custnum + last first company + address1 address2 city county state zip country + latitude longitude + geocode censustract censusyear + ship_address1 ship_address2 ship_city ship_county ship_state ship_zip ship_country + ship_latitude ship_longitude + daytime night fax mobile + payby payinfo paydate paycvv payname + ), + + } ); + + my @invoicing_list = $opt{'invoicing_list'} + ? split( /\s*\,\s*/, $opt{'invoicing_list'} ) + : (); + push @invoicing_list, 'POST' if $opt{'postal_invoicing'}; + + $error = $cust_main->insert( {}, \@invoicing_list ); + return { 'error' => $error } if $error; + + return { 'error' => '', + 'custnum' => $cust_main->custnum, + }; + +} + =item customer_info =cut @@ -96,6 +146,9 @@ sub customer_info { $return{'postal_invoicing'} = 0 < ( grep { $_ eq 'POST' } @invoicing_list ); + #generally, the more useful data from the cust_main record the better. + # well, tell me what you want + return \%return; } @@ -113,7 +166,7 @@ sub location_info { my %return = ( 'error' => '', - 'locations' => [ @cust_location ], + 'locations' => [ map $_->hashref, @cust_location ], ); return \%return;