| Net-Google-Calendar documentation | Contained in the Net-Google-Calendar distribution. |
Net::Google::Calendar::Person - a thin wrapper round XML::Atom::Person
A simple string value that can be used as a representation of this person.
Get or set the email of the person
Get or set the status of event attendee.
See:
http://code.google.com/apis/gdata/elements.html#gdAttendeeStatus
Takes or returns any of the values accepted, declined, invited, tentative.
Get or set the type of event attendee.
See:
http://code.google.com/apis/gdata/elements.html#gdAttendeeType
Takes or returns any of the values optional, required.
| Net-Google-Calendar documentation | Contained in the Net-Google-Calendar distribution. |
package Net::Google::Calendar::Person; use strict; use XML::Atom::Person; use base qw(XML::Atom::Person Net::Google::Calendar::Base); my %allowed = ( attendeeStatus => [qw(accepted declined invited tentative)], attendeeType => [qw(optional required)], rel => [qw(attendee organizer performer speaker)], );
sub new { my $class = shift; my %opts = @_; $opts{Version} = '1.0' unless exists $opts{Version}; my $self = $class->SUPER::new(%opts); $self->_initialize(); return $self; }
sub name { my $self = shift; return $self->_do('@valueString', @_); }
sub email { my $self = shift; $self->_do('@email', @_); }
sub attendee_status { my $self = shift; $self->_do('attendeeStatus', @_); }
sub attendee_type { my $self = shift; $self->_do('attendeeType', @_); }
sub rel { my $self = shift; $self->_do('@rel', @_); } sub _do { my $self = shift; my $name = shift; my $attr = ($name =~ s!^@!!); $name =~ s!^gd:!!; my $vals = $allowed{$name}; my $gd_ns = ''; # $self->{_gd_ns}; my $ns = (defined $vals)? "http://schemas.google.com/g/2005#event." : ""; if (@_) { my $new = shift; $new =~ s!^$ns!!; die "$new is not one of the allowed values for $name (".join(",", @$vals).")" unless !defined $vals || grep { $new eq $_ } @$vals; if ($attr) { #print "Setting attr $name to ${ns}${new}\n"; $self->set_attr($name, "${ns}${new}"); } else { #print "Setting child gd:$name to ${ns}${new}\n"; $self->set($gd_ns, "gd:${name}", '', { value => "${ns}${new}" }); } } my $val; if ($attr) { $val = $self->get_attr($name); } else { my $tmp = $self->_my_get($gd_ns, "gd:${name}"); if (defined $tmp) { $val = $tmp->getAttribute('value'); } # else { print "Failed to get gd:${name}\n"; } } $val =~ s!^$ns!! if defined $val; return $val; } 1;