| 1 | package Apigee::Edge; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Mojo::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Mojo::URL; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Mojo::Util qw(b64_encode); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use URI::Escape qw/uri_escape/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use vars qw/$errstr/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub errstr { return $errstr } | ||||||||||||||||||||||||||
|
Subroutine
errstr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub new { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | for (qw/org usr pwd/) { | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | $args{$_} || croak "Param $_ is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $args{endpoint} ||= 'https://api.enterprise.apigee.com/v1'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"endpoint"} ||= "https://api.enterprise.apigee.com/v1"
MC/DC0%0/1
$args{"endpoint"} ||= "https://api.enterprise.apigee.com/v1"
$args{"endpoint"}
Truth table0%0/2
A
A= $args{"endpoint"}
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $args{timeout} ||= 60; # for ua timeout | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{"timeout"} ||= 60
MC/DC0%0/1
$args{"timeout"} ||= 60
$args{"timeout"}
Truth table0%0/2
A
A= $args{"timeout"}
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | return bless \%args, $class; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub __ua { | ||||||||||||||||||||||||||
|
Subroutine
__ua: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | return $self->{ua} if exists $self->{ua}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my $ua = Mojo::UserAgent->new; | |||||||||||||||||||||||||||
| 36 | 0 | $ua->max_redirects(3); | |||||||||||||||||||||||||||
| 37 | 0 | $ua->inactivity_timeout($self->{timeout}); | |||||||||||||||||||||||||||
| 38 | 0 | $ua->proxy->detect; # env proxy | |||||||||||||||||||||||||||
| 39 | 0 | $ua->cookie_jar(0); | |||||||||||||||||||||||||||
| 40 | 0 | $ua->max_connections(100); | |||||||||||||||||||||||||||
| 41 | 0 | $self->{ua} = $ua; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | return $ua; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | ## Apps http://apigee.com/docs/api/apps-0 | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub get_app { | ||||||||||||||||||||||||||
|
Subroutine
get_app: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ($self, $app_id) = @_; | |||||||||||||||||||||||||||
| 49 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/apps/$app_id"); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub get_apps_by_family { | ||||||||||||||||||||||||||
|
Subroutine
get_apps_by_family: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($self, $family) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/apps?appfamily=" . uri_escape($family)); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub get_apps_by_keystatus { | ||||||||||||||||||||||||||
|
Subroutine
get_apps_by_keystatus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 0 | my ($self, $keystatus) = @_; | |||||||||||||||||||||||||||
| 59 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/apps?keyStatus=" . uri_escape($keystatus)); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub get_apps_by_type { | ||||||||||||||||||||||||||
|
Subroutine
get_apps_by_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 0 | my ($self, $type) = @_; | |||||||||||||||||||||||||||
| 64 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/apps?apptype=" . uri_escape($type)); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub get_apps { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
get_apps: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | my $url = Mojo::URL->new("/o/" . $self->{org} . "/apps"); | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | $url->query(\%args) if %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | return $self->request('GET', $url->to_string); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | ## Developers http://apigee.com/docs/api/developers-0 | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub create_developer { | ||||||||||||||||||||||||||
|
Subroutine
create_developer: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | return $self->request('POST', "/o/" . $self->{org} . "/developers", %args); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub get_developer { | ||||||||||||||||||||||||||
|
Subroutine
get_developer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 84 | 0 | my ($email) = @_; | |||||||||||||||||||||||||||
| 85 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers/" . uri_escape($email)); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub delete_developer { | ||||||||||||||||||||||||||
|
Subroutine
delete_developer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 0 | my ($email) = @_; | |||||||||||||||||||||||||||
| 91 | 0 | return $self->request('DELETE', "/o/" . $self->{org} . "/developers/" . uri_escape($email)); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub get_app_developers { | ||||||||||||||||||||||||||
|
Subroutine
get_app_developers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | 0 | my ($app) = @_; | |||||||||||||||||||||||||||
| 97 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers?app=" . uri_escape($app)); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub get_developers { | ||||||||||||||||||||||||||
|
Subroutine
get_developers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 102 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers"); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub set_developer_status { | ||||||||||||||||||||||||||
|
Subroutine
set_developer_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 0 | my ($self, $email, $status); | |||||||||||||||||||||||||||
| 107 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "?action=" . uri_escape($status)); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub update_developer { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
update_developer: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 112 | 0 | my $email = shift; | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $email or croak "email is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | return $self->request('PUT', "/o/" . $self->{org} . "/developers/" . uri_escape($email), %args); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | ## Apps: Developer http://apigee.com/docs/api/apps-developer | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub change_app_status { | ||||||||||||||||||||||||||
|
Subroutine
change_app_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 0 | my ($self, $email, $app) = @_; | |||||||||||||||||||||||||||
| 121 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps/" . uri_escape($app)); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub create_developer_app { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
create_developer_app: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 0 | my $email = shift; | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | return $self->request('POST', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps", %args); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub delete_developer_app { | ||||||||||||||||||||||||||
|
Subroutine
delete_developer_app: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 132 | 0 | my ($self, $email, $app) = @_; | |||||||||||||||||||||||||||
| 133 | 0 | return $self->request('DELETE', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps/" . uri_escape($app)); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub get_developer_app { | ||||||||||||||||||||||||||
|
Subroutine
get_developer_app: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 0 | my ($self, $email, $app) = @_; | |||||||||||||||||||||||||||
| 138 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps/" . uri_escape($app)); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub get_developer_apps { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
get_developer_apps: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 143 | 0 | my $email = shift; | |||||||||||||||||||||||||||
| 144 | 0 | ▶ | $email or croak "email is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | my $url = Mojo::URL->new("/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps"); | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | $url->query(\%args) if %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | return $self->request('GET', $url->to_string); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub update_developer_app { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
update_developer_app: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 154 | 0 | my $email = shift; | |||||||||||||||||||||||||||
| 155 | 0 | my $app = shift; | |||||||||||||||||||||||||||
| 156 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $email or croak "email is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $app or croak "app is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | return $self->request('PUT', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps/" . uri_escape($app), %args); | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub get_count_of_developer_app_resource { | ||||||||||||||||||||||||||
|
Subroutine
get_count_of_developer_app_resource: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 163 | 0 | my ($self, $email, $app, $entity) = @_; | |||||||||||||||||||||||||||
| 164 | return $self->request('GET', | ||||||||||||||||||||||||||||
| 165 | "/o/" | ||||||||||||||||||||||||||||
| 166 | . $self->{org} | ||||||||||||||||||||||||||||
| 167 | 0 | . "/developers/" | |||||||||||||||||||||||||||
| 168 | . uri_escape($email) | ||||||||||||||||||||||||||||
| 169 | . "/apps/" | ||||||||||||||||||||||||||||
| 170 | . uri_escape($app) | ||||||||||||||||||||||||||||
| 171 | . qq~?"query=count&entity=~ | ||||||||||||||||||||||||||||
| 172 | . uri_escape($entity) | ||||||||||||||||||||||||||||
| 173 | . qq~"~); | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub regenerate_developer_app_key { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
regenerate_developer_app_key: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 178 | 0 | my $email = shift; | |||||||||||||||||||||||||||
| 179 | 0 | my $app = shift; | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $email or croak "email is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $app or croak "app is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | return $self->request('POST', "/o/" . $self->{org} . "/developers/" . uri_escape($email) . "/apps/" . uri_escape($app), %args); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | ## API Products http://apigee.com/docs/api/api-products-1 | ||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub create_api_product { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
create_api_product: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 188 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | return $self->request('POST', "/o/" . $self->{org} . "/apiproducts", %args); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub update_api_product { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
update_api_product: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 195 | 0 | my $product = shift; | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $product or croak "product is required."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | return $self->request('PUT', "/o/" . $self->{org} . "/apiproducts/" . uri_escape($product), %args); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub delete_api_product { | ||||||||||||||||||||||||||
|
Subroutine
delete_api_product: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 0 | my ($self, $product) = @_; | |||||||||||||||||||||||||||
| 203 | 0 | return $self->request('DELETE', "/o/" . $self->{org} . "/apiproducts/" . uri_escape($product)); | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub get_api_product { | ||||||||||||||||||||||||||
|
Subroutine
get_api_product: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 207 | 0 | my ($self, $product) = @_; | |||||||||||||||||||||||||||
| 208 | 0 | return $self->request('GET', "/o/" . $self->{org} . "/apiproducts/" . uri_escape($product)); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub get_api_products { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
get_api_products: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | my $url = Mojo::URL->new("/o/" . $self->{org} . "/apiproducts"); | |||||||||||||||||||||||||||
| 215 | 0 | ▶ | $url->query(\%args) if %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | return $self->request('GET', $url->to_string); | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub search_api_products { | ||||||||||||||||||||||||||
|
Subroutine
search_api_products: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 220 | 0 | return (shift)->get_api_products(@_); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub get_api_product_details { ## no critic (ArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
get_api_product_details: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 224 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 225 | 0 | my $product = shift; | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | my %args = @_ % 2 ? %{$_[0]} : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | my $url = Mojo::URL->new("/o/" . $self->{org} . "/apiproducts/" . uri_escape($product)); | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | $url->query(\%args) if %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | return $self->request('GET', $url->to_string); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | sub request { | ||||||||||||||||||||||||||
|
Subroutine
request: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 0 | my ($self, $method, $url, %params) = @_; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | $errstr = ''; # reset | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my $ua = $self->__ua; | |||||||||||||||||||||||||||
| 238 | 0 | my $header = {Authorization => 'Basic ' . b64_encode($self->{usr} . ':' . $self->{pwd}, '')}; | |||||||||||||||||||||||||||
| 239 | 0 | ▶ | $header->{'Content-Type'} = 'application/json' if %params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my @extra = %params ? (json => \%params) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | my $tx = $ua->build_tx($method => $self->{endpoint} . $url => $header => @extra); | |||||||||||||||||||||||||||
| 242 | 0 | $tx->req->headers->accept('application/json'); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | $tx = $ua->start($tx); | |||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($tx->res->headers->content_type and $tx->res->headers->content_type =~ 'application/json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tx->res->headers->content_type and $tx->res->headers->content_type =~ m[application/json]
MC/DC0%0/2
$tx->res->headers->content_type and $tx->res->headers->content_type =~ m[application/json]
$tx->res->headers->content_type
$tx->res->headers->content_type =~ m[application/json]
Truth table0%0/3
A and B
A= $tx->res->headers->content_typeB= $tx->res->headers->content_type =~ m[application/json]
| |||||||||||||||||||||||||||||
| 246 | 0 | return $tx->res->json; | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if (!$tx->success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 0 | $errstr = "Failed to fetch $url: " . $tx->error->{message}; | |||||||||||||||||||||||||||
| 250 | 0 | return; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 0 | $errstr = "Unknown Response."; | |||||||||||||||||||||||||||
| 254 | 0 | return; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 3 | 1; | |||||||||||||||||||||||||||
| 258 | __END__ | ||||||||||||||||||||||||||||