| 1 | package Net::SecurityCenter::API::Notification; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use parent 'Net::SecurityCenter::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Net::SecurityCenter::Utils qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | our $VERSION = '0.310'; | |||||||||
| 11 | |||||||||||
| 12 | 2 | 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 | ▶ | my ( $self, %args ) = @_; | ||||||||
|
Subroutine
list: called CC=5 SCAR=19.3
Pod
documented
| |||||||||||
| 36 | |||||||||||
| 37 | my $tmpl = { | ||||||||||
| 38 | 1 | fields => $common_template->{'fields'}, | |||||||||
| 39 | timeframe => { | ||||||||||
| 40 | allow => [ '24h', '7d', '30d' ], | ||||||||||
| 41 | default => '24h' | ||||||||||
| 42 | }, | ||||||||||
| 43 | raw => {}, | ||||||||||
| 44 | }; | ||||||||||
| 45 | |||||||||||
| 46 | 1 | my $params = sc_check_params( $tmpl, \%args ); | |||||||||
| 47 | 1 | my $raw = delete( $params->{'raw'} ); | |||||||||
| 48 | |||||||||||
| 49 | 1 | my $notifications = $self->client->get( '/notification', $params ); | |||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | return if ( !$notifications ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 1 | ▶ | if ($raw) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | ▶ | return wantarray ? @{$notifications} : $notifications; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 1 | ▶ | return wantarray ? @{ sc_normalize_array($notifications) } : sc_normalize_array($notifications); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | #------------------------------------------------------------------------------- | ||||||||||
| 62 | |||||||||||
| 63 | sub get { | ||||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | my ( $self, %args ) = @_; | ||||||||
|
Subroutine
get: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | my $tmpl = { | ||||||||||
| 68 | fields => $common_template->{'fields'}, | ||||||||||
| 69 | 1 | id => $common_template->{'id'}, | |||||||||
| 70 | raw => {}, | ||||||||||
| 71 | }; | ||||||||||
| 72 | |||||||||||
| 73 | 1 | my $params = sc_check_params( $tmpl, \%args ); | |||||||||
| 74 | 1 | my $raw = delete( $params->{'raw'} ); | |||||||||
| 75 | 1 | my $notification_id = delete( $params->{'id'} ); | |||||||||
| 76 | 1 | my $notification = $self->client->get( "/notification/$notification_id", $params ); | |||||||||
| 77 | |||||||||||
| 78 | 1 | ▶ | return if ( !$notification ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 1 | ▶ | return $notification if ($raw); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 1 | return sc_normalize_hash($notification); | |||||||||
| 81 | |||||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | #------------------------------------------------------------------------------- | ||||||||||
| 85 | |||||||||||
| 86 | 2 | 1; | |||||||||
| 87 | |||||||||||
| 88 | __END__ | ||||||||||