File Coverage

blib/lib/Net/Duo/Admin/Group.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             # Representation of a single Duo group for the Admin API.
2             #
3             # This class wraps the Duo representation of a single Duo group, as returned
4             # by (for example) the Admin /groups REST endpoint.
5             #
6             # SPDX-License-Identifier: MIT
7              
8             package Net::Duo::Admin::Group 1.02;
9              
10 6     6   6926 use 5.014;
  6         22  
11 6     6   31 use strict;
  6         13  
  6         117  
12 6     6   28 use warnings;
  6         12  
  6         181  
13              
14 6     6   2459 use parent qw(Net::Duo::Object);
  6         1456  
  6         48  
15              
16             # Data specification for converting JSON into our object representation. See
17             # the Net::Duo::Object documentation for syntax information.
18             ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
19             sub _fields {
20             return {
21 13     13   109 desc => 'simple',
22             group_id => 'simple',
23             name => 'simple',
24             push_enabled => ['simple', 'boolean'],
25             sms_enabled => ['simple', 'boolean'],
26             status => 'simple',
27             voice_enabled => ['simple', 'boolean'],
28             };
29             }
30             ## use critic
31              
32             # Install our accessors.
33             Net::Duo::Admin::Group->install_accessors;
34              
35             # Override the create method to add the appropriate URI.
36             #
37             # $class - Class of object to create
38             # $duo - Net::Duo object to use to create the object
39             # $data_ref - Data for new object as a reference to a hash
40             #
41             # Returns: Newly-created object
42             # Throws: Net::Duo::Exception on any problem creating the object
43             sub create {
44 1     1 1 383 my ($class, $duo, $data_ref) = @_;
45 1         12 return $class->SUPER::create($duo, '/admin/v1/groups', $data_ref);
46             }
47              
48             # Delete the group from Duo. After this call, the object should be treated as
49             # read-only since it can no longer be usefully updated.
50             #
51             # $self - The Net::Duo::Admin::Group object to delete
52             #
53             # Returns: undef
54             # Throws: Net::Duo::Exception on any problem deleting the object
55             ## no critic (Subroutines::ProhibitBuiltinHomonyms)
56             sub delete {
57 1     1 1 3 my ($self) = @_;
58 1         8 $self->{_duo}->call_json('DELETE', "/admin/v1/groups/$self->{group_id}");
59 1         3 return;
60             }
61             ## use critic
62              
63             1;
64             __END__