contact self-service pw changes, RT#37023
[freeside.git] / FS / FS / ClientAPI_XMLRPC.pm
1 package FS::ClientAPI_XMLRPC;
2
3 =head1 NAME
4
5 FS::ClientAPI_XMLRPC - Freeside XMLRPC accessible self-service API, on the backend
6
7 =head1 SYNOPSIS
8
9 This module implements the self-service API offered by xmlrpc.cgi and friends,
10 but on a backend machine.
11
12 =head1 DESCRIPTION
13
14 Use this API to implement your own client "self-service" module vi XMLRPC.
15
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>.
21
22 =head1 BUGS
23
24 =head1 SEE ALSO
25
26 L<FS::SelfService::XMLRPC>, L<FS::SelfService>
27
28 =cut
29
30 use strict;
31
32 use vars qw($DEBUG $AUTOLOAD);
33 use FS::XMLRPC_Lite; #XMLRPC::Lite, for XMLRPC::Data
34 use FS::ClientAPI;
35
36 $DEBUG = 0;
37 $FS::ClientAPI::DEBUG = $DEBUG;
38
39 #false laziness w/FS::SelfService/XMLRPC.pm, same problem as below but worse
40 our %typefix_skin_info = (
41   'logo'              => 'base64',
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',
47 );
48 our %typefix = (
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' },
56 );
57
58 sub AUTOLOAD {
59   my $call = $AUTOLOAD;
60   $call =~ s/^FS::(SelfService::|ClientAPI_)XMLRPC:://;
61
62   warn "FS::ClientAPI_XMLRPC::AUTOLOAD $call\n" if $DEBUG;
63
64   my $autoload = &ss2clientapi;
65
66   if (exists($autoload->{$call})) {
67
68     shift; #discard package name;
69
70     #$call = "FS::SelfService::$call";
71     #no strict 'refs';
72     #&{$call}(@_);
73     #FS::ClientAPI->dispatch($autoload->{$call}, @_);
74
75     my $return = FS::ClientAPI->dispatch($autoload->{$call}, { @_ } );
76
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})
82                                         ->type($type);
83       }
84     }
85
86     $return;
87
88   }else{
89     die "No such procedure: $call";
90   }
91 }
92
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?
96 sub ss2clientapi {
97   {
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   'switch_cust'               => 'MyAccount/switch_cust',
107   'customer_info'             => 'MyAccount/customer_info',
108   'customer_info_short'       => 'MyAccount/customer_info_short',
109
110   'contact_passwd'            => 'MyAccount/contact/contact_passwd',
111   'list_contacts'             => 'MyAccount/contact/list_contacts',
112   'edit_contact'              => 'MyAccount/contact/edit_contact',
113   'delete_contact'            => 'MyAccount/contact/delete_contact',
114
115   'billing_history'           => 'MyAccount/billing_history',
116   'edit_info'                 => 'MyAccount/edit_info',     #add to ss cgi!
117   'invoice'                   => 'MyAccount/invoice',
118   'invoice_pdf'               => 'MyAccount/invoice_pdf',
119   'legacy_invoice'            => 'MyAccount/legacy_invoice',
120   'legacy_invoice_pdf'        => 'MyAccount/legacy_invoice_pdf',
121   'invoice_logo'              => 'MyAccount/invoice_logo',
122   'list_invoices'             => 'MyAccount/list_invoices', #?
123   'cancel'                    => 'MyAccount/cancel',        #add to ss cgi!
124   'payment_info'              => 'MyAccount/payment_info',
125   'payment_info_renew_info'   => 'MyAccount/payment_info_renew_info',
126   'process_payment'           => 'MyAccount/process_payment',
127   'store_payment'             => 'MyAccount/store_payment',
128   'process_stored_payment'    => 'MyAccount/process_stored_payment',
129   'process_payment_order_pkg' => 'MyAccount/process_payment_order_pkg',
130   'process_payment_change_pkg' => 'MyAccount/process_payment_change_pkg',
131   'process_payment_order_renew' => 'MyAccount/process_payment_order_renew',
132   'process_prepay'            => 'MyAccount/process_prepay',
133   'start_thirdparty'          => 'MyAccount/start_thirdparty',
134   'finish_thirdparty'         => 'MyAccount/finish_thirdparty',
135   'realtime_collect'          => 'MyAccount/realtime_collect',
136   'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
137   'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
138   'list_svc_usage'            => 'MyAccount/list_svc_usage',   
139   'svc_status_html'           => 'MyAccount/svc_status_html',
140   'svc_status_hash'           => 'MyAccount/svc_status_hash',
141   'set_svc_status_hash'       => 'MyAccount/set_svc_status_hash',
142   'set_svc_status_listadd'    => 'MyAccount/set_svc_status_listadd',
143   'set_svc_status_listdel'    => 'MyAccount/set_svc_status_listdel',
144   'set_svc_status_vacationadd'=> 'MyAccount/set_svc_status_vacationadd',
145   'set_svc_status_vacationdel'=> 'MyAccount/set_svc_status_vacationdel',
146   'acct_forward_info'         => 'MyAccount/acct_forward_info',
147   'process_acct_forward'      => 'MyAccount/process_acct_forward',
148   'list_dsl_devices'          => 'MyAccount/list_dsl_devices',   
149   'add_dsl_device'            => 'MyAccount/add_dsl_device',   
150   'delete_dsl_device'         => 'MyAccount/delete_dsl_device',   
151   'port_graph'                => 'MyAccount/port_graph',   
152   'list_cdr_usage'            => 'MyAccount/list_cdr_usage',   
153   'list_support_usage'        => 'MyAccount/list_support_usage',   
154   'order_pkg'                 => 'MyAccount/order_pkg',     #add to ss cgi!
155   'change_pkg'                => 'MyAccount/change_pkg', 
156   'order_recharge'            => 'MyAccount/order_recharge',
157   'renew_info'                => 'MyAccount/renew_info',
158   'order_renew'               => 'MyAccount/order_renew',
159   'cancel_pkg'                => 'MyAccount/cancel_pkg',    #add to ss cgi!
160   'suspend_pkg'               => 'MyAccount/suspend_pkg',   #add to ss cgi!
161   'charge'                    => 'MyAccount/charge',        #?
162   'part_svc_info'             => 'MyAccount/part_svc_info',
163   'provision_acct'            => 'MyAccount/provision_acct',
164   'provision_phone'           => 'MyAccount/provision_phone',
165   'provision_pbx'             => 'MyAccount/provision_pbx',
166   'provision_external'        => 'MyAccount/provision_external',
167   'unprovision_svc'           => 'MyAccount/unprovision_svc',
168   'myaccount_passwd'          => 'MyAccount/myaccount_passwd',
169   'reset_passwd'              => 'MyAccount/reset_passwd',
170   'check_reset_passwd'        => 'MyAccount/check_reset_passwd',
171   'process_reset_passwd'      => 'MyAccount/process_reset_passwd',
172   'list_tickets'              => 'MyAccount/list_tickets',
173   'create_ticket'             => 'MyAccount/create_ticket',
174   'get_ticket'                => 'MyAccount/get_ticket',
175   'adjust_ticket_priority'    => 'MyAccount/adjust_ticket_priority',
176   'did_report'                => 'MyAccount/did_report',
177   'signup_info'               => 'Signup/signup_info',
178   'skin_info'                 => 'MyAccount/skin_info',
179   'access_info'               => 'MyAccount/access_info',
180   'domain_select_hash'        => 'Signup/domain_select_hash',  # expose?
181   'new_customer'              => 'Signup/new_customer',
182   'new_customer_minimal'      => 'Signup/new_customer_minimal',
183   'capture_payment'           => 'Signup/capture_payment',
184   'clear_signup_cache'        => 'Signup/clear_cache',
185   'new_agent'                 => 'Agent/new_agent',
186   'agent_login'               => 'Agent/agent_login',
187   'agent_logout'              => 'Agent/agent_logout',
188   'agent_info'                => 'Agent/agent_info',
189   'agent_list_customers'      => 'Agent/agent_list_customers',
190   'check_username'            => 'Agent/check_username',
191   'suspend_username'          => 'Agent/suspend_username',
192   'unsuspend_username'        => 'Agent/unsuspend_username',
193   'mason_comp'                => 'MasonComponent/mason_comp',
194   'call_time'                 => 'PrepaidPhone/call_time',
195   'call_time_nanpa'           => 'PrepaidPhone/call_time_nanpa',
196   'phonenum_balance'          => 'PrepaidPhone/phonenum_balance',
197
198   'list_quotations'           => 'MyAccount/quotation/list_quotations',
199   'quotation_new'             => 'MyAccount/quotation/quotation_new',
200   'quotation_delete'          => 'MyAccount/quotation/quotation_delete',
201   'quotation_info'            => 'MyAccount/quotation/quotation_info',
202   'quotation_print'           => 'MyAccount/quotation/quotation_print',
203   'quotation_add_pkg'         => 'MyAccount/quotation/quotation_add_pkg',
204   'quotation_remove_pkg'      => 'MyAccount/quotation/quotation_remove_pkg',
205   'quotation_order'           => 'MyAccount/quotation/quotation_order',
206   };
207 }
208
209 1;