1 package FS::ClientAPI_XMLRPC;
5 FS::ClientAPI_XMLRPC - Freeside XMLRPC accessible self-service API, on the backend
9 This module implements the self-service API offered by xmlrpc.cgi and friends,
10 but on a backend machine.
14 Use this API to implement your own client "self-service" module vi XMLRPC.
16 Each routine described in L<FS::SelfService> is available vi XMLRPC as the
17 method FS.SelfService.XMLRPC.B<method>. All values are passed to the
18 selfservice-server in a struct of strings. The return values are in a
19 struct as strings, arrays, or structs as appropriate for the values
20 described in L<FS::SelfService>.
26 L<FS::SelfService::XMLRPC>, L<FS::SelfService>
32 use vars qw($DEBUG $AUTOLOAD);
33 use XMLRPC::Lite; # for XMLRPC::Data
37 $FS::ClientAPI::DEBUG = $DEBUG;
39 #false laziness w/FS::SelfService/XMLRPC.pm, same problem as below but worse
40 our %typefix_skin_info = (
42 'title_left_image' => 'base64',
43 'title_right_image' => 'base64',
44 'menu_top_image' => 'base64',
45 'menu_body_image' => 'base64',
46 'menu_bottom_image' => 'base64',
49 'invoice_pdf' => { 'invoice_pdf' => 'base64', },
50 'legacy_invoice_pdf' => { 'invoice_pdf' => 'base64', },
51 'skin_info' => \%typefix_skin_info,
52 'login_info' => \%typefix_skin_info,
53 'invoice_logo' => { 'logo' => 'base64', },
54 'login_banner_image' => { 'image' => 'base64', },
55 'quotation_print' => { 'document' => 'base64' },
60 $call =~ s/^FS::(SelfService::|ClientAPI_)XMLRPC:://;
62 warn "FS::ClientAPI_XMLRPC::AUTOLOAD $call\n" if $DEBUG;
64 my $autoload = &ss2clientapi;
66 if (exists($autoload->{$call})) {
68 shift; #discard package name;
70 #$call = "FS::SelfService::$call";
73 #FS::ClientAPI->dispatch($autoload->{$call}, @_);
75 my $return = FS::ClientAPI->dispatch($autoload->{$call}, { @_ } );
77 if ( exists($typefix{$call}) ) {
78 my $typefix = $typefix{$call};
79 foreach my $field ( grep exists($return->{$_}), keys %$typefix ) {
80 my $type = $typefix->{$field};
81 $return->{$field} = XMLRPC::Data->value($return->{$field})
89 die "No such procedure: $call";
93 #terrible false laziness w/SelfService.pm
94 # - fix at build time, by including some file in both selfserv and backend libs?
95 # - or fix at runtime, by having selfservice client ask server for the list?
98 'passwd' => 'passwd/passwd',
99 'chfn' => 'passwd/passwd',
100 'chsh' => 'passwd/passwd',
101 'login_info' => 'MyAccount/login_info',
102 'login_banner_image' => 'MyAccount/login_banner_image',
103 'login' => 'MyAccount/login',
104 'logout' => 'MyAccount/logout',
105 'switch_acct' => 'MyAccount/switch_acct',
106 'customer_info' => 'MyAccount/customer_info',
107 'customer_info_short' => 'MyAccount/customer_info_short',
108 'billing_history' => 'MyAccount/billing_history',
109 'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
110 'invoice' => 'MyAccount/invoice',
111 'invoice_pdf' => 'MyAccount/invoice_pdf',
112 'legacy_invoice' => 'MyAccount/legacy_invoice',
113 'legacy_invoice_pdf' => 'MyAccount/legacy_invoice_pdf',
114 'invoice_logo' => 'MyAccount/invoice_logo',
115 'list_invoices' => 'MyAccount/list_invoices', #?
116 'cancel' => 'MyAccount/cancel', #add to ss cgi!
117 'payment_info' => 'MyAccount/payment_info',
118 'payment_info_renew_info' => 'MyAccount/payment_info_renew_info',
119 'process_payment' => 'MyAccount/process_payment',
120 'store_payment' => 'MyAccount/store_payment',
121 'process_stored_payment' => 'MyAccount/process_stored_payment',
122 'process_payment_order_pkg' => 'MyAccount/process_payment_order_pkg',
123 'process_payment_change_pkg' => 'MyAccount/process_payment_change_pkg',
124 'process_payment_order_renew' => 'MyAccount/process_payment_order_renew',
125 'process_prepay' => 'MyAccount/process_prepay',
126 'start_thirdparty' => 'MyAccount/start_thirdparty',
127 'finish_thirdparty' => 'MyAccount/finish_thirdparty',
128 'realtime_collect' => 'MyAccount/realtime_collect',
129 'list_pkgs' => 'MyAccount/list_pkgs', #add to ss (added?)
130 'list_svcs' => 'MyAccount/list_svcs', #add to ss (added?)
131 'list_svc_usage' => 'MyAccount/list_svc_usage',
132 'svc_status_html' => 'MyAccount/svc_status_html',
133 'svc_status_hash' => 'MyAccount/svc_status_hash',
134 'set_svc_status_hash' => 'MyAccount/set_svc_status_hash',
135 'set_svc_status_listadd' => 'MyAccount/set_svc_status_listadd',
136 'set_svc_status_listdel' => 'MyAccount/set_svc_status_listdel',
137 'set_svc_status_vacationadd'=> 'MyAccount/set_svc_status_vacationadd',
138 'set_svc_status_vacationdel'=> 'MyAccount/set_svc_status_vacationdel',
139 'acct_forward_info' => 'MyAccount/acct_forward_info',
140 'process_acct_forward' => 'MyAccount/process_acct_forward',
141 'list_dsl_devices' => 'MyAccount/list_dsl_devices',
142 'add_dsl_device' => 'MyAccount/add_dsl_device',
143 'delete_dsl_device' => 'MyAccount/delete_dsl_device',
144 'port_graph' => 'MyAccount/port_graph',
145 'list_cdr_usage' => 'MyAccount/list_cdr_usage',
146 'list_support_usage' => 'MyAccount/list_support_usage',
147 'order_pkg' => 'MyAccount/order_pkg', #add to ss cgi!
148 'change_pkg' => 'MyAccount/change_pkg',
149 'order_recharge' => 'MyAccount/order_recharge',
150 'renew_info' => 'MyAccount/renew_info',
151 'order_renew' => 'MyAccount/order_renew',
152 'cancel_pkg' => 'MyAccount/cancel_pkg', #add to ss cgi!
153 'suspend_pkg' => 'MyAccount/suspend_pkg', #add to ss cgi!
154 'charge' => 'MyAccount/charge', #?
155 'part_svc_info' => 'MyAccount/part_svc_info',
156 'provision_acct' => 'MyAccount/provision_acct',
157 'provision_phone' => 'MyAccount/provision_phone',
158 'provision_pbx' => 'MyAccount/provision_pbx',
159 'provision_external' => 'MyAccount/provision_external',
160 'unprovision_svc' => 'MyAccount/unprovision_svc',
161 'myaccount_passwd' => 'MyAccount/myaccount_passwd',
162 'reset_passwd' => 'MyAccount/reset_passwd',
163 'check_reset_passwd' => 'MyAccount/check_reset_passwd',
164 'process_reset_passwd' => 'MyAccount/process_reset_passwd',
165 'list_tickets' => 'MyAccount/list_tickets',
166 'create_ticket' => 'MyAccount/create_ticket',
167 'get_ticket' => 'MyAccount/get_ticket',
168 'adjust_ticket_priority' => 'MyAccount/adjust_ticket_priority',
169 'did_report' => 'MyAccount/did_report',
170 'signup_info' => 'Signup/signup_info',
171 'skin_info' => 'MyAccount/skin_info',
172 'access_info' => 'MyAccount/access_info',
173 'domain_select_hash' => 'Signup/domain_select_hash', # expose?
174 'new_customer' => 'Signup/new_customer',
175 'new_customer_minimal' => 'Signup/new_customer_minimal',
176 'capture_payment' => 'Signup/capture_payment',
177 'clear_signup_cache' => 'Signup/clear_cache',
178 'new_agent' => 'Agent/new_agent',
179 'agent_login' => 'Agent/agent_login',
180 'agent_logout' => 'Agent/agent_logout',
181 'agent_info' => 'Agent/agent_info',
182 'agent_list_customers' => 'Agent/agent_list_customers',
183 'check_username' => 'Agent/check_username',
184 'suspend_username' => 'Agent/suspend_username',
185 'unsuspend_username' => 'Agent/unsuspend_username',
186 'mason_comp' => 'MasonComponent/mason_comp',
187 'call_time' => 'PrepaidPhone/call_time',
188 'call_time_nanpa' => 'PrepaidPhone/call_time_nanpa',
189 'phonenum_balance' => 'PrepaidPhone/phonenum_balance',
191 'list_quotations' => 'MyAccount/quotation/list_quotations',
192 'quotation_new' => 'MyAccount/quotation/quotation_new',
193 'quotation_delete' => 'MyAccount/quotation/quotation_delete',
194 'quotation_info' => 'MyAccount/quotation/quotation_info',
195 'quotation_print' => 'MyAccount/quotation/quotation_print',
196 'quotation_add_pkg' => 'MyAccount/quotation/quotation_add_pkg',
197 'quotation_remove_pkg' => 'MyAccount/quotation/quotation_remove_pkg',
198 'quotation_order' => 'MyAccount/quotation/quotation_order',
203 #XXX submit patch to SOAP::Lite
205 use XMLRPC::Transport::HTTP;
207 package XMLRPC::Transport::HTTP::Server;
209 @XMLRPC::Transport::HTTP::Server::ISA = qw(SOAP::Transport::HTTP::Server);
211 sub initialize; *initialize = \&XMLRPC::Server::initialize;
212 sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault;
213 sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response;