summaryrefslogtreecommitdiff
path: root/FS/FS/API.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-03-05 16:07:14 -0800
committerIvan Kohler <ivan@freeside.biz>2014-03-05 16:07:14 -0800
commita8001fede477df80f80951eaf962bdb058d9f605 (patch)
treea1a1c5c3ebf4646cdad7d2249aaa1a9326b2c2f2 /FS/FS/API.pm
parent1ac43321cf1601e42bfc24433d0edd2268cb2a2e (diff)
add back-office xmlrpc api and daemon, RT#27958
Diffstat (limited to 'FS/FS/API.pm')
-rw-r--r--FS/FS/API.pm112
1 files changed, 112 insertions, 0 deletions
diff --git a/FS/FS/API.pm b/FS/FS/API.pm
new file mode 100644
index 0000000..df48802
--- /dev/null
+++ b/FS/FS/API.pm
@@ -0,0 +1,112 @@
+package FS::API;
+
+use FS::Conf;
+use FS::Record qw( qsearchs );
+use FS::cust_main;
+
+=head1 NAME
+
+FS::API - Freeside backend API
+
+=head1 SYNOPSIS
+
+ use FS::API;
+
+=head1 DESCRIPTION
+
+This module implements a backend API for advanced back-office integration.
+
+In contrast to the self-service API, which authenticates an end-user and offers
+functionality to that end user, the backend API performs a simple shared-secret
+authentication and offers full, administrator functionality, enabling
+integration with other back-office systems.
+
+If accessing this API remotely with XML-RPC or JSON-RPC, be careful to block
+the port by default, only allow access from back-office servers with the same
+security precations as the Freeside server, and encrypt the communication
+channel (for exampple, with an SSH tunnel or VPN) rather than accessing it
+in plaintext.
+
+=head1 METHODS
+
+=over 4
+
+# needs to be able to:
+Enter cash payment
+Enter credit
+Enter cash refund.
+
+# would like to be able to pass the phone number ( from svc_phone ) to the API for this query.
+
+#---
+
+#Customer data
+# pull customer info
+# The fields needed are:
+#
+# cust_main.custnum
+# cust_main.first
+# cust_main.last
+# cust_main.company
+# cust_main.address1
+# cust_main.address2
+# cust_main.city
+# cust_main.state
+# cust_main.zip
+# cust_main.daytime
+# cust_main.night
+# cust_main_invoice.dest
+#
+# at minimum
+
+#Customer balances
+
+#Advertising sources?
+
+# "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 customer_info
+
+=cut
+
+#some false laziness w/ClientAPI::Myaccount customer_info/customer_info_short
+
+use vars qw( @cust_main_editable_fields @location_editable_fields );
+@cust_main_editable_fields = qw(
+ first last company daytime night fax mobile
+);
+# locale
+# payby payinfo payname paystart_month paystart_year payissue payip
+# ss paytype paystate stateid stateid_state
+@location_editable_fields = qw(
+ address1 address2 city county state zip country
+);
+
+sub customer_info {
+ my( $class, %opt ) = @_;
+ my $conf = new FS::Conf;
+ return { 'error' => 'Incorrect shared secret' }
+ unless $opt{secret} eq $conf->config('api_shared_secret');
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $opt{custnum} })
+ or return { 'error' => 'Unknown custnum' };
+
+ my %return = (
+ 'error' => '',
+ 'display_custnum' => $cust_main->display_custnum,
+ 'name' => $cust_main->first. ' '. $cust_main->get('last'),
+ );
+
+ $return{$_} = $cust_main->get($_)
+ foreach @cust_main_editable_fields;
+
+ return \%return;
+
+}
+
+=back
+
+1;