| 1 | package Bio::Cellucidate::Request; | ||||||||||
| 2 | |||||||||||
| 3 | 7 | ▶ | use base REST::Client; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use XML::Simple; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 32 | ▶ | sub processResponse { | ||||||||
|
Subroutine
processResponse: called CC=4 SCAR=15.5
Pod
undocumented
| |||||||||||
| 7 | 32 | my $self = shift; | |||||||||
| 8 | 32 | ▶ | die "No content!" unless (my $content = $self->responseContent); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 9 | 32 | ▶ | unless ($self->responseCode eq '200') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 10 | 0 | die "Invalid Request! Response Code: " . $self->responseCode . "\n" . $content; | |||||||||
| 11 | } | ||||||||||
| 12 | 32 | ▶ | if ($self->responseHeader('Content-Type') =~ /.*application\/xml.*/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 32 | return eval { XMLin($content, ForceArray => 0, KeepRoot => 0, KeyAttr => [], NoAttr => 1, SuppressEmpty => undef) }; | |||||||||
| 14 | } else { | ||||||||||
| 15 | 0 | return $content; | |||||||||
| 16 | } | ||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 10 | ▶ | sub processResponseAsArray { | ||||||||
|
Subroutine
processResponseAsArray: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||
| 20 | 10 | my $self = shift; | |||||||||
| 21 | 10 | my $key = shift; | |||||||||
| 22 | |||||||||||
| 23 | 10 | ▶ | my $response_data = $self->processResponse->{$key} if $self->processResponse; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 10 | ▶ | return [] unless $response_data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 10 | ▶ | return ref($response_data) eq 'ARRAY' ? $response_data : [ $response_data ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub _xbuildUseragent { | ||||||||
|
Subroutine
_xbuildUseragent: not called CC=2 SCAR=17.9
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | return if $self->getUseragent(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | my $ua = LWP::UserAgent->new; | |||||||||
| 36 | 0 | $ua->agent("Bio::Cellucidate::Request/$Bio::Cellucidate::VERSION"); | |||||||||
| 37 | 0 | $self->setUseragent($ua); | |||||||||
| 38 | |||||||||||
| 39 | 0 | return; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 7 | 1; | |||||||||