File Coverage

File:lib/WWW/Google/Contacts/Types.pm
Coverage:100.0%

linestmtbrancondsubpodtimecode
1package WWW::Google::Contacts::Types;
2
3
12
327
use MooseX::Types -declare =>
4    [ qw(
5            Category
6            Name
7            PhoneNumber ArrayRefOfPhoneNumber
8            Email ArrayRefOfEmail
9            IM ArrayRefOfIM
10            Organization ArrayRefOfOrganization
11            PostalAddress ArrayRefOfPostalAddress
12            CalendarLink ArrayRefOfCalendarLink
13            Birthday
14            ContactEvent ArrayRefOfContactEvent
15            ExternalId ArrayRefOfExternalId
16            Gender
17            GroupMembership ArrayRefOfGroupMembership
18            Hobby ArrayRefOfHobby
19            Jot ArrayRefOfJot
20            Language ArrayRefOfLanguage
21            Priority
22            Sensitivity
23            Relation ArrayRefOfRelation
24            UserDefined ArrayRefOfUserDefined
25            Website ArrayRefOfWebsite
26            Photo
27            Group
28
12
12
89
34
    ) ];
29
30
12
12
12
152
41
108
use MooseX::Types::Moose qw(Str HashRef ArrayRef Any Undef Bool);
31
32
12
12
12
194
51
206
use WWW::Google::Contacts::Type::Category;
33
12
12
12
229
50
217
use WWW::Google::Contacts::Type::Name;
34
12
12
12
378
51
204
use WWW::Google::Contacts::Type::PhoneNumber;
35
12
12
12
149
41
81
use WWW::Google::Contacts::Type::PhoneNumber;
36
12
12
12
200
51
214
use WWW::Google::Contacts::Type::Email;
37
12
12
12
143
46
80
use WWW::Google::Contacts::Type::Email;
38
12
12
12
195
46
202
use WWW::Google::Contacts::Type::IM;
39
12
12
12
229
50
213
use WWW::Google::Contacts::Type::Organization;
40
12
12
12
223
55
239
use WWW::Google::Contacts::Type::PostalAddress;
41
12
12
12
235
49
220
use WWW::Google::Contacts::Type::Birthday;
42
12
12
12
238
50
242
use WWW::Google::Contacts::Type::CalendarLink;
43
44
12
12
12
271
54
209
use WWW::Google::Contacts::Type::ContactEvent;
45
12
12
12
225
49
212
use WWW::Google::Contacts::Type::ExternalId;
46
12
12
12
282
52
239
use WWW::Google::Contacts::Type::Gender;
47
12
12
12
226
53
215
use WWW::Google::Contacts::Type::GroupMembership;
48
12
12
12
225
45
210
use WWW::Google::Contacts::Type::Hobby;
49
12
12
12
231
51
210
use WWW::Google::Contacts::Type::Jot;
50
12
12
12
225
48
211
use WWW::Google::Contacts::Type::Language;
51
12
12
12
248
47
207
use WWW::Google::Contacts::Type::Priority;
52
12
12
12
222
959
210
use WWW::Google::Contacts::Type::Relation;
53
12
12
12
227
50
211
use WWW::Google::Contacts::Type::UserDefined;
54
12
12
12
224
49
208
use WWW::Google::Contacts::Type::Website;
55
56class_type Group,
57    { class => 'WWW::Google::Contacts::Group' };
58
59coerce Group,
60    from HashRef,
61    via { require WWW::Google::Contacts::Group; WWW::Google::Contacts::Group->new( $_ ) };
62
63class_type Category,
64    { class => 'WWW::Google::Contacts::Type::Category' };
65
66coerce Category,
67    from Any,
68    via {
69        WWW::Google::Contacts::Type::Category->new(
70            type => 'http://schemas.google.com/g/2005#kind',
71            term => 'http://schemas.google.com/contact/2008#contact'
72        );
73    };
74
75class_type Name,
76    { class => 'WWW::Google::Contacts::Type::Name' };
77
78coerce Name,
79    from Str,
80    via { WWW::Google::Contacts::Type::Name->new( full_name => $_ ) },
81    from Any,
82    via { WWW::Google::Contacts::Type::Name->new( $_ || {} ) };
83
84class_type PhoneNumber,
85    { class => 'WWW::Google::Contacts::Type::PhoneNumber' };
86
87coerce PhoneNumber,
88    from HashRef,
89    via { WWW::Google::Contacts::Type::PhoneNumber->new( $_ ) },
90    from Str,
91    via { WWW::Google::Contacts::Type::PhoneNumber->new( type => "mobile", value => $_ ) };
92
93subtype ArrayRefOfPhoneNumber,
94    as ArrayRef[ PhoneNumber ];
95
96coerce ArrayRefOfPhoneNumber,
97    from ArrayRef,
98    via { return [ map { to_PhoneNumber( $_ ) } @{ $_ } ] },
99    from Any,
100    via { return [ to_PhoneNumber( $_ ) ] };
101
102class_type Email,
103    { class => 'WWW::Google::Contacts::Type::Email' };
104
105coerce Email,
106    from HashRef,
107    via { WWW::Google::Contacts::Type::Email->new( $_ ) },
108    from Str,
109    via { WWW::Google::Contacts::Type::Email->new( type => "home", value => $_ ) };
110
111subtype ArrayRefOfEmail,
112    as ArrayRef[ Email ];
113
114coerce ArrayRefOfEmail,
115    from ArrayRef,
116    via { [ map { to_Email( $_ ) } @{ $_ } ] },
117    from Any,
118    via { [ to_Email( $_ ) ] };
119
120class_type IM,
121    { class => 'WWW::Google::Contacts::Type::IM' };
122
123coerce IM,
124    from HashRef,
125    via { WWW::Google::Contacts::Type::IM->new( $_ ) },
126    from Str,
127    via { WWW::Google::Contacts::Type::IM->new( value => $_ ) };
128
129subtype ArrayRefOfIM,
130    as ArrayRef[ IM ];
131
132coerce ArrayRefOfIM,
133    from ArrayRef,
134    via { [ map { to_IM( $_ ) } @{ $_ } ] },
135    from Any,
136    via { [ to_IM( $_ ) ] };
137
138class_type Organization,
139    { class => 'WWW::Google::Contacts::Type::Organization' };
140
141coerce Organization,
142    from HashRef,
143    via { WWW::Google::Contacts::Type::Organization->new( $_ ) },
144    from Str,
145    via { WWW::Google::Contacts::Type::Organization->new( type => "work", name => $_ ) };
146
147subtype ArrayRefOfOrganization,
148    as ArrayRef[ Organization ];
149
150coerce ArrayRefOfOrganization,
151    from ArrayRef,
152    via { [ map { to_Organization( $_ ) } @{ $_ } ] },
153    from Any,
154    via { [ to_Organization( $_ ) ] };
155
156class_type PostalAddress,
157    { class => 'WWW::Google::Contacts::Type::PostalAddress' };
158
159coerce PostalAddress,
160    from HashRef,
161    via { WWW::Google::Contacts::Type::PostalAddress->new( $_ ) },
162    from Str,
163    via { WWW::Google::Contacts::Type::PostalAddress->new( type => "work", formatted => $_ ) };
164
165subtype ArrayRefOfPostalAddress,
166    as ArrayRef[ PostalAddress ];
167
168coerce ArrayRefOfPostalAddress,
169    from ArrayRef,
170    via { [ map { to_PostalAddress( $_ ) } @{ $_ } ] },
171    from Any,
172    via { [ to_PostalAddress( $_ ) ] };
173
174class_type Birthday,
175    { class => 'WWW::Google::Contacts::Type::Birthday' };
176
177coerce Birthday,
178    from Str,
179    via { WWW::Google::Contacts::Type::Birthday->new( when => $_ ) },
180    from HashRef,
181    via { WWW::Google::Contacts::Type::Birthday->new( $_ ) };
182
183class_type CalendarLink,
184    { class => 'WWW::Google::Contacts::Type::CalendarLink' };
185
186coerce CalendarLink,
187    from HashRef,
188    via { WWW::Google::Contacts::Type::CalendarLink->new( $_ ) },
189    from Str,
190    via { WWW::Google::Contacts::Type::CalendarLink->new( type => "home", href => $_ ) };
191
192subtype ArrayRefOfCalendarLink,
193    as ArrayRef[ CalendarLink ];
194
195coerce ArrayRefOfCalendarLink,
196    from ArrayRef,
197    via { [ map { to_CalendarLink( $_ ) } @{ $_ } ] },
198    from Any,
199    via { [ to_CalendarLink( $_ ) ] };
200
201class_type ContactEvent,
202    { class => 'WWW::Google::Contacts::Type::ContactEvent' };
203
204coerce ContactEvent,
205    from HashRef,
206    via { WWW::Google::Contacts::Type::ContactEvent->new( $_ ) };
207
208subtype ArrayRefOfContactEvent,
209    as ArrayRef[ ContactEvent ];
210
211coerce ArrayRefOfContactEvent,
212    from ArrayRef,
213    via { [ map { to_ContactEvent( $_ ) } @{ $_ } ] },
214    from Any,
215    via { [ to_ContactEvent( $_ ) ] };
216
217class_type ExternalId,
218    { class => 'WWW::Google::Contacts::Type::ExternalId' };
219
220coerce ExternalId,
221    from HashRef,
222    via { WWW::Google::Contacts::Type::ExternalId->new( $_ ) };
223
224subtype ArrayRefOfExternalId,
225    as ArrayRef[ ExternalId ];
226
227coerce ArrayRefOfExternalId,
228    from ArrayRef,
229    via { [ map { to_ExternalId( $_ ) } @{ $_ } ] },
230    from Any,
231    via { [ to_ExternalId( $_ ) ] };
232
233class_type Gender,
234    { class => 'WWW::Google::Contacts::Type::Gender' };
235
236coerce Gender,
237    from Str,
238    via { WWW::Google::Contacts::Type::Gender->new( value => $_ ) };
239
240class_type GroupMembership,
241    { class => 'WWW::Google::Contacts::Type::GroupMembership' };
242
243coerce GroupMembership,
244    from HashRef,
245    via { WWW::Google::Contacts::Type::GroupMembership->new( $_ ) },
246    from Str,
247    via { WWW::Google::Contacts::Type::GroupMembership->new( href => $_ ) },
248    from Group,
249    via { WWW::Google::Contacts::Type::GroupMembership->new( href => $_->id ) };
250
251subtype ArrayRefOfGroupMembership,
252    as ArrayRef[ GroupMembership ];
253
254coerce ArrayRefOfGroupMembership,
255    from ArrayRef,
256    via { [ map { to_GroupMembership( $_ ) } @{ $_ } ] },
257    from Any,
258    via { [ to_GroupMembership( $_ ) ] };
259
260class_type Hobby,
261    { class => 'WWW::Google::Contacts::Type::Hobby' };
262
263coerce Hobby,
264    from HashRef,
265    via { WWW::Google::Contacts::Type::Hobby->new( $_ ) },
266    from Str,
267    via { WWW::Google::Contacts::Type::Hobby->new( value => $_ ) };
268
269subtype ArrayRefOfHobby,
270    as ArrayRef[ Hobby ];
271
272coerce ArrayRefOfHobby,
273    from ArrayRef,
274    via { [ map { to_Hobby( $_ ) } @{ $_ } ] },
275    from Any,
276    via { [ to_Hobby( $_ ) ] };
277
278class_type Jot,
279    { class => 'WWW::Google::Contacts::Type::Jot' };
280
281coerce Jot,
282    from HashRef,
283    via { WWW::Google::Contacts::Type::Jot->new( $_ ) },
284    from Str,
285    via { WWW::Google::Contacts::Type::Jot->new( type => "home", value => $_ ) };
286
287subtype ArrayRefOfJot,
288    as ArrayRef[ Jot ];
289
290coerce ArrayRefOfJot,
291    from ArrayRef,
292    via { [ map { to_Jot( $_ ) } @{ $_ } ] },
293    from Any,
294    via { [ to_Jot( $_ ) ] };
295
296class_type Language,
297    { class => 'WWW::Google::Contacts::Type::Language' };
298
299coerce Language,
300    from HashRef,
301    via { WWW::Google::Contacts::Type::Language->new( $_ ) },
302    from Str,
303    via { WWW::Google::Contacts::Type::Language->new( value => $_ ) };
304
305subtype ArrayRefOfLanguage,
306    as ArrayRef[ Language ];
307
308coerce ArrayRefOfLanguage,
309    from ArrayRef,
310    via { [ map { to_Language( $_ ) } @{ $_ } ] },
311    from Any,
312    via { [ to_Language( $_ ) ] };
313
314class_type Priority,
315    { class => 'WWW::Google::Contacts::Type::Priority' };
316
317coerce Priority,
318    from Str,
319    via { WWW::Google::Contacts::Type::Priority->new( type => $_ ) };
320
321class_type Relation,
322    { class => 'WWW::Google::Contacts::Type::Relation' };
323
324coerce Relation,
325    from HashRef,
326    via { WWW::Google::Contacts::Type::Relation->new( $_ ) };
327
328subtype ArrayRefOfRelation,
329    as ArrayRef[ Relation ];
330
331coerce ArrayRefOfRelation,
332    from ArrayRef,
333    via { [ map { to_Relation( $_ ) } @{ $_ } ] },
334    from Any,
335    via { [ to_Relation( $_ ) ] };
336
337class_type UserDefined,
338    { class => 'WWW::Google::Contacts::Type::UserDefined' };
339
340coerce UserDefined,
341    from HashRef,
342    via { WWW::Google::Contacts::Type::UserDefined->new( $_ ) };
343
344subtype ArrayRefOfUserDefined,
345    as ArrayRef[ UserDefined ];
346
347coerce ArrayRefOfUserDefined,
348    from ArrayRef,
349    via { [ map { to_UserDefined( $_ ) } @{ $_ } ] },
350    from HashRef,
351    via {
352        my $ref = $_;
353        return [ to_UserDefined( $ref ) ] if ( defined $ref->{ key } );
354        [ map { to_UserDefined({ key => $_, value => $ref->{ $_ }{ value } }) } keys %{ $ref } ]
355    },
356    from Any,
357    via { [ to_UserDefined( $_ ) ] };
358
359class_type Website,
360    { class => 'WWW::Google::Contacts::Type::Website' };
361
362coerce Website,
363    from HashRef,
364    via { WWW::Google::Contacts::Type::Website->new( $_ ) },
365    from Str,
366    via { WWW::Google::Contacts::Type::Website->new( type => "home", value => $_ ) };
367
368subtype ArrayRefOfWebsite,
369    as ArrayRef[ Website ];
370
371coerce ArrayRefOfWebsite,
372    from ArrayRef,
373    via { [ map { to_Website( $_ ) } @{ $_ } ] },
374    from Any,
375    via { [ to_Website( $_ ) ] };
376
377class_type Photo,
378    { class => 'WWW::Google::Contacts::Photo' };
379
380coerce Photo,
381    from HashRef,
382    via { require WWW::Google::Contacts::Photo; WWW::Google::Contacts::Photo->new( $_ ) };