4 use FS::Record qw( qsearchs );
9 FS::API - Freeside backend API
17 This module implements a backend API for advanced back-office integration.
19 In contrast to the self-service API, which authenticates an end-user and offers
20 functionality to that end user, the backend API performs a simple shared-secret
21 authentication and offers full, administrator functionality, enabling
22 integration with other back-office systems.
24 If accessing this API remotely with XML-RPC or JSON-RPC, be careful to block
25 the port by default, only allow access from back-office servers with the same
26 security precations as the Freeside server, and encrypt the communication
27 channel (for exampple, with an SSH tunnel or VPN) rather than accessing it
34 # needs to be able to:
39 # would like to be able to pass the phone number ( from svc_phone ) to the API for this query.
45 # The fields needed are:
58 # cust_main_invoice.dest
66 # "2 way syncing" ? start with non-sync pulling info here, then if necessary
67 # figure out how to trigger something when those things change
69 # long-term: package changes?
75 #some false laziness w/ClientAPI::Myaccount customer_info/customer_info_short
77 use vars qw( @cust_main_editable_fields @location_editable_fields );
78 @cust_main_editable_fields = qw(
79 first last company daytime night fax mobile
82 # payby payinfo payname paystart_month paystart_year payissue payip
83 # ss paytype paystate stateid stateid_state
84 @location_editable_fields = qw(
85 address1 address2 city county state zip country
89 my( $class, %opt ) = @_;
90 my $conf = new FS::Conf;
91 return { 'error' => 'Incorrect shared secret' }
92 unless $opt{secret} eq $conf->config('api_shared_secret');
94 my $cust_main = qsearchs('cust_main', { 'custnum' => $opt{custnum} })
95 or return { 'error' => 'Unknown custnum' };
99 'display_custnum' => $cust_main->display_custnum,
100 'name' => $cust_main->first. ' '. $cust_main->get('last'),
103 $return{$_} = $cust_main->get($_)
104 foreach @cust_main_editable_fields;