blib/lib/SignalWire/Agents/REST/Namespaces/Base.pm

filter: Statementstmt 62.5% 20 / 32 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 54.5% 6 / 11 Podpod 0.0% 0 / 5 totaltotal 52.0% 26 / 50 CC 2 SCAR 7.7
CC
2
Cov
59%
list
6.0
create
2.0
get
2.0
CRAP 2.2
« blib/lib/SignalWire/Agents/REST/Namespaces/Datasphere.pm ↑ Summary blib/lib/SignalWire/Agents/Skills/Builtin/DatasphereServerless.pm »
1 package SignalWire::Agents::REST::Namespaces::Base;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Base for all namespace/resource classes.
7 4 has '_http' => ( is => 'ro', required => 1 );
8 4 has '_base_path' => ( is => 'ro', required => 1 );
9  
10 1 ▶sub _path {
Subroutine _path: called CC=1 SCAR=0.0
11 1 my ($self, @parts) = @_;
12 1 return join('/', $self->_base_path, @parts);
13 }
14  
15 # --- CrudResource ---
16 package SignalWire::Agents::REST::Namespaces::CrudResource;
17 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 extends 'SignalWire::Agents::REST::Namespaces::Base';
19  
20 # Subclasses can override: 'PATCH' (default) or 'PUT'
21 20 ▶has '_update_method' => ( is => 'ro', default => sub { 'PATCH' } );
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 0 ▶sub list {
Subroutine list: not called CC=2 SCAR=17.9
Pod undocumented
24 0 my ($self, %params) = @_;
25 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
26 0 return $self->_http->get($self->_base_path, params => $p);
27 }
28  
29 0 ▶sub create {
Subroutine create: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my ($self, %kwargs) = @_;
31 0 return $self->_http->post($self->_base_path, body => \%kwargs);
32 }
33  
34 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
35 0 my ($self, $resource_id) = @_;
36 0 return $self->_http->get($self->_path($resource_id));
37 }
38  
39 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
Pod undocumented
40 0 my ($self, $resource_id, %kwargs) = @_;
41 0 my $method = lc($self->_update_method);
42 0 return $self->_http->$method($self->_path($resource_id), body => \%kwargs);
43 }
44  
45 0 ▶sub delete_resource {
Subroutine delete_resource: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my ($self, $resource_id) = @_;
47 0 return $self->_http->delete_request($self->_path($resource_id));
48 }
49  
50 4 1;
« blib/lib/SignalWire/Agents/REST/Namespaces/Datasphere.pm ↑ Summary blib/lib/SignalWire/Agents/Skills/Builtin/DatasphereServerless.pm »