Subject: | UserDefined - Doesn't handle multiple user defined fields |
A contact with more than one user defined field will fail with the
following error:
Attribute (key) is required at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Types.pm line 294
WWW::Google::Contacts::Types::__ANON__('HASH(0xaab0058)') called
at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeCoercion.pm
line 63
Moose::Meta::TypeCoercion::__ANON__('HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeCoercion.pm
line 97
Moose::Meta::TypeCoercion::coerce('Moose::Meta::TypeCoercion=HASH(0x9a9b6e0)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeConstraint.pm
line 90
Moose::Meta::TypeConstraint::coerce('Moose::Meta::TypeConstraint::Class=HASH(0x9a9afd0)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types.pm line 480
MooseX::Types::__ANON__('HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Types.pm line 300
WWW::Google::Contacts::Types::__ANON__('HASH(0xaab0058)') called
at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeCoercion.pm
line 63
Moose::Meta::TypeCoercion::__ANON__('HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeCoercion.pm
line 97
Moose::Meta::TypeCoercion::coerce('Moose::Meta::TypeCoercion=HASH(0x9a9b9d0)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi/Moose/Meta/TypeConstraint.pm
line 90
Moose::Meta::TypeConstraint::coerce('Moose::Meta::TypeConstraint::Parameterizable=HASH(0x9a9bc90)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm line 199
eval {...} called at
/usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm line 198
MooseX::Types::TypeDecorator::AUTOLOAD('MooseX::Types::TypeDecorator=HASH(0x962cf20)',
'HASH(0xaab0058)') called at accessor user_defined defined at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Contact.pm
line 365
WWW::Google::Contacts::Contact::user_defined('WWW::Google::Contacts::Contact=HASH(0xa12c020)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Base.pm line 78
WWW::Google::Contacts::Base::set_from_server('WWW::Google::Contacts::Contact=HASH(0xa12c020)',
'HASH(0xac396c0)') called at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Roles/List.pm
line 79
WWW::Google::Contacts::Roles::List::next('WWW::Google::Contacts::ContactList=HASH(0x960ed60)')
called at google_contact.pl line 13
at /usr/local/lib/perl5/site_perl/5.10.1/MooseX/Types/TypeDecorator.pm
line 201
MooseX::Types::TypeDecorator::AUTOLOAD('MooseX::Types::TypeDecorator=HASH(0x962cf20)',
'HASH(0xaab0058)') called at accessor user_defined defined at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Contact.pm
line 365
WWW::Google::Contacts::Contact::user_defined('WWW::Google::Contacts::Contact=HASH(0xa12c020)',
'HASH(0xaab0058)') called at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Base.pm line 78
WWW::Google::Contacts::Base::set_from_server('WWW::Google::Contacts::Contact=HASH(0xa12c020)',
'HASH(0xac396c0)') called at
/usr/local/lib/perl5/site_perl/5.10.1/WWW/Google/Contacts/Roles/List.pm
line 79
WWW::Google::Contacts::Roles::List::next('WWW::Google::Contacts::ContactList=HASH(0x960ed60)')
called at google_contact.pl line 13
The data for multiple user defined fields looks like this:
$VAR1 = {
'8:00 AM' => {
'value' => 'Birth Time'
},
'Cayman Brac, Cayman Islands' => {
'value' => 'Birth Place'
}
};
They keys and the values look switched to me.
Don't know if the coersion is doing the right thing for multiple
UserDefined fields. I think it should be an array of hashes.
class_type UserDefined,
{ class => 'WWW::Google::Contacts::Type::UserDefined' };
coerce UserDefined,
from HashRef,
via { WWW::Google::Contacts::Type::UserDefined->new( $_ ) };
I'm hoping to leverage this code for an iPhone app I'm writing, so it'd
be great to fix it! I spent about 3 hours on it and I couldn't figure
it out. I'm hoping it is an easy fix.
Thanks,
mb