1 package FS::part_export::http;
6 @ISA = qw(FS::part_export);
12 $self->_export_command('insert', @_);
17 $self->_export_command('delete', @_);
21 my( $self, $action, $svc_x ) = ( shift, shift, shift );
23 return unless $self->option("${action}_data");
25 $self->http_queue( $svc_x->svcnum,
26 $self->option('method'),
29 /^\s*(\S+)\s+(.*)$/ or /()()/;
30 my( $field, $value_expression ) = ( $1, $2 );
31 my $value = eval $value_expression;
34 } split(/\n/, $self->option("${action}_data") )
40 my( $self, $new, $old ) = ( shift, shift, shift );
42 return unless $self->option('replace_data');
44 $self->http_queue( $svc_x->svcnum,
45 $self->option('method'),
48 /^\s*(\S+)\s+(.*)$/ or /()()/;
49 my( $field, $value_expression ) = ( $1, $2 );
52 } split(/\n/, $self->option('replace_data') )
58 my($self, $svcnum) = (shift, shift);
59 my $queue = new FS::queue {
61 'job' => "FS::part_export::http::http",
67 my($method, $url, @data) = @_;
69 $method = lc($method);
71 eval "use LWP::UserAgent;";
72 die "using LWP::UserAgent: $@" if $@;
73 eval "use HTTP::Request::Common;";
74 die "using HTTP::Request::Common: $@" if $@;
76 my $ua = LWP::UserAgent->new;
78 #my $response = $ua->$method(
80 # 'Content-Type'=>'application/x-www-form-urlencoded'
82 my $req = HTTP::Request::Common::POST( $url, \@data );
83 my $response = $ua->request($req);
85 die $response->error_as_HTML if $response->is_error;