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);
34 use FS::XMLRPC_Lite; #XMLRPC::Lite, for XMLRPC::Data
38 $FS::ClientAPI::DEBUG = $DEBUG;
40 #false laziness w/FS::SelfService/XMLRPC.pm, same problem as below but worse
41 our %typefix_skin_info = (
43 'title_left_image' => 'base64',
44 'title_right_image' => 'base64',
45 'menu_top_image' => 'base64',
46 'menu_body_image' => 'base64',
47 'menu_bottom_image' => 'base64',
50 'invoice_pdf' => { 'invoice_pdf' => 'base64', },
51 'legacy_invoice_pdf' => { 'invoice_pdf' => 'base64', },
52 'skin_info' => \%typefix_skin_info,
53 'login_info' => \%typefix_skin_info,
54 'logout' => \%typefix_skin_info,
55 'access_info' => \%typefix_skin_info,
56 'reset_passwd' => \%typefix_skin_info,
57 'check_reset_passwd' => \%typefix_skin_info,
58 'process_reset_passwd' => \%typefix_skin_info,
59 'invoice_logo' => { 'logo' => 'base64', },
60 'login_banner_image' => { 'image' => 'base64', },
61 'quotation_print' => { 'document' => 'base64' },
66 $call =~ s/^FS::(SelfService::|ClientAPI_)XMLRPC:://;
68 warn "FS::ClientAPI_XMLRPC::AUTOLOAD $call\n" if $DEBUG;
70 my $autoload = &ss2clientapi;
72 if (exists($autoload->{$call})) {
74 shift; #discard package name;
77 #$call = "FS::SelfService::$call";
80 #FS::ClientAPI->dispatch($autoload->{$call}, @_);
83 #XXX doesn't deep-fix multi-level data structs, but at least doesn't mangle
85 $hash{$_} = decode(utf8=>$hash{$_})
86 foreach grep !ref($hash{$_}), keys %hash;
88 my $return = FS::ClientAPI->dispatch($autoload->{$call}, \%hash );
90 if ( exists($typefix{$call}) ) {
91 my $typefix = $typefix{$call};
92 foreach my $field ( grep exists($return->{$_}), keys %$typefix ) {
93 my $type = $typefix->{$field};
94 $return->{$field} = XMLRPC::Data->value($return->{$field})
102 die "No such procedure: $call";
106 #terrible false laziness w/SelfService.pm
107 # - fix at build time, by including some file in both selfserv and backend libs?
108 # - or fix at runtime, by having selfservice client ask server for the list?
111 'passwd' => 'passwd/passwd',
112 'chfn' => 'passwd/passwd',
113 'chsh' => 'passwd/passwd',
114 'login_info' => 'MyAccount/login_info',
115 'login_banner_image' => 'MyAccount/login_banner_image',
116 'login' => 'MyAccount/login',
117 'logout' => 'MyAccount/logout',
118 'switch_acct' => 'MyAccount/switch_acct',
119 'switch_cust' => 'MyAccount/switch_cust',
120 'customer_info' => 'MyAccount/customer_info',
121 'customer_info_short' => 'MyAccount/customer_info_short',
122 'customer_recurring' => 'MyAccount/customer_recurring',
124 'contact_passwd' => 'MyAccount/contact/contact_passwd',
125 'list_contacts' => 'MyAccount/contact/list_contacts',
126 'edit_contact' => 'MyAccount/contact/edit_contact',
127 'delete_contact' => 'MyAccount/contact/delete_contact',
128 'new_contact' => 'MyAccount/contact/new_contact',
130 'billing_history' => 'MyAccount/billing_history',
131 'edit_info' => 'MyAccount/edit_info', #add to ss cgi!
132 'invoice' => 'MyAccount/invoice',
133 'invoice_pdf' => 'MyAccount/invoice_pdf',
134 'legacy_invoice' => 'MyAccount/legacy_invoice',
135 'legacy_invoice_pdf' => 'MyAccount/legacy_invoice_pdf',
136 'invoice_logo' => 'MyAccount/invoice_logo',
137 'list_invoices' => 'MyAccount/list_invoices', #?
138 'list_payments' => 'MyAccount/list_payments',
139 'payment_receipt' => 'MyAccount/payment_receipt',
140 'list_payby' => 'MyAccount/list_payby',
141 'insert_payby' => 'MyAccount/insert_payby',
142 'update_payby' => 'MyAccount/update_payby',
143 'delete_payby' => 'MyAccount/delete_payby',
144 'cancel' => 'MyAccount/cancel', #add to ss cgi!
145 'payment_info' => 'MyAccount/payment_info',
146 'payment_info_renew_info' => 'MyAccount/payment_info_renew_info',
147 'process_payment' => 'MyAccount/process_payment',
148 'store_payment' => 'MyAccount/store_payment',
149 'process_stored_payment' => 'MyAccount/process_stored_payment',
150 'process_payment_order_pkg' => 'MyAccount/process_payment_order_pkg',
151 'process_payment_change_pkg' => 'MyAccount/process_payment_change_pkg',
152 'process_payment_order_renew' => 'MyAccount/process_payment_order_renew',
153 'process_prepay' => 'MyAccount/process_prepay',
154 'start_thirdparty' => 'MyAccount/start_thirdparty',
155 'finish_thirdparty' => 'MyAccount/finish_thirdparty',
156 'realtime_collect' => 'MyAccount/realtime_collect',
157 'list_pkgs' => 'MyAccount/list_pkgs', #add to ss (added?)
158 'pkg_info' => 'MyAccount/pkg_info',
159 'list_svcs' => 'MyAccount/list_svcs', #add to ss (added?)
160 'list_svc_usage' => 'MyAccount/list_svc_usage',
161 'svc_status_html' => 'MyAccount/svc_status_html',
162 'svc_status_hash' => 'MyAccount/svc_status_hash',
163 'set_svc_status_hash' => 'MyAccount/set_svc_status_hash',
164 'set_svc_status_listadd' => 'MyAccount/set_svc_status_listadd',
165 'set_svc_status_listdel' => 'MyAccount/set_svc_status_listdel',
166 'set_svc_status_vacationadd'=> 'MyAccount/set_svc_status_vacationadd',
167 'set_svc_status_vacationdel'=> 'MyAccount/set_svc_status_vacationdel',
168 'acct_forward_info' => 'MyAccount/acct_forward_info',
169 'process_acct_forward' => 'MyAccount/process_acct_forward',
170 'list_dsl_devices' => 'MyAccount/list_dsl_devices',
171 'add_dsl_device' => 'MyAccount/add_dsl_device',
172 'delete_dsl_device' => 'MyAccount/delete_dsl_device',
173 'port_graph' => 'MyAccount/port_graph',
174 'list_cdr_usage' => 'MyAccount/list_cdr_usage',
175 'list_support_usage' => 'MyAccount/list_support_usage',
176 'order_pkg' => 'MyAccount/order_pkg', #add to ss cgi!
177 'change_pkg' => 'MyAccount/change_pkg',
178 'order_recharge' => 'MyAccount/order_recharge',
179 'renew_info' => 'MyAccount/renew_info',
180 'order_renew' => 'MyAccount/order_renew',
181 'cancel_pkg' => 'MyAccount/cancel_pkg', #add to ss cgi!
182 'suspend_pkg' => 'MyAccount/suspend_pkg', #add to ss cgi!
183 'charge' => 'MyAccount/charge', #?
184 'part_svc_info' => 'MyAccount/part_svc_info',
185 'provision_acct' => 'MyAccount/provision_acct',
186 'provision_phone' => 'MyAccount/provision_phone',
187 'provision_pbx' => 'MyAccount/provision_pbx',
188 'provision_external' => 'MyAccount/provision_external',
189 'unprovision_svc' => 'MyAccount/unprovision_svc',
190 'myaccount_passwd' => 'MyAccount/myaccount_passwd',
191 'reset_passwd' => 'MyAccount/reset_passwd',
192 'check_reset_passwd' => 'MyAccount/check_reset_passwd',
193 'process_reset_passwd' => 'MyAccount/process_reset_passwd',
194 'validate_passwd' => 'MyAccount/validate_passwd',
195 'list_tickets' => 'MyAccount/list_tickets',
196 'create_ticket' => 'MyAccount/create_ticket',
197 'get_ticket' => 'MyAccount/get_ticket',
198 'adjust_ticket_priority' => 'MyAccount/adjust_ticket_priority',
199 'did_report' => 'MyAccount/did_report',
200 'signup_info' => 'Signup/signup_info',
201 'skin_info' => 'MyAccount/skin_info',
202 'access_info' => 'MyAccount/access_info',
203 'domain_select_hash' => 'Signup/domain_select_hash', # expose?
204 'new_customer' => 'Signup/new_customer',
205 'new_customer_minimal' => 'Signup/new_customer_minimal',
206 'capture_payment' => 'Signup/capture_payment',
207 'clear_signup_cache' => 'Signup/clear_cache',
208 'new_prospect' => 'Signup/new_prospect',
209 'new_agent' => 'Agent/new_agent',
210 'agent_login' => 'Agent/agent_login',
211 'agent_logout' => 'Agent/agent_logout',
212 'agent_info' => 'Agent/agent_info',
213 'agent_list_customers' => 'Agent/agent_list_customers',
214 'check_username' => 'Agent/check_username',
215 'suspend_username' => 'Agent/suspend_username',
216 'unsuspend_username' => 'Agent/unsuspend_username',
217 'mason_comp' => 'MasonComponent/mason_comp',
218 'call_time' => 'PrepaidPhone/call_time',
219 'call_time_nanpa' => 'PrepaidPhone/call_time_nanpa',
220 'phonenum_balance' => 'PrepaidPhone/phonenum_balance',
222 'list_quotations' => 'MyAccount/quotation/list_quotations',
223 'quotation_new' => 'MyAccount/quotation/quotation_new',
224 'quotation_delete' => 'MyAccount/quotation/quotation_delete',
225 'quotation_info' => 'MyAccount/quotation/quotation_info',
226 'quotation_print' => 'MyAccount/quotation/quotation_print',
227 'quotation_add_pkg' => 'MyAccount/quotation/quotation_add_pkg',
228 'quotation_remove_pkg' => 'MyAccount/quotation/quotation_remove_pkg',
229 'quotation_order' => 'MyAccount/quotation/quotation_order',
230 'get_mac_address' => 'MyAccount/get_mac_address',
232 'freesideinc_service' => 'Freeside/freesideinc_service',