DSL status pulling, RT#13656
[freeside.git] / FS / FS / part_export / http_status.pm
1 packages FS::part_export::http_status;
2 use base qw( FS::part_export );
3
4 use strict;
5 use warnings;
6 use LWP::UserAgent;
7 use HTTP::Request::Common;
8
9 tie my %options, 'Tie::IxHash',
10   'url' => { label => 'URL', },
11   #'user'     => { label => 'Username', default=>'' },
12   #'password' => { label => 'Password', default => '' },
13 ;
14
15 %info = (
16   'svc'     => 'svc_dsl',
17   'desc'    => 'Retrieve status information via HTTP or HTTPS',
18   'options' => \%options,
19   'notes'   => <<'END'
20 Fields from the service can be substituted in the URL as $field.
21 END
22 );
23
24 sub rebless { shift; }
25
26 sub export_getstatus {
27   my( $self, $svc_x, $htmlref, $hashref ) = @_;
28
29   my $url = $self->option('url');
30   {
31     no strict 'refs';
32     ${$_} = $svc_x->getfield($x) foreach $svc_x->fields;
33
34     $url = eval(qq($url));
35   }
36
37   my $req = HTTP::Request::Common::GET( $url );
38   my $ua = LWP::UserAgent->new;
39   my $response = $ua->request($req);
40
41   $$htmlref = $response->is_error ? $response->error_as_HTML
42                                   : $response->content;
43
44
45   #hash data note yet implemented for this status export
46
47 }
48
49 1;