File Coverage

blib/lib/Elive/Entity/ServerParameters.pm
Criterion Covered Total %
statement 12 35 34.2
branch 0 8 0.0
condition 0 6 0.0
subroutine 4 9 44.4
pod 4 4 100.0
total 20 62 32.2


line stmt bran cond sub pod time code
1             package Elive::Entity::ServerParameters;
2 1     1   778 use warnings; use strict;
  1     1   2  
  1         34  
  1         5  
  1         2  
  1         32  
3              
4 1     1   4 use Mouse;
  1         2  
  1         8  
5 1     1   349 use Mouse::Util::TypeConstraints;
  1         2  
  1         8  
6              
7             extends 'Elive::Entity';
8              
9             __PACKAGE__->entity_name('ServerParameters');
10             __PACKAGE__->_isa('Meeting');
11              
12             coerce 'Elive::Entity::ServerParameters' => from 'HashRef'
13             => via {Elive::Entity::ServerParameters->new($_) };
14              
15             has 'meetingId' => (is => 'rw', isa => 'Int', required => 1,
16             documentation => 'associated meeting');
17             __PACKAGE__->primary_key('meetingId');
18              
19             has 'seats' => (is => 'rw', isa => 'Int',
20             documentation => 'Number of available seats');
21             __PACKAGE__->_alias(requiredSeats => 'seats');
22              
23             has 'boundaryMinutes' => (is => 'rw', isa => 'Int',
24             documentation => 'meeting boundary time (minutes)');
25             __PACKAGE__->_alias(boundary => 'boundaryMinutes', freeze => 1);
26             __PACKAGE__->_alias(boundaryTime => 'boundaryMinutes'); # v 9.5.0 +
27              
28             has 'fullPermissions' => (is => 'rw', isa => 'Bool', required => 1,
29             documentation => 'whether participants can perform activities (e.g. use whiteboard) before the supervisor arrives');
30             __PACKAGE__->_alias(permissionsOn => 'fullPermissions', freeze => 1);
31             __PACKAGE__->_alias(permissions => 'fullPermissions');
32              
33             has 'supervised' => (is => 'rw', isa => 'Bool',
34             documentation => 'whether the moderator can see private messages');
35              
36             has 'enableTelephony'
37             => (is => 'rw', isa => 'Bool',
38             documentation => 'Telephony is enabled');
39              
40             has 'telephonyType'
41             => (is => 'rw', isa => 'Str',
42             documentation => 'Can be either SIP/PHONE.' );
43              
44             has 'moderatorTelephonyAddress'
45             => (is => 'rw', isa => 'Str',
46             documentation => 'Either a PHONE number or SIP address for the moderator for telephone');
47              
48             has 'moderatorTelephonyPIN'
49             => (is => 'rw', isa => 'Str',
50             documentation => 'PIN for moderator telephony');
51              
52             has 'participantTelephonyAddress'
53             => (is => 'rw', isa => 'Str',
54             documentation => 'Either a PHONE number or SIP address for the participants for telephone');
55              
56             has 'participantTelephonyPIN'
57             => (is => 'rw', isa => 'Str',
58             documentation => 'PIN for participants telephony');
59              
60             has 'serverTelephonyAddress'
61             => (is => 'rw', isa => 'Str',
62             documentation => 'Either a PHONE number or SIP address for the server');
63              
64             has 'serverTelephonyPIN'
65             => (is => 'rw', isa => 'Str',
66             documentation => 'PIN for the server');
67              
68             has 'serverTelephonyAddress'
69             => (is => 'rw', isa => 'Str',
70             documentation => 'Either a PHONE number or SIP address for the server');
71              
72             has 'redirectURL' => (is => 'rw', isa => 'Str',
73             documentation => 'URL to redirect users to after the online session is over.');
74              
75             ## Mispellings in toolkit - Required to support Elm 3.0 / Elive 9.5.0
76             __PACKAGE__->_alias(ModertatorTelephonyAddress => 'ModeratorTelephonyAddress');
77             __PACKAGE__->_alias(ModertatorTelephonyPIN => 'ModeratorTelephonyPIN');
78              
79             =head1 NAME
80              
81             Elive::Entity::ServerParameters - Meeting server parameters entity class
82              
83             =head1 SYNOPSIS
84              
85             Note: the C and C methods are depreciated. For alternatives
86             please see L.
87              
88             my $meeting = Elive::Entity::Meeting->insert( \%meeting_data );
89             my $server_params $meeting->server_parameters;
90              
91             $server_params->update({
92             boundaryMinutes => 15,
93             fullPermissions => 0,
94             supervised => 1,
95             enableTelephony => 0,
96             seats => 18,
97             });
98              
99             =head1 DESCRIPTION
100              
101             The server parameters entity contains additional meeting options.
102              
103             =cut
104              
105             =head1 METHODS
106              
107             =cut
108              
109             =head2 retrieve
110              
111             my $server_paremeters = Elive::Entity::ServerParameters->retrieve($meeting_id);
112              
113             Retrieves the server parameters for a meeting.
114              
115             =cut
116              
117             =head2 insert
118              
119             The insert method is not applicable. The meeting server parameters entity
120             is automatically created when you create a meeting.
121              
122             =cut
123              
124 0     0 1   sub insert {return shift->_not_available}
125              
126             =head2 delete
127              
128             The delete method is not applicable. meeting server parameters are deleted
129             when the meeting itself is deleted.
130              
131             =cut
132              
133 0     0 1   sub delete {return shift->_not_available}
134              
135             =head2 list
136              
137             The list method is not available for meeting parameters.
138              
139             =cut
140              
141 0     0 1   sub list {return shift->_not_available}
142              
143             =head2 update
144              
145             my $server_parameters
146             = Elive::Entity::ServerParameters->fetch([$meeting_id]);
147              
148             $server_parameters->update({
149             boundaryMinutes => 15,
150             fullPermissions => 1,
151             supervised => 1,
152             });
153              
154             Updates the meeting boundary times, permissions and whether the meeting is
155             supervised.
156              
157             =cut
158              
159             sub update {
160 0     0 1   my ($self, $update_data, %opt) = @_;
161              
162 0 0         $self->set( %$update_data)
163             if (keys %$update_data);
164             #
165             # Command Toolkit seems to require a setting for fullPermissions (aka
166             # permissionsOn); always pass it through.
167             #
168 0           my @required = qw/boundaryMinutes fullPermissions supervised/;
169 0           my %changed;
170 0           @changed{@required, $self->is_changed} = undef;
171              
172 0           foreach (@required) {
173 0 0         die "missing required property: $_"
174             unless defined $self->{$_};
175             }
176              
177             #
178             # direct changes to seats are ignored. This needs to be intercepted
179             # and routed to the updateMeeting command.
180             #
181 0 0         if (exists $changed{seats}) {
182 0           delete $changed{seats};
183              
184 0           my $meeting_params = Elive::Entity::Meeting->_freeze({
185             meetingId => $self,
186             seats => $self->seats,
187             });
188              
189 0   0       my $connection = $opt{connection} || $self->connection;
190              
191 0           my $som = $connection->call(updateMeeting => %$meeting_params);
192 0           $connection->_check_for_errors($som);
193             }
194             #
195             # This command barfs if we don't write values back, whether they've
196             # changed or not.
197             #
198 0           return $self->SUPER::update(undef, %opt, changed => [sort keys %changed]);
199             }
200              
201             #
202             # elm 3.x may throw back a complex type for telephonyType, something like:
203             # {Name: 'PHONE', Ordinal: 1, TelephonyType: 1}. Dereference this, when it
204             # happens, to obtain the underlying database value 'PHONE'.
205             #
206              
207             sub _thaw {
208 0     0     my ($class, $db_data, @args) = @_;
209 0           my $thawed = $class->SUPER::_thaw($db_data, @args);
210              
211 0           my $telephonyType = $thawed->{telephonyType};
212 0 0 0       if (Elive::Util::_reftype($telephonyType) eq 'HASH'
213             && (my $name = $telephonyType->{Name})) {
214 0           $thawed->{telephonyType} = $name;
215             }
216              
217 0           return $thawed;
218             }
219              
220             =head1 See Also
221              
222             L
223              
224             =cut
225              
226             1;