File Coverage

blib/lib/WebService/Reactio/Incident.pm
Criterion Covered Total %
statement 30 30 100.0
branch 8 8 100.0
condition 3 6 50.0
subroutine 8 8 100.0
pod 0 4 0.0
total 49 56 87.5


line stmt bran cond sub pod time code
1             package WebService::Reactio::Incident;
2 1     1   567 use strict;
  1         1  
  1         23  
3 1     1   5 use warnings;
  1         1  
  1         22  
4 1     1   724 use utf8;
  1         9  
  1         5  
5              
6 1     1   23 use Carp;
  1         1  
  1         253  
7              
8             sub create_incident {
9 2     2 0 2336 my ($self, $name, $options) = @_;
10 2 100       137 Carp::croak '[ERROR] Incident name is required' unless $name;
11              
12 1   50     6 my $params = $options || {};
13 1         2 $params->{name} = $name;
14              
15 1         5 $self->_request('POST', '/api/v1/incidents', $params);
16             }
17              
18             sub incident {
19 2     2 0 2215 my ($self, $incident_id) = @_;
20 2 100       103 Carp::croak '[ERROR] Incident id is required' unless $incident_id;
21              
22 1         5 $self->_request('GET', '/api/v1/incidents/'.$incident_id);
23             }
24              
25             sub incidents {
26 1     1 0 890 my ($self, $options) = @_;
27 1   50     5 my $params = $options || {};
28              
29 1         7 $self->_request('GET', '/api/v1/incidents', $params);
30             }
31              
32             sub notify_incident {
33 3     3 0 2535 my ($self, $incident_id, $text, $options) = @_;
34 3 100       106 Carp::croak '[ERROR] Incident id is required' unless $incident_id;
35 2 100       97 Carp::croak '[ERROR] Notification text is required' unless $text;
36              
37 1   50     3 my $params = $options || {};
38 1         2 $params->{incident_id} = $incident_id;
39 1         3 $params->{notification_text} = $text;
40              
41 1         4 $self->_request('POST', '/api/v1/notifications', $params);
42             }
43              
44             1;