| 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 | 1 | our $VERSION = '1.6.0'; | |||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | SelectPdf::WebElementsClient - Get the locations of certain web elements. | ||||||||||
| 13 | This is retrieved if pdf_web_elements_selectors parameter was set during the initial conversion call and elements were found to match the selectors. | ||||||||||
| 14 | |||||||||||
| 15 | =head1 METHODS | ||||||||||
| 16 | |||||||||||
| 17 | =head2 new( $apiKey, $jobId ) | ||||||||||
| 18 | |||||||||||
| 19 | Construct the web elements client. | ||||||||||
| 20 | |||||||||||
| 21 | my $client = SelectPdf::WebElementsClient->new($apiKey, $jobId); | ||||||||||
| 22 | |||||||||||
| 23 | Parameters: | ||||||||||
| 24 | |||||||||||
| 25 | - $apiKey API Key. | ||||||||||
| 26 | - $jobId Job ID. | ||||||||||
| 27 | =cut | ||||||||||
| 28 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 0 | my $type = shift; | |||||||||
| 30 | 0 | my $self = $type->SUPER::new; | |||||||||
| 31 | |||||||||||
| 32 | # API endpoint | ||||||||||
| 33 | 0 | $self->{apiEndpoint} = "https://selectpdf.com/api2/webelements/"; | |||||||||
| 34 | |||||||||||
| 35 | 0 | $self->{parameters}{"key"} = shift; | |||||||||
| 36 | 0 | $self->{parameters}{"job_id"} = shift; | |||||||||
| 37 | |||||||||||
| 38 | 0 | bless $self, $type; | |||||||||
| 39 | 0 | return $self; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | =head2 getWebElements | ||||||||||
| 43 | |||||||||||
| 44 | 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. | ||||||||||
| 45 | |||||||||||
| 46 | my $client = SelectPdf::WebElementsClient->new($apiKey, $jobId); | ||||||||||
| 47 | $elements = $client->getWebElements(); | ||||||||||
| 48 | |||||||||||
| 49 | Returns: | ||||||||||
| 50 | |||||||||||
| 51 | - List of web elements locations. | ||||||||||
| 52 | =cut | ||||||||||
| 53 | 0 | ▶ | sub getWebElements { | ||||||||
|
Subroutine
getWebElements: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 54 | 0 | my($self) = @_; | |||||||||
| 55 | |||||||||||
| 56 | 0 | $self->{headers}{"Accept"} = "text/json"; | |||||||||
| 57 | |||||||||||
| 58 | 0 | my $result = $self->SUPER::performPost(); | |||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | if ($result) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | return decode_json($result); | |||||||||
| 62 | } | ||||||||||
| 63 | else { | ||||||||||
| 64 | 0 | return []; | |||||||||
| 65 | } | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||