summaryrefslogtreecommitdiff
path: root/FS/FS/API.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-04-18 21:47:51 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-04-22 12:10:09 -0500
commit5c321cb0e6488b0b76fec03395ec815703867b22 (patch)
tree56f2476f724f7d8b38f4d34d7107ac1260cce8b9 /FS/FS/API.pm
parentfd0483007b898b9944cc31fd5d6e90932fe2c8c0 (diff)
RT#29296: API stuff: Add new locations [change_package_location API call]
Diffstat (limited to 'FS/FS/API.pm')
-rw-r--r--FS/FS/API.pm52
1 files changed, 52 insertions, 0 deletions
diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index 32400f7..77ae03b 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -8,6 +8,7 @@ use FS::cust_location;
use FS::cust_pay;
use FS::cust_credit;
use FS::cust_refund;
+use FS::cust_pkg;
=head1 NAME
@@ -556,6 +557,57 @@ sub location_info {
return \%return;
}
+=item change_package_location
+
+Updates package location. Takes a list of keys and values
+as paramters with the following keys:
+
+pkgnum
+
+secret
+
+locationnum - pass this, or the following keys (don't pass both)
+
+address1
+
+address2
+
+city
+
+county
+
+state
+
+zip
+
+country
+
+On error, returns a hashref with an 'error' key.
+On success, returns a hashref with 'pkgnum' and 'locationnum' keys,
+containing the new values.
+
+=cut
+
+sub change_package_location {
+ my $self = shift;
+ my %opt = @_;
+ return _shared_secret_error() unless _check_shared_secret($opt{'secret'});
+
+ my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $opt{'pkgnum'} })
+ 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;
+
+ $cust_pkg->API_change(%changeopt);
+}
+
=item bill_now OPTION => VALUE, ...
Bills a single customer now, in the same fashion as the "Bill now" link in the