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