X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FAPI.pm;h=fd3793d4f15d69cb361124d06caff610912aef4c;hb=e3c22ef5216a090529e99209409a9cc6ff11a1d3;hp=77ae03b10e746f005b64c08ce7da171e675b3d88;hpb=b7f8a7cfd566881a6d89117d17e391ceb58097d4;p=freeside.git diff --git a/FS/FS/API.pm b/FS/FS/API.pm index 77ae03b10..fd3793d4f 100644 --- a/FS/FS/API.pm +++ b/FS/FS/API.pm @@ -66,6 +66,10 @@ Amount paid Option date for payment +=item order_number + +Optional order number + =back Example: @@ -78,6 +82,7 @@ Example: #optional '_date' => 1397977200, #UNIX timestamp + 'order_number' => '12345', ); if ( $result->{'error'} ) { @@ -532,6 +537,41 @@ sub customer_info { $cust_main->API_getinfo; } +=item customer_list_svcs OPTION => VALUE, ... + +Returns customer service information. Takes a list of keys and values as +parameters with the following keys: custnum, secret + +=cut + +sub customer_list_svcs { + my( $class, %opt ) = @_; + return _shared_secret_error() unless _check_shared_secret($opt{secret}); + + my $cust_main = qsearchs('cust_main', { 'custnum' => $opt{custnum} }) + or return { 'error' => 'Unknown custnum' }; + + #$cust_main->API_list_svcs; + + #false laziness w/ClientAPI/list_svcs + + my @cust_svc = (); + #my @cust_pkg_usage = (); + #foreach my $cust_pkg ( $p->{'ncancelled'} + # ? $cust_main->ncancelled_pkgs + # : $cust_main->unsuspended_pkgs ) { + foreach my $cust_pkg ( $cust_main->all_pkgs ) { + #next if $pkgnum && $cust_pkg->pkgnum != $pkgnum; + push @cust_svc, @{[ $cust_pkg->cust_svc ]}; #@{[ ]} to force array context + #push @cust_pkg_usage, $cust_pkg->cust_pkg_usage; + } + + return { + 'cust_svc' => [ map $_->API_getinfo, @cust_svc ], + }; + +} + =item location_info Returns location specific information for the customer. Takes a list of keys @@ -568,6 +608,8 @@ secret locationnum - pass this, or the following keys (don't pass both) +locationname + address1 address2 @@ -580,8 +622,22 @@ state zip +addr_clean + country +censustract + +censusyear + +location_type + +location_number + +location_kind + +incorporated + On error, returns a hashref with an 'error' key. On success, returns a hashref with 'pkgnum' and 'locationnum' keys, containing the new values. @@ -589,7 +645,7 @@ containing the new values. =cut sub change_package_location { - my $self = shift; + my $class = shift; my %opt = @_; return _shared_secret_error() unless _check_shared_secret($opt{'secret'}); @@ -597,13 +653,27 @@ sub change_package_location { or return { 'error' => 'Unknown pkgnum' }; my %changeopt; - $changeopt{'pkgnum'} = $pkgnum; - my $cust_location = FS::cust_location->new({ - 'custnum' => $cust_pkg->custnum, - %location_hash, - }); - $changeopt{'cust_location'} = $cust_location; + foreach my $field ( qw( + locationnum + locationname + address1 + address2 + city + county + state + zip + addr_clean + country + censustract + censusyear + location_type + location_number + location_kind + incorporated + )) { + $changeopt{$field} = $opt{$field} if $opt{$field}; + } $cust_pkg->API_change(%changeopt); }