diff options
author | Christopher Burger <burgerc@freeside.biz> | 2017-11-15 14:04:22 -0500 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2017-11-29 11:00:22 -0500 |
commit | bfb12f9c65c192993a7fb82e00bfbe10da149da7 (patch) | |
tree | 74077eb8cb220d809eab16b9fb46d23e6f4be65d /FS/FS/API.pm | |
parent | 09898d8b692668f6d668624de1e112595a32ec6d (diff) |
RT# 29295 - added package_list and package_status to backend API. Also added two new test files in bin to test new apis
Diffstat (limited to 'FS/FS/API.pm')
-rw-r--r-- | FS/FS/API.pm | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/FS/FS/API.pm b/FS/FS/API.pm index 1758744..75948a3 100644 --- a/FS/FS/API.pm +++ b/FS/FS/API.pm @@ -650,6 +650,102 @@ sub location_info { return \%return; } +=item list_customer_packages OPTION => VALUE, ... + +Lists all customer packages. + +=over + +=item secret + +API Secret + +=item custnum + +Customer Number + +=back + +Example: + + my $result = FS::API->list_packages( + 'secret' => 'sharingiscaring', + 'custnum' => custnum, + ); + + if ( $result->{'error'} ) { + die $result->{'error'}; + } else { + # list packages returns an array of hashes for packages ordered by custnum and pkgnum. + print Dumper($result->{'pkgs'}); + } + +=cut + +sub list_customer_packages { + my( $class, %opt ) = @_; + return _shared_secret_error() unless _check_shared_secret($opt{secret}); + + my $sql_query = FS::cust_pkg->search({ 'custnum' => $opt{custnum}, }); + + $sql_query->{order_by} = 'ORDER BY custnum, pkgnum'; + + my @packages = qsearch($sql_query) + or return { 'error' => 'No packages' }; + + my $return = { + 'packages' => [ map $_->hashref, @packages ], + }; + + $return; +} + +=item package_status OPTION => VALUE, ... + +Get package status. + +=over + +=item secret + +API Secret + +=item pkgnum + +Package Number + +=back + +Example: + + my $result = FS::API->package_status( + 'secret' => 'sharingiscaring', + 'pkgnum' => pkgnum, + ); + + if ( $result->{'error'} ) { + die $result->{'error'}; + } else { + # package status returns a hash with the status for a package. + print Dumper($result->{'status'}); + } + +=cut + +sub package_status { + my( $class, %opt ) = @_; + return _shared_secret_error() unless _check_shared_secret($opt{secret}); + + my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $opt{pkgnum} } ) + or return { 'error' => 'No packages' }; + + my $return = { + 'status' => $cust_pkg->status, + }; + + $return; +} + =item order_package OPTION => VALUE, ... Orders a new customer package. Takes a list of keys and values as paramaters |