add invoice_pdf to selfservice, RT#13656
[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::ClientAPI;
34
35 $DEBUG = 0;
36 $FS::ClientAPI::DEBUG = $DEBUG;
37
38 sub AUTOLOAD {
39   my $call = $AUTOLOAD;
40   $call =~ s/^FS::(SelfService::|ClientAPI_)XMLRPC:://;
41
42   warn "FS::ClientAPI_XMLRPC::AUTOLOAD $call\n" if $DEBUG;
43
44   my $autoload = &ss2clientapi;
45
46   if (exists($autoload->{$call})) {
47     shift; #discard package name;
48     #$call = "FS::SelfService::$call";
49     #no strict 'refs';
50     #&{$call}(@_);
51     #FS::ClientAPI->dispatch($autoload->{$call}, @_);
52     FS::ClientAPI->dispatch($autoload->{$call}, { @_ } );
53   }else{
54     die "No such procedure: $call";
55   }
56 }
57
58 #terrible false laziness w/SelfService.pm
59 # - fix at build time, by including some file in both selfserv and backend libs?
60 # - or fix at runtime, by having selfservice client ask server for the list?
61 sub ss2clientapi {
62   {
63   'passwd'                    => 'passwd/passwd',
64   'chfn'                      => 'passwd/passwd',
65   'chsh'                      => 'passwd/passwd',
66   'login_info'                => 'MyAccount/login_info',
67   'login'                     => 'MyAccount/login',
68   'logout'                    => 'MyAccount/logout',
69   'customer_info'             => 'MyAccount/customer_info',
70   'edit_info'                 => 'MyAccount/edit_info',     #add to ss cgi!
71   'invoice'                   => 'MyAccount/invoice',
72   'invoice_pdf'               => 'MyAccount/invoice_pdf',
73   'invoice_logo'              => 'MyAccount/invoice_logo',
74   'list_invoices'             => 'MyAccount/list_invoices', #?
75   'cancel'                    => 'MyAccount/cancel',        #add to ss cgi!
76   'payment_info'              => 'MyAccount/payment_info',
77   'payment_info_renew_info'   => 'MyAccount/payment_info_renew_info',
78   'process_payment'           => 'MyAccount/process_payment',
79   'process_payment_order_pkg' => 'MyAccount/process_payment_order_pkg',
80   'process_payment_change_pkg' => 'MyAccount/process_payment_change_pkg',
81   'process_payment_order_renew' => 'MyAccount/process_payment_order_renew',
82   'process_prepay'            => 'MyAccount/process_prepay',
83   'realtime_collect'          => 'MyAccount/realtime_collect',
84   'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
85   'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
86   'list_svc_usage'            => 'MyAccount/list_svc_usage',   
87   'port_graph'                => 'MyAccount/port_graph',   
88   'list_cdr_usage'            => 'MyAccount/list_cdr_usage',   
89   'list_support_usage'        => 'MyAccount/list_support_usage',   
90   'order_pkg'                 => 'MyAccount/order_pkg',     #add to ss cgi!
91   'change_pkg'                => 'MyAccount/change_pkg', 
92   'order_recharge'            => 'MyAccount/order_recharge',
93   'renew_info'                => 'MyAccount/renew_info',
94   'order_renew'               => 'MyAccount/order_renew',
95   'cancel_pkg'                => 'MyAccount/cancel_pkg',    #add to ss cgi!
96   'suspend_pkg'               => 'MyAccount/suspend_pkg',   #add to ss cgi!
97   'charge'                    => 'MyAccount/charge',        #?
98   'part_svc_info'             => 'MyAccount/part_svc_info',
99   'provision_acct'            => 'MyAccount/provision_acct',
100   'provision_phone'           => 'MyAccount/provision_phone',
101   'provision_external'        => 'MyAccount/provision_external',
102   'unprovision_svc'           => 'MyAccount/unprovision_svc',
103   'myaccount_passwd'          => 'MyAccount/myaccount_passwd',
104   'create_ticket'             => 'MyAccount/create_ticket',
105   'get_ticket'                => 'MyAccount/get_ticket',
106   'adjust_ticket_priority'    => 'MyAccount/adjust_ticket_priority',
107   'did_report'                => 'MyAccount/did_report',
108   'signup_info'               => 'Signup/signup_info',
109   'skin_info'                 => 'MyAccount/skin_info',
110   'access_info'               => 'MyAccount/access_info',
111   'domain_select_hash'        => 'Signup/domain_select_hash',  # expose?
112   'new_customer'              => 'Signup/new_customer',
113   'capture_payment'           => 'Signup/capture_payment',
114   'clear_signup_cache'        => 'Signup/clear_cache',
115   'new_agent'                 => 'Agent/new_agent',
116   'agent_login'               => 'Agent/agent_login',
117   'agent_logout'              => 'Agent/agent_logout',
118   'agent_info'                => 'Agent/agent_info',
119   'agent_list_customers'      => 'Agent/agent_list_customers',
120   'check_username'            => 'Agent/check_username',
121   'suspend_username'          => 'Agent/suspend_username',
122   'unsuspend_username'        => 'Agent/unsuspend_username',
123   'mason_comp'                => 'MasonComponent/mason_comp',
124   'call_time'                 => 'PrepaidPhone/call_time',
125   'call_time_nanpa'           => 'PrepaidPhone/call_time_nanpa',
126   'phonenum_balance'          => 'PrepaidPhone/phonenum_balance',
127   #izoom
128   #'bulk_processrow'           => 'Bulk/processrow',
129   #conflicts w/Agentone# 'check_username'            => 'Bulk/check_username',
130   #sg
131   'ping'                      => 'SGNG/ping',
132   'decompify_pkgs'            => 'SGNG/decompify_pkgs',
133   'previous_payment_info'     => 'SGNG/previous_payment_info',
134   'previous_payment_info_renew_info'
135                               => 'SGNG/previous_payment_info_renew_info',
136   'previous_process_payment'  => 'SGNG/previous_process_payment',
137   'previous_process_payment_order_pkg'
138                               => 'SGNG/previous_process_payment_order_pkg',
139   'previous_process_payment_change_pkg'
140                               => 'SGNG/previous_process_payment_change_pkg',
141   'previous_process_payment_order_renew'
142                               => 'SGNG/previous_process_payment_order_renew',
143   };
144 }
145
146
147 #XXX submit patch to SOAP::Lite
148
149 use XMLRPC::Transport::HTTP;
150
151 package XMLRPC::Transport::HTTP::Server;
152
153 @XMLRPC::Transport::HTTP::Server::ISA = qw(SOAP::Transport::HTTP::Server);
154
155 sub initialize; *initialize = \&XMLRPC::Server::initialize;
156 sub make_fault; *make_fault = \&XMLRPC::Transport::HTTP::CGI::make_fault;
157 sub make_response; *make_response = \&XMLRPC::Transport::HTTP::CGI::make_response;
158
159 1;