| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::SecurityCenter::API::Notification; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 705 | use warnings; | 
|  | 2 |  |  |  |  | 15 |  | 
|  | 2 |  |  |  |  | 62 |  | 
| 4 | 2 |  |  | 2 |  | 10 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 36 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 2 |  | 10 | use parent 'Net::SecurityCenter::Base'; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 9 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 92 | use Net::SecurityCenter::Utils qw(:all); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 870 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION = '0.310'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | my $common_template = { | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | id => { | 
| 15 |  |  |  |  |  |  | required => 1, | 
| 16 |  |  |  |  |  |  | allow    => qr/^\d+$/, | 
| 17 |  |  |  |  |  |  | messages => { | 
| 18 |  |  |  |  |  |  | required => 'Notification ID is required', | 
| 19 |  |  |  |  |  |  | allow    => 'Invalid Notification ID', | 
| 20 |  |  |  |  |  |  | }, | 
| 21 |  |  |  |  |  |  | }, | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | fields => { | 
| 24 |  |  |  |  |  |  | filter => \&sc_filter_array_to_string, | 
| 25 |  |  |  |  |  |  | }, | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | }; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | #------------------------------------------------------------------------------- | 
| 30 |  |  |  |  |  |  | # METHODS | 
| 31 |  |  |  |  |  |  | #------------------------------------------------------------------------------- | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub list { | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 1 |  |  | 1 | 1 | 3 | my ( $self, %args ) = @_; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | my $tmpl = { | 
| 38 | 1 |  |  |  |  | 9 | fields    => $common_template->{'fields'}, | 
| 39 |  |  |  |  |  |  | timeframe => { | 
| 40 |  |  |  |  |  |  | allow   => [ '24h', '7d', '30d' ], | 
| 41 |  |  |  |  |  |  | default => '24h' | 
| 42 |  |  |  |  |  |  | }, | 
| 43 |  |  |  |  |  |  | raw => {}, | 
| 44 |  |  |  |  |  |  | }; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 1 |  |  |  |  | 4 | my $params = sc_check_params( $tmpl, \%args ); | 
| 47 | 1 |  |  |  |  | 2 | my $raw    = delete( $params->{'raw'} ); | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 1 |  |  |  |  | 9 | my $notifications = $self->client->get( '/notification', $params ); | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 1 | 50 |  |  |  | 4 | return if ( !$notifications ); | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 1 | 50 |  |  |  | 4 | if ($raw) { | 
| 54 | 0 | 0 |  |  |  | 0 | return wantarray ? @{$notifications} : $notifications; | 
|  | 0 |  |  |  |  | 0 |  | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 1 | 50 |  |  |  | 6 | return wantarray ? @{ sc_normalize_array($notifications) } : sc_normalize_array($notifications); | 
|  | 0 |  |  |  |  | 0 |  | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | #------------------------------------------------------------------------------- | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | sub get { | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 1 |  |  | 1 | 1 | 4 | my ( $self, %args ) = @_; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | my $tmpl = { | 
| 68 |  |  |  |  |  |  | fields => $common_template->{'fields'}, | 
| 69 | 1 |  |  |  |  | 4 | id     => $common_template->{'id'}, | 
| 70 |  |  |  |  |  |  | raw    => {}, | 
| 71 |  |  |  |  |  |  | }; | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 1 |  |  |  |  | 5 | my $params          = sc_check_params( $tmpl, \%args ); | 
| 74 | 1 |  |  |  |  | 3 | my $raw             = delete( $params->{'raw'} ); | 
| 75 | 1 |  |  |  |  | 3 | my $notification_id = delete( $params->{'id'} ); | 
| 76 | 1 |  |  |  |  | 4 | my $notification    = $self->client->get( "/notification/$notification_id", $params ); | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 1 | 50 |  |  |  | 3 | return               if ( !$notification ); | 
| 79 | 1 | 50 |  |  |  | 5 | return $notification if ($raw); | 
| 80 | 1 |  |  |  |  | 3 | return sc_normalize_hash($notification); | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | #------------------------------------------------------------------------------- | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | 1; | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | __END__ |