[freeside-commits] branch FREESIDE_4_BRANCH updated. bfb12f9c65c192993a7fb82e00bfbe10da149da7
Christopher Burger
burgerc at freeside.biz
Wed Nov 29 11:06:43 PST 2017
The branch, FREESIDE_4_BRANCH has been updated
via bfb12f9c65c192993a7fb82e00bfbe10da149da7 (commit)
from 09898d8b692668f6d668624de1e112595a32ec6d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bfb12f9c65c192993a7fb82e00bfbe10da149da7
Author: Christopher Burger <burgerc at freeside.biz>
Date: Wed Nov 15 14:04:22 2017 -0500
RT# 29295 - added package_list and package_status to backend API. Also added two new test files in bin to test new apis
diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index 17587443b..75948a3e3 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
diff --git a/bin/xmlrpc-customer_package-status.pl b/bin/xmlrpc-customer_package-status.pl
new file mode 100644
index 000000000..589c42af4
--- /dev/null
+++ b/bin/xmlrpc-customer_package-status.pl
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+## example
+# perl xmlrpc-customer_package-status.pl <pkgnum>
+##
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+my $uri = new URI 'http://localhost:8008/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $result = $server->call(
+ 'FS.API.package_status',
+ 'secret' => 'MySecretCode',
+ 'pkgnum' => $ARGV[0],
+);
+
+die $result->{'error'} if $result->{'error'};
+
+print $result->{status};
+
+print "\nAll Done\n";
+
+exit;
\ No newline at end of file
diff --git a/bin/xmlrpc-customer_packages-list.pl b/bin/xmlrpc-customer_packages-list.pl
new file mode 100644
index 000000000..745d30fbd
--- /dev/null
+++ b/bin/xmlrpc-customer_packages-list.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+## example
+# perl xmlrpc-customer_packages-list.pl <custnum>
+##
+
+use strict;
+use Frontier::Client;
+use Data::Dumper;
+
+my $uri = new URI 'http://localhost:8008/';
+
+my $server = new Frontier::Client ( 'url' => $uri );
+
+my $result = $server->call(
+ 'FS.API.list_customer_packages',
+ 'secret' => 'MySecretCode',
+ 'custnum' => $ARGV[0],
+);
+
+die $result->{'error'} if $result->{'error'};
+
+my @packages = @{$result->{packages}};
+
+print Dumper(@packages);
+
+print "\n total: " . scalar @packages;
+
+print "\nAll Done\n";
+
+exit;
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
FS/FS/API.pm | 96 ++++++++++++++++++++++
...s-list.pl => xmlrpc-customer_package-status.pl} | 9 +-
...es-list.pl => xmlrpc-customer_packages-list.pl} | 13 ++-
3 files changed, 114 insertions(+), 4 deletions(-)
copy bin/{xmlrpc-advertising_sources-list.pl => xmlrpc-customer_package-status.pl} (67%)
mode change 100755 => 100644
copy bin/{xmlrpc-advertising_sources-list.pl => xmlrpc-customer_packages-list.pl} (56%)
mode change 100755 => 100644
More information about the freeside-commits
mailing list