SelectPdf/WebElementsClient.pm

filter: Statementstmt 45.8% 11 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 48.4% 16 / 33 CC 2 SCAR 10.4
CC
2
Cov
42%
getWebElements
6.0
new
2.0
BEGIN
1.0
CRAP 2.8
« SelectPdf/AsyncJobClient.pm ↑ Summary SelectPdf/PdfMergeClient.pm »
1 package SelectPdf::WebElementsClient;
2
3 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use SelectPdf::ApiClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 our @ISA = qw(SelectPdf::ApiClient);
7
8 =head1 NAME
9
10 SelectPdf::WebElementsClient - Get the locations of certain web elements.
11 This is retrieved if pdf_web_elements_selectors parameter was set during the initial conversion call and elements were found to match the selectors.
12
13 =head1 METHODS
14
15 =head2 new( $apiKey, $jobId )
16
17 Construct the web elements client.
18
19 my $client = SelectPdf::WebElementsClient->new($apiKey, $jobId);
20
21 Parameters:
22
23 - $apiKey API Key.
24 - $jobId Job ID.
25 =cut
26 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
27 0 my $type = shift;
28 0 my $self = $type->SUPER::new;
29
30 # API endpoint
31 0 $self->{apiEndpoint} = "https://selectpdf.com/api2/webelements/";
32
33 0 $self->{parameters}{"key"} = shift;
34 0 $self->{parameters}{"job_id"} = shift;
35
36 0 bless $self, $type;
37 0 return $self;
38 }
39
40 =head2 getWebElements
41
42 Get the locations of certain web elements. This is retrieved if pdf_web_elements_selectors parameter is set and elements were found to match the selectors.
43
44 my $client = SelectPdf::WebElementsClient->new($apiKey, $jobId);
45 $elements = $client->getWebElements();
46
47 Returns:
48
49 - List of web elements locations.
50 =cut
51 0 ▶sub getWebElements {
Subroutine getWebElements: not called CC=2 SCAR=17.9
Pod documented
52 0 my($self) = @_;
53
54 0 $self->{headers}{"Accept"} = "text/json";
55
56 0 my $result = $self->SUPER::performPost();
57
58 0 ▶ if ($result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 0 0 0
59 0 return decode_json($result);
60 }
61 else {
62 0 return [];
63 }
64 }
65
66 1 1;
« SelectPdf/AsyncJobClient.pm ↑ Summary SelectPdf/PdfMergeClient.pm »