3 # Copyright (c) 2004 Kristian Hoffmann <khoff@fire2wire.com>
4 # Based on the original RT::URI::base and RT::URI::fsck_com_rt.
6 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
8 # (Except where explictly superceded by other copyright notices)
10 # This work is made available to you under the terms of Version 2 of
11 # the GNU General Public License. A copy of that license should have
12 # been provided with this software, but in any event can be snarfed
15 # This work is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details.
20 # Unless otherwise specified, all modifications, corrections or
21 # extensions to this work which alter its source code become the
22 # property of Best Practical Solutions, LLC when submitted for
23 # inclusion in the work.
29 no warnings qw(redefine);
31 use vars qw($URL $XMLRPC_URL $_FS_VERSION);
37 RT::URI::freeside::XMLRPC
41 Overlay for the RT::URI::freeside URI handler implementing the XMLRPC integration type.
43 See L<RT::URI::freeside> for public/private interface documentation.
48 sub _XMLRPCRequest { #Subroutine
55 my $server = new Frontier::Client ( url => $XMLRPC_URL );
56 $result = $server->call($method, @args);
59 if (not $@ and ref($result) eq 'ARRAY') {
60 return (scalar(@$result) == 1) ? @$result[0] : @$result;
62 $RT::Logger->debug("Freeside XMLRPC: " . $result || $@);
68 sub _FreesideGetRecord {
71 my ($table, $pkey) = ($self->{'fstable'}, $self->{'fspkey'});
74 $RT::Logger->debug("Called XMLRPC::_FreesideGetRecord()");
76 #FIXME: Need a better way to get primary keys.
77 # Maybe create a method for it and cache them like version?
79 cust_main => 'custnum',
82 my $method = 'Record.qsearchs';
83 my @args = ($table, { $table_pkeys{$table} => $pkey });
84 my ($record) = &_XMLRPCRequest($method, @args);
91 sub FreesideGetConfig {
93 return _XMLRPCRequest('Conf.config', @_);
104 sub FreesideVersion {
106 return $_FS_VERSION if ($_FS_VERSION =~ /^\d+\.\d+\.\d+/);
108 $RT::Logger->debug("Requesting freeside version...");
109 ($_FS_VERSION) = &_XMLRPCRequest('version');
110 $RT::Logger->debug("Cached freeside version: ${_FS_VERSION}");
116 sub smart_search { #Subroutine
118 return _XMLRPCRequest('cust_main.smart_search', @_);
124 return _XMLRPCRequest('CGI.small_custview', @_);