Elive

 view release on metacpan or  search on metacpan

lib/Elive/Entity/Session.pm  view on Meta::CPAN

	facilitatorId => Elive->login->userId,
	password => 'secret',
	start => $session_start,
	end => $session_end,
        restricted => 1,
	privateMeeting => 1,
	recordingStatus => 'remote',
	maxTalkers => 2,
	boundaryMinutes => 15,
	fullPermissions => 1,
	supervised => 1,
	seats => 10,
        participants => [
            -moderators => [qw(alice bob)],
            -others => '*staff_group'
         ],
        add_preload => $preload,
    );

    my $session = Elive::Entity::Session->insert( \%session_data );

=cut

sub insert {
    my $class = shift;
    my %data = %{ shift() };
    my %opt = @_;

    my $connection = $opt{connection} || $class->connection
	or die "not connected";

    my $participants = Elive::Entity::Participants->new( $data{participants} );

    $data{facilitatorId} ||= $connection->login->userId;
    my $facilitatorId = $data{facilitatorId};

    $participants->add(-moderators => $facilitatorId);
    #
    # our freeze method breaks this down into guests, moderator and
    # participants. Pass the participants as well, just for the readback
    #
    $data{participants} = $participants->tidied;

    my @objs = $class->SUPER::insert( \%data, command => 'createSession', %opt );
    return wantarray? @objs : $objs[0];
}

=head2 update

    $session->update({ boundaryTime => 15});

    # ...or...

    $session->boundaryTime(15);
    $session->update;

Updates session properties, using the C<updateSession> command.

=cut

sub update {
    my $self = shift;
    my %update_data = %{ shift() || {} };
    my %opt = @_;

    my $changed = $opt{changed} || [$ self->is_changed];

    if (@$changed || keys %update_data) {
	#
	# Early ELM 3.x has a habit of wiping defaults. We're better off
	# to rewrite the whole record
	#
	my @all_props =  map {$_->properties} values %{$self->_delegates};
		       
	$changed = [ grep {$_ ne 'meetingId'} @all_props ];

	my $connection = $opt{connection} || $self->connection;

	my $facilitatorId = $update_data{facilitatorId}
	|| $self->facilitatorId
	|| $connection->login->userId;

	my $participants = $update_data{participants}
	|| $self->participants;

	$participants = Elive::Entity::Participants->new( $participants )
	    unless Scalar::Util::blessed( $participants );

	$participants->add(-moderators => $facilitatorId);
	#
	# our freeze method breaks this down into guests, moderator and
	# participants. Pass the participants as well, just for the readback
	#
	$update_data{participants} = $participants->tidied;

	return $self->SUPER::update( \%update_data, %opt, changed => $changed );
    }

    return $self; # nothing to update
}

=head2 retrieve

Retrieves a session for the given session id.

    Elive::Entity::Session->retrieve( $session_id );

=cut

sub retrieve {
    my $class = shift;
    my $id = shift;
    my %opt = @_;

    ($id) = @$id
	if Elive::Util::_reftype($id) eq 'ARRAY';

    my $id_string = Elive::Util::string($id);
    die "nothing to retrieve" unless $id_string;

    my $connection = $opt{connection} || $class->connection



( run in 1.257 second using v1.01-cache-2.11-cpan-d8267643d1d )