X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fhttp.pm;h=3749224ffca5b1c8f80ae05bcd81b82ec621c0ae;hb=b5c4237a34aef94976bc343c8d9e138664fc3984;hp=9a216c148eec48f66aac548cd56b312355de3cd9;hpb=fd93bd0bf90836be82c5271bb36e46cca83735f4;p=freeside.git diff --git a/FS/FS/part_export/http.pm b/FS/FS/part_export/http.pm index 9a216c148..3749224ff 100644 --- a/FS/FS/part_export/http.pm +++ b/FS/FS/part_export/http.pm @@ -33,6 +33,10 @@ tie %options, 'Tie::IxHash', default => join("\n", ), }, + 'success_regexp' => { + label => 'Success Regexp', + default => '', + }, ; %info = ( @@ -71,6 +75,7 @@ sub _export_command { $self->http_queue( $svc_x->svcnum, $self->option('method'), $self->option('url'), + $self->option('success_regexp'), map { /^\s*(\S+)\s+(.*)$/ or /()()/; my( $field, $value_expression ) = ( $1, $2 ); @@ -90,13 +95,16 @@ sub _export_replace { my $new_cust_main = $new->table eq 'cust_main' ? $new : $new->cust_svc->cust_pkg->cust_main; + my $cust_main = $new_cust_main; #so folks can use $new_cust_main or $cust_main - $self->http_queue( $svc_x->svcnum, + $self->http_queue( $new->svcnum, $self->option('method'), $self->option('url'), + $self->option('success_regexp'), map { /^\s*(\S+)\s+(.*)$/ or /()()/; my( $field, $value_expression ) = ( $1, $2 ); + my $value = eval $value_expression; die $@ if $@; ( $field, $value ); } split(/\n/, $self->option('replace_data') ) @@ -112,7 +120,7 @@ sub http_queue { } sub http { - my($method, $url, @data) = @_; + my($method, $url, $success_regexp, @data) = @_; $method = lc($method); @@ -132,6 +140,11 @@ sub http { die $response->error_as_HTML if $response->is_error; + if(length($success_regexp) > 1) { + my $response_content = $response->content; + die $response_content unless $response_content =~ /$success_regexp/; + } + } 1;