| 1 | package Net::Google::CalendarV3::Event; | ||
| 2 | $Net::Google::CalendarV3::Event::VERSION = '0.16'; | ||
| 3 | use Moose; | ||
| 4 | with 'Net::Google::CalendarV3::ToJson'; | ||
| 5 | use Kavorka qw(method multi); | ||
| 6 | use Try::Tiny; | ||
| 7 | use Net::Google::CalendarV3::Attendee; | ||
| 8 | use Net::Google::CalendarV3::Date; | ||
| 9 | use Net::Google::CalendarV3::Person; | ||
| 10 | use Types::Standard qw( Str Int ArrayRef Enum); | ||
| 11 | use Net::Google::CalendarV3::Types qw( CBool Person Attendee Date DateTime ); | ||
| 12 | |||
| 13 | has [ qw( kind etag creator organizer attendees created | ||
| 14 | endTimeUnspecified gadget | ||
| 15 | hangoutLink htmlLink iCalUID locked originalStartTime | ||
| 16 | privateCopy recurringEventId reminders source start end | ||
| 17 | updated | ||
| 18 | ) ], is => 'ro'; | ||
| 19 | has [ qw( anyoneCanAddSelf attendeesOmitted colorId description | ||
| 20 | extendedProperties guestsCanInviteOthers guestsCanSeeOtherGuests | ||
| 21 | id location recurrence sequence status summary | ||
| 22 | transparency visibility | ||
| 23 | ) ], is => 'rw'; | ||
| 24 | |||
| 25 | has '+kind' => default => 'calendar#event'; | ||
| 26 | |||
| 27 | has [ qw( +creator +organizer ) ], isa => Person, coerce => 1; | ||
| 28 | has '+attendees', isa => ArrayRef[Attendee], coerce => 1; | ||
| 29 | has [ qw( +anyoneCanAddSelf +attendeesOmitted | ||
| 30 | +guestsCanInviteOthers +guestsCanSeeOtherGuests | ||
| 31 | +locked +privateCopy | ||
| 32 | ) ], isa => CBool, coerce => 1; | ||
| 33 | |||
| 34 | has [qw( +start +end +originalStartTime )], isa => Date, coerce => 1, lazy => 1, builder => '_build_empty_date'; | ||
| 35 | method _build_empty_date { Net::Google::CalendarV3::Date->new } | ||
| 36 | |||
| 37 | has '+status', isa => Enum[qw(confirmed tentative cancelled)]; | ||
| 38 | has '+transparency', isa => Enum[qw(opaque transparent)]; | ||
| 39 | has '+visibility', isa => Enum[qw(default public private confidential)]; | ||
| 40 | |||
| 41 | # compatibility methods for Net::Google::Calendar::Entry | ||
| 42 | |||
| 43 | method uid { $self->id } | ||
| 44 | |||
| 45 | multi method title ($title) { | ||
| 46 | $self->summary($title); | ||
| 47 | } | ||
| 48 | |||
| 49 | multi method title () { | ||
| 50 | $self->summary; | ||
| 51 | } | ||
| 52 | |||
| 53 | multi method content ($content) { | ||
| 54 | $self->description($content); | ||
| 55 | } | ||
| 56 | |||
| 57 | multi method content () { | ||
| 58 | $self->description; | ||
| 59 | } | ||
| 60 | |||
| 61 | multi method when (DateTime $start, DateTime $end, CBool $is_all_day) { | ||
| 62 | $self->start->set($start, $is_all_day); | ||
| 63 | $self->end->set($end, $is_all_day); | ||
| 64 | } | ||
| 65 | |||
| 66 | multi method when () { | ||
| 67 | my ($start_dt, $start_all_day) = $self->start->get(); | ||
| 68 | my ($end_dt, $end_all_day) = $self->end->get(); | ||
| 69 | return ($start_dt, $end_dt, $start_all_day && $end_all_day); | ||
| 70 | } | ||
| 71 | |||
| 72 | =pod | ||
| 73 | { | ||
| 74 | "kind": "calendar#event", | ||
| 75 | "etag": etag, | ||
| 76 | "id": string, | ||
| 77 | "status": string, | ||
| 78 | "htmlLink": string, | ||
| 79 | "created": datetime, | ||
| 80 | "updated": datetime, | ||
| 81 | "summary": string, | ||
| 82 | "description": string, | ||
| 83 | "location": string, | ||
| 84 | "colorId": string, | ||
| 85 | "creator": { | ||
| 86 | "id": string, | ||
| 87 | "email": string, | ||
| 88 | "displayName": string, | ||
| 89 | "self": boolean | ||
| 90 | }, | ||
| 91 | "organizer": { | ||
| 92 | "id": string, | ||
| 93 | "email": string, | ||
| 94 | "displayName": string, | ||
| 95 | "self": boolean | ||
| 96 | }, | ||
| 97 | "start": { | ||
| 98 | "date": date, | ||
| 99 | "dateTime": datetime, | ||
| 100 | "timeZone": string | ||
| 101 | }, | ||
| 102 | "end": { | ||
| 103 | "date": date, | ||
| 104 | "dateTime": datetime, | ||
| 105 | "timeZone": string | ||
| 106 | }, | ||
| 107 | "endTimeUnspecified": boolean, | ||
| 108 | "recurrence": [ | ||
| 109 | string | ||
| 110 | ], | ||
| 111 | "recurringEventId": string, | ||
| 112 | "originalStartTime": { | ||
| 113 | "date": date, | ||
| 114 | "dateTime": datetime, | ||
| 115 | "timeZone": string | ||
| 116 | }, | ||
| 117 | "transparency": string, | ||
| 118 | "visibility": string, | ||
| 119 | "iCalUID": string, | ||
| 120 | "sequence": integer, | ||
| 121 | "attendees": [ | ||
| 122 | { | ||
| 123 | "id": string, | ||
| 124 | "email": string, | ||
| 125 | "displayName": string, | ||
| 126 | "organizer": boolean, | ||
| 127 | "self": boolean, | ||
| 128 | "resource": boolean, | ||
| 129 | "optional": boolean, | ||
| 130 | "responseStatus": string, | ||
| 131 | "comment": string, | ||
| 132 | "additionalGuests": integer | ||
| 133 | } | ||
| 134 | ], | ||
| 135 | "attendeesOmitted": boolean, | ||
| 136 | "extendedProperties": { | ||
| 137 | "private": { | ||
| 138 | (key): string | ||
| 139 | }, | ||
| 140 | "shared": { | ||
| 141 | (key): string | ||
| 142 | } | ||
| 143 | }, | ||
| 144 | "hangoutLink": string, | ||
| 145 | "gadget": { | ||
| 146 | "type": string, | ||
| 147 | "title": string, | ||
| 148 | "link": string, | ||
| 149 | "iconLink": string, | ||
| 150 | "width": integer, | ||
| 151 | "height": integer, | ||
| 152 | "display": string, | ||
| 153 | "preferences": { | ||
| 154 | (key): string | ||
| 155 | } | ||
| 156 | }, | ||
| 157 | "anyoneCanAddSelf": boolean, | ||
| 158 | "guestsCanInviteOthers": boolean, | ||
| 159 | "guestsCanModify": boolean, | ||
| 160 | "guestsCanSeeOtherGuests": boolean, | ||
| 161 | "privateCopy": boolean, | ||
| 162 | "locked": boolean, | ||
| 163 | "reminders": { | ||
| 164 | "useDefault": boolean, | ||
| 165 | "overrides": [ | ||
| 166 | { | ||
| 167 | "method": string, | ||
| 168 | "minutes": integer | ||
| 169 | } | ||
| 170 | ] | ||
| 171 | }, | ||
| 172 | "source": { | ||
| 173 | "url": string, | ||
| 174 | "title": string | ||
| 175 | } | ||
| 176 | } | ||
| 177 | =cut | ||
| 178 | |||
| 179 | 1; | ||
| 180 |