1 package FS::part_export::http_status;
2 use base qw( FS::part_export );
8 use HTTP::Request::Common;
10 tie my %options, 'Tie::IxHash',
11 'url' => { label => 'URL', },
12 #'user' => { label => 'Username', default=>'' },
13 #'password' => { label => 'Password', default => '' },
18 'desc' => 'Retrieve status information via HTTP or HTTPS',
19 'options' => \%options,
21 Fields from the service can be substituted in the URL as $field.
25 sub rebless { shift; }
27 sub export_getstatus {
28 my( $self, $svc_x, $htmlref, $hashref ) = @_;
31 my $urlopt = $self->option('url');
35 ${$_} = $svc_x->getfield($_) foreach $svc_x->fields;
36 if ( $svc_x->table eq 'svc_dsl' ) {
37 ${$_} = $svc_x->$_() foreach (qw( gateway_access_or_phonenum ));
40 $url = eval(qq("$urlopt"));
43 my $req = HTTP::Request::Common::GET( $url );
44 my $ua = LWP::UserAgent->new;
45 my $response = $ua->request($req);
47 $$htmlref = $response->is_error ? $response->error_as_HTML
50 #hash data note yet implemented for this status export