| 1 | package WWW::Google::Contacts::Contact; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 17 | $WWW::Google::Contacts::Contact::VERSION = '0.39'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use MooseX::Types::Moose qw( Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use WWW::Google::Contacts::Types qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | Category | ||||||||||||||||||||||||||||
| 10 | Name | ||||||||||||||||||||||||||||
| 11 | PhoneNumber ArrayRefOfPhoneNumber | ||||||||||||||||||||||||||||
| 12 | Email ArrayRefOfEmail | ||||||||||||||||||||||||||||
| 13 | IM ArrayRefOfIM | ||||||||||||||||||||||||||||
| 14 | Organization ArrayRefOfOrganization | ||||||||||||||||||||||||||||
| 15 | PostalAddress ArrayRefOfPostalAddress | ||||||||||||||||||||||||||||
| 16 | CalendarLink ArrayRefOfCalendarLink | ||||||||||||||||||||||||||||
| 17 | Birthday | ||||||||||||||||||||||||||||
| 18 | ContactEvent ArrayRefOfContactEvent | ||||||||||||||||||||||||||||
| 19 | ExternalId ArrayRefOfExternalId | ||||||||||||||||||||||||||||
| 20 | Gender | ||||||||||||||||||||||||||||
| 21 | GroupMembership ArrayRefOfGroupMembership | ||||||||||||||||||||||||||||
| 22 | Hobby ArrayRefOfHobby | ||||||||||||||||||||||||||||
| 23 | Jot ArrayRefOfJot | ||||||||||||||||||||||||||||
| 24 | Language ArrayRefOfLanguage | ||||||||||||||||||||||||||||
| 25 | Priority | ||||||||||||||||||||||||||||
| 26 | Sensitivity | ||||||||||||||||||||||||||||
| 27 | Relation ArrayRefOfRelation | ||||||||||||||||||||||||||||
| 28 | UserDefined ArrayRefOfUserDefined | ||||||||||||||||||||||||||||
| 29 | Website ArrayRefOfWebsite | ||||||||||||||||||||||||||||
| 30 | Photo | ||||||||||||||||||||||||||||
| 31 | 17 | ); | |||||||||||||||||||||||||||
| 32 | 17 | ▶ | use WWW::Google::Contacts::Meta::Attribute::Trait::XmlField; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 17 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub create_url { | ||||||||||||||||||||||||||
|
Subroutine
create_url: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | 0 | return sprintf( "%s://www.google.com/m8/feeds/contacts/default/full", | |||||||||||||||||||||||||||
| 38 | $self->server->protocol ); | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 17 | extends 'WWW::Google::Contacts::Base'; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 17 | with 'WWW::Google::Contacts::Roles::CRUD'; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 17 | has id => ( | |||||||||||||||||||||||||||
| 46 | isa => Str, | ||||||||||||||||||||||||||||
| 47 | is => 'ro', | ||||||||||||||||||||||||||||
| 48 | writer => '_set_id', | ||||||||||||||||||||||||||||
| 49 | predicate => 'has_id', | ||||||||||||||||||||||||||||
| 50 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 51 | xml_key => 'id', | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | has etag => ( | ||||||||||||||||||||||||||||
| 55 | isa => Str, | ||||||||||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||||||||||
| 57 | writer => '_set_etag', | ||||||||||||||||||||||||||||
| 58 | predicate => 'has_etag', | ||||||||||||||||||||||||||||
| 59 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 60 | xml_key => 'gd:etag', | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | include_in_xml => sub { 0 }, # This is set in HTTP headers | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 62 | 17 | ); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | has link => ( | ||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||
| 66 | trigger => \&_set_link, | ||||||||||||||||||||||||||||
| 67 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 68 | xml_key => 'link', | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | include_in_xml => sub { 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 70 | 17 | ); | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # What to do with different link types | ||||||||||||||||||||||||||||
| 73 | my $link_map = { | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | 'self' => sub { my ( $self, $link ) = @_; $self->_set_id( $link->{href} ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | 'http://schemas.google.com/contacts/2008/rel#photo' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 76 | 0 | my ( $self, $link ) = @_; | |||||||||||||||||||||||||||
| 77 | 0 | $self->photo( { %$link, server => $self->server } ); | |||||||||||||||||||||||||||
| 78 | }, | ||||||||||||||||||||||||||||
| 79 | 17 | }; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub _set_link { | ||||||||||||||||||||||||||
|
Subroutine
_set_link: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 82 | 0 | my ( $self, $links ) = @_; | |||||||||||||||||||||||||||
| 83 | 0 | foreach my $link ( @{$links} ) { | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | next unless ( defined $link_map->{ $link->{rel} } ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | my $code = $link_map->{ $link->{rel} }; | |||||||||||||||||||||||||||
| 86 | 0 | $self->$code($link); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 17 | has photo => ( | |||||||||||||||||||||||||||
| 91 | isa => Photo, | ||||||||||||||||||||||||||||
| 92 | is => 'rw', | ||||||||||||||||||||||||||||
| 93 | coerce => 1, | ||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | has category => ( | ||||||||||||||||||||||||||||
| 97 | isa => Category, | ||||||||||||||||||||||||||||
| 98 | is => 'rw', | ||||||||||||||||||||||||||||
| 99 | predicate => 'has_category', | ||||||||||||||||||||||||||||
| 100 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 101 | xml_key => 'category', | ||||||||||||||||||||||||||||
| 102 | 3 | ▶ | default => sub { undef }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 103 | 17 | coerce => 1, | |||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 17 | has notes => ( | |||||||||||||||||||||||||||
| 107 | isa => Str, | ||||||||||||||||||||||||||||
| 108 | is => 'rw', | ||||||||||||||||||||||||||||
| 109 | predicate => 'has_notes', | ||||||||||||||||||||||||||||
| 110 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 111 | xml_key => 'content', | ||||||||||||||||||||||||||||
| 112 | is_element => 1, | ||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | has name => ( | ||||||||||||||||||||||||||||
| 116 | isa => Name, | ||||||||||||||||||||||||||||
| 117 | is => 'rw', | ||||||||||||||||||||||||||||
| 118 | predicate => 'has_name', | ||||||||||||||||||||||||||||
| 119 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 120 | xml_key => 'gd:name', | ||||||||||||||||||||||||||||
| 121 | handles => [ | ||||||||||||||||||||||||||||
| 122 | qw( given_name additional_name family_name | ||||||||||||||||||||||||||||
| 123 | name_prefix name_suffix full_name ) | ||||||||||||||||||||||||||||
| 124 | ], | ||||||||||||||||||||||||||||
| 125 | 3 | ▶ | default => sub { undef }, # empty Name object, so handles will work | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 126 | 17 | coerce => 1, | |||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 17 | has phone_number => ( | |||||||||||||||||||||||||||
| 130 | isa => ArrayRefOfPhoneNumber, | ||||||||||||||||||||||||||||
| 131 | is => 'rw', | ||||||||||||||||||||||||||||
| 132 | predicate => 'has_phone_number', | ||||||||||||||||||||||||||||
| 133 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 134 | xml_key => 'gd:phoneNumber', | ||||||||||||||||||||||||||||
| 135 | coerce => 1, | ||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 17 | has email => ( | |||||||||||||||||||||||||||
| 139 | isa => ArrayRefOfEmail, | ||||||||||||||||||||||||||||
| 140 | is => 'rw', | ||||||||||||||||||||||||||||
| 141 | predicate => 'has_email', | ||||||||||||||||||||||||||||
| 142 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 143 | xml_key => 'gd:email', | ||||||||||||||||||||||||||||
| 144 | coerce => 1, | ||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 17 | has im => ( | |||||||||||||||||||||||||||
| 148 | isa => ArrayRefOfIM, | ||||||||||||||||||||||||||||
| 149 | is => 'rw', | ||||||||||||||||||||||||||||
| 150 | predicate => 'has_im', | ||||||||||||||||||||||||||||
| 151 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 152 | xml_key => 'gd:im', | ||||||||||||||||||||||||||||
| 153 | coerce => 1, | ||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 17 | has organization => ( | |||||||||||||||||||||||||||
| 157 | isa => ArrayRefOfOrganization, | ||||||||||||||||||||||||||||
| 158 | is => 'rw', | ||||||||||||||||||||||||||||
| 159 | predicate => 'has_organization', | ||||||||||||||||||||||||||||
| 160 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 161 | xml_key => 'gd:organization', | ||||||||||||||||||||||||||||
| 162 | coerce => 1, | ||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 17 | has postal_address => ( | |||||||||||||||||||||||||||
| 166 | isa => ArrayRefOfPostalAddress, | ||||||||||||||||||||||||||||
| 167 | is => 'rw', | ||||||||||||||||||||||||||||
| 168 | predicate => 'has_postal_address', | ||||||||||||||||||||||||||||
| 169 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 170 | xml_key => 'gd:structuredPostalAddress', | ||||||||||||||||||||||||||||
| 171 | coerce => 1, | ||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 17 | has billing_information => ( | |||||||||||||||||||||||||||
| 175 | isa => Str, | ||||||||||||||||||||||||||||
| 176 | is => 'rw', | ||||||||||||||||||||||||||||
| 177 | predicate => 'has_billing_information', | ||||||||||||||||||||||||||||
| 178 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 179 | xml_key => 'gContact:billingInformation', | ||||||||||||||||||||||||||||
| 180 | is_element => 1, | ||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 17 | has birthday => ( | |||||||||||||||||||||||||||
| 184 | isa => Birthday, | ||||||||||||||||||||||||||||
| 185 | is => 'rw', | ||||||||||||||||||||||||||||
| 186 | predicate => 'has_birthday', | ||||||||||||||||||||||||||||
| 187 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 188 | xml_key => 'gContact:birthday', | ||||||||||||||||||||||||||||
| 189 | is_element => 1, | ||||||||||||||||||||||||||||
| 190 | coerce => 1, | ||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 17 | has calendar_link => ( | |||||||||||||||||||||||||||
| 194 | isa => ArrayRefOfCalendarLink, | ||||||||||||||||||||||||||||
| 195 | is => 'rw', | ||||||||||||||||||||||||||||
| 196 | predicate => 'has_calendar_link', | ||||||||||||||||||||||||||||
| 197 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 198 | xml_key => 'gContact:calendarLink', | ||||||||||||||||||||||||||||
| 199 | coerce => 1, | ||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 17 | has directory_server => ( | |||||||||||||||||||||||||||
| 203 | isa => Str, | ||||||||||||||||||||||||||||
| 204 | is => 'rw', | ||||||||||||||||||||||||||||
| 205 | predicate => 'has_directory_server', | ||||||||||||||||||||||||||||
| 206 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 207 | xml_key => 'gContact:directoryServer', | ||||||||||||||||||||||||||||
| 208 | is_element => 1, | ||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 17 | has event => ( | |||||||||||||||||||||||||||
| 212 | isa => ArrayRefOfContactEvent, | ||||||||||||||||||||||||||||
| 213 | is => 'rw', | ||||||||||||||||||||||||||||
| 214 | predicate => 'has_event', | ||||||||||||||||||||||||||||
| 215 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 216 | xml_key => 'gContact:event', | ||||||||||||||||||||||||||||
| 217 | coerce => 1, | ||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 17 | has external_id => ( | |||||||||||||||||||||||||||
| 221 | isa => ArrayRefOfExternalId, | ||||||||||||||||||||||||||||
| 222 | is => 'rw', | ||||||||||||||||||||||||||||
| 223 | predicate => 'has_external_id', | ||||||||||||||||||||||||||||
| 224 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 225 | xml_key => 'gContact:excternalId', | ||||||||||||||||||||||||||||
| 226 | coerce => 1, | ||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 17 | has gender => ( | |||||||||||||||||||||||||||
| 230 | isa => Gender, | ||||||||||||||||||||||||||||
| 231 | is => 'rw', | ||||||||||||||||||||||||||||
| 232 | predicate => 'has_gender', | ||||||||||||||||||||||||||||
| 233 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 234 | xml_key => 'gContact:gender', | ||||||||||||||||||||||||||||
| 235 | coerce => 1, | ||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 17 | has group_membership => ( | |||||||||||||||||||||||||||
| 239 | isa => ArrayRefOfGroupMembership, | ||||||||||||||||||||||||||||
| 240 | is => 'rw', | ||||||||||||||||||||||||||||
| 241 | predicate => 'has_group_membership', | ||||||||||||||||||||||||||||
| 242 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 243 | xml_key => 'gContact:groupMembershipInfo', | ||||||||||||||||||||||||||||
| 244 | coerce => 1, | ||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 17 | has hobby => ( | |||||||||||||||||||||||||||
| 248 | isa => ArrayRefOfHobby, | ||||||||||||||||||||||||||||
| 249 | is => 'rw', | ||||||||||||||||||||||||||||
| 250 | predicate => 'has_hobby', | ||||||||||||||||||||||||||||
| 251 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 252 | xml_key => 'gContact:hobby', | ||||||||||||||||||||||||||||
| 253 | coerce => 1, | ||||||||||||||||||||||||||||
| 254 | ); | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 17 | has initials => ( | |||||||||||||||||||||||||||
| 257 | isa => Str, | ||||||||||||||||||||||||||||
| 258 | is => 'rw', | ||||||||||||||||||||||||||||
| 259 | predicate => 'has_initials', | ||||||||||||||||||||||||||||
| 260 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 261 | xml_key => 'gContact:initials', | ||||||||||||||||||||||||||||
| 262 | is_element => 1, | ||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 17 | has jot => ( | |||||||||||||||||||||||||||
| 266 | isa => ArrayRefOfJot, | ||||||||||||||||||||||||||||
| 267 | is => 'rw', | ||||||||||||||||||||||||||||
| 268 | predicate => 'has_jot', | ||||||||||||||||||||||||||||
| 269 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 270 | xml_key => 'gContact:jot', | ||||||||||||||||||||||||||||
| 271 | coerce => 1, | ||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 17 | has language => ( | |||||||||||||||||||||||||||
| 275 | isa => ArrayRefOfLanguage, | ||||||||||||||||||||||||||||
| 276 | is => 'rw', | ||||||||||||||||||||||||||||
| 277 | predicate => 'has_language', | ||||||||||||||||||||||||||||
| 278 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 279 | xml_key => 'gContact:language', | ||||||||||||||||||||||||||||
| 280 | coerce => 1, | ||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 17 | has maiden_name => ( | |||||||||||||||||||||||||||
| 284 | isa => Str, | ||||||||||||||||||||||||||||
| 285 | is => 'rw', | ||||||||||||||||||||||||||||
| 286 | predicate => 'has_maiden_name', | ||||||||||||||||||||||||||||
| 287 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 288 | xml_key => 'gContact:maidenName', | ||||||||||||||||||||||||||||
| 289 | is_element => 1, | ||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 17 | has mileage => ( | |||||||||||||||||||||||||||
| 293 | isa => Str, | ||||||||||||||||||||||||||||
| 294 | is => 'rw', | ||||||||||||||||||||||||||||
| 295 | predicate => 'has_mileage', | ||||||||||||||||||||||||||||
| 296 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 297 | xml_key => 'gContact:mileage', | ||||||||||||||||||||||||||||
| 298 | is_element => 1, | ||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 17 | has nickname => ( | |||||||||||||||||||||||||||
| 302 | isa => Str, | ||||||||||||||||||||||||||||
| 303 | is => 'rw', | ||||||||||||||||||||||||||||
| 304 | predicate => 'has_nickname', | ||||||||||||||||||||||||||||
| 305 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 306 | xml_key => 'gContact:nickname', | ||||||||||||||||||||||||||||
| 307 | is_element => 1, | ||||||||||||||||||||||||||||
| 308 | ); | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 17 | has occupation => ( | |||||||||||||||||||||||||||
| 311 | isa => Str, | ||||||||||||||||||||||||||||
| 312 | is => 'rw', | ||||||||||||||||||||||||||||
| 313 | predicate => 'has_occupation', | ||||||||||||||||||||||||||||
| 314 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 315 | xml_key => 'gContact:occupation', | ||||||||||||||||||||||||||||
| 316 | is_element => 1, | ||||||||||||||||||||||||||||
| 317 | ); | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 17 | has priority => ( | |||||||||||||||||||||||||||
| 320 | isa => Priority, | ||||||||||||||||||||||||||||
| 321 | is => 'rw', | ||||||||||||||||||||||||||||
| 322 | predicate => 'has_priority', | ||||||||||||||||||||||||||||
| 323 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 324 | xml_key => 'gContact:priority', | ||||||||||||||||||||||||||||
| 325 | coerce => 1, | ||||||||||||||||||||||||||||
| 326 | ); | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 17 | has relation => ( | |||||||||||||||||||||||||||
| 329 | isa => ArrayRefOfRelation, | ||||||||||||||||||||||||||||
| 330 | is => 'rw', | ||||||||||||||||||||||||||||
| 331 | predicate => 'has_relation', | ||||||||||||||||||||||||||||
| 332 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 333 | xml_key => 'gContact:relation', | ||||||||||||||||||||||||||||
| 334 | coerce => 1, | ||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 17 | has sensitivity => ( | |||||||||||||||||||||||||||
| 338 | isa => Sensitivity, | ||||||||||||||||||||||||||||
| 339 | is => 'rw', | ||||||||||||||||||||||||||||
| 340 | predicate => 'has_sensitivity', | ||||||||||||||||||||||||||||
| 341 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 342 | xml_key => 'gContact:sensitivity', | ||||||||||||||||||||||||||||
| 343 | is_element => 1, | ||||||||||||||||||||||||||||
| 344 | coerce => 1, | ||||||||||||||||||||||||||||
| 345 | ); | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 17 | has shortname => ( | |||||||||||||||||||||||||||
| 348 | isa => Str, | ||||||||||||||||||||||||||||
| 349 | is => 'rw', | ||||||||||||||||||||||||||||
| 350 | predicate => 'has_shortname', | ||||||||||||||||||||||||||||
| 351 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 352 | xml_key => 'gContact:shortname', | ||||||||||||||||||||||||||||
| 353 | is_element => 1, | ||||||||||||||||||||||||||||
| 354 | ); | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 17 | has subject => ( | |||||||||||||||||||||||||||
| 357 | isa => Str, | ||||||||||||||||||||||||||||
| 358 | is => 'rw', | ||||||||||||||||||||||||||||
| 359 | predicate => 'has_subject', | ||||||||||||||||||||||||||||
| 360 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 361 | xml_key => 'gContact:subject', | ||||||||||||||||||||||||||||
| 362 | is_element => 1, | ||||||||||||||||||||||||||||
| 363 | ); | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 17 | has user_defined => ( | |||||||||||||||||||||||||||
| 366 | isa => ArrayRefOfUserDefined, | ||||||||||||||||||||||||||||
| 367 | is => 'rw', | ||||||||||||||||||||||||||||
| 368 | predicate => 'has_user_defined', | ||||||||||||||||||||||||||||
| 369 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 370 | xml_key => 'gContact:userDefinedField', | ||||||||||||||||||||||||||||
| 371 | coerce => 1, | ||||||||||||||||||||||||||||
| 372 | ); | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 17 | has website => ( | |||||||||||||||||||||||||||
| 375 | isa => ArrayRefOfWebsite, | ||||||||||||||||||||||||||||
| 376 | is => 'rw', | ||||||||||||||||||||||||||||
| 377 | predicate => 'has_website', | ||||||||||||||||||||||||||||
| 378 | traits => ['XmlField'], | ||||||||||||||||||||||||||||
| 379 | xml_key => 'gContact:website', | ||||||||||||||||||||||||||||
| 380 | coerce => 1, | ||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | # Stolen from Meta/Attribute/Native/MethodProvider/Array.pm, need coercion | ||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub add_phone_number { | ||||||||||||||||||||||||||
|
Subroutine
add_phone_number: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 385 | 0 | my ( $self, $phone ) = @_; | |||||||||||||||||||||||||||
| 386 | 0 | ▶ | $self->phone_number( [] ) unless $self->has_phone_number; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | 0 | push @{ $self->phone_number }, to_PhoneNumber($phone); | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 1 | ▶ | sub add_email { | ||||||||||||||||||||||||||
|
Subroutine
add_email: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 391 | 1 | my ( $self, $email ) = @_; | |||||||||||||||||||||||||||
| 392 | 1 | ▶ | $self->email( [] ) unless $self->has_email; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 1 | push @{ $self->email }, to_Email($email); | |||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | sub add_user_defined { | ||||||||||||||||||||||||||
|
Subroutine
add_user_defined: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 397 | 0 | my ( $self, $user_def ) = @_; | |||||||||||||||||||||||||||
| 398 | 0 | ▶ | $self->user_defined( [] ) unless $self->has_user_defined; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | push @{ $self->user_defined }, to_UserDefined($user_def); | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 0 | ▶ | sub add_event { | ||||||||||||||||||||||||||
|
Subroutine
add_event: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 403 | 0 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||
| 404 | 0 | ▶ | $self->event( [] ) unless $self->has_event; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | push @{ $self->event }, to_ContactEvent($event); | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 0 | ▶ | sub add_website { | ||||||||||||||||||||||||||
|
Subroutine
add_website: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 409 | 0 | my ( $self, $website ) = @_; | |||||||||||||||||||||||||||
| 410 | 0 | ▶ | $self->website( [] ) unless $self->has_website; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 0 | push @{ $self->website }, to_Website($website); | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub add_relation { | ||||||||||||||||||||||||||
|
Subroutine
add_relation: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 415 | 0 | my ( $self, $relation ) = @_; | |||||||||||||||||||||||||||
| 416 | 0 | ▶ | $self->relation( [] ) unless $self->has_relation; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 0 | push @{ $self->relation }, to_Relation($relation); | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub add_group_membership { | ||||||||||||||||||||||||||
|
Subroutine
add_group_membership: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 421 | 0 | my ( $self, $group ) = @_; | |||||||||||||||||||||||||||
| 422 | 0 | ▶ | $self->group_membership( [] ) unless $self->has_group_membership; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if ( not ref($group) and $group !~ m{^http} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $group or $group =~ /^http/
MC/DC0%0/2
ref $group or $group =~ /^http/
ref $group
$group =~ /^http/
Truth table0%0/3
A or B
A= ref $groupB= $group =~ /^http/
| |||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | # It's probably a group name. | ||||||||||||||||||||||||||||
| 426 | # As it stands right now, can't deal with this in the coercion, need access to server obj | ||||||||||||||||||||||||||||
| 427 | 0 | my @groups = | |||||||||||||||||||||||||||
| 428 | WWW::Google::Contacts::GroupList->new( server => $self->server ) | ||||||||||||||||||||||||||||
| 429 | ->search( { title => $group } ); | ||||||||||||||||||||||||||||
| 430 | 0 | ▶ | if ( scalar @groups == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 431 | 0 | croak "Can not find a group with name: $group"; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | elsif ( scalar @groups > 1 ) { | ||||||||||||||||||||||||||||
| 434 | 0 | croak | |||||||||||||||||||||||||||
| 435 | "Can not add group membership. Found several groups with group name: $group"; | ||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | 0 | $group = shift @groups; | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | 0 | push @{ $self->group_membership }, to_GroupMembership($group); | |||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub groups { | ||||||||||||||||||||||||||
|
Subroutine
groups: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 443 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | my $to_ret = []; | |||||||||||||||||||||||||||
| 446 | 0 | ▶ | my $membership = $self->group_membership || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->group_membership || []
MC/DC0%0/1
$self->group_membership || []
$self->group_membership
Truth table0%0/2
A
A= $self->group_membership
| |||||||||||||||||||||||||||||
| 447 | 0 | foreach my $member ( @{$membership} ) { | |||||||||||||||||||||||||||
| 448 | 0 | push @{$to_ret}, | |||||||||||||||||||||||||||
| 449 | WWW::Google::Contacts::Group->new( | ||||||||||||||||||||||||||||
| 450 | id => $member->href, | ||||||||||||||||||||||||||||
| 451 | server => $self->server | ||||||||||||||||||||||||||||
| 452 | )->retrieve; | ||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | 0 | ▶ | return wantarray ? @{$to_ret} : $to_ret; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 17 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 458 | 17 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 459 | 17 | 1; | |||||||||||||||||||||||||||
| 460 | __END__ | ||||||||||||||||||||||||||||