-
Guillaume ROUSSE authoredGuillaume ROUSSE authored
Service.pm 989 B
package AccountManager::Service;
use strict;
use warnings;
use base 'AccountManager::DB::Object';
use List::MoreUtils qw(any);
__PACKAGE__->meta->setup(
table => 'services',
columns => [
id => { type => 'bigserial', not_null => 1 },
entityid => { type => 'varchar', length => 200, not_null => 1 },
displayname => { type => 'varchar', length => 500 },
contacts => { type => 'array' },
],
primary_key_columns => [ 'id' ],
unique_key => [ 'entityid' ],
);
sub print {
my ($self, $fd) = @_;
$fd = \*STDOUT unless $fd;
printf $fd
"Service ID=%s; entityid=%s; displayname=%s; contacts=%s\n",
$self->id(),
$self->entityid(),
$self->displayname() || '',
join(',', $self->contacts());
}
## Check if email address is a known contact
sub is_contact {
my ($self, $email) = @_;
$email = lc($email);
return any { $email eq lc($_) } $self->contacts();
}
1;