Class: TimeTree::Event
Overview
Model for TimeTree event or keep.
Constant Summary
collapse
- TIME_FIELDS =
%i[start_at end_at updated_at created_at].freeze
- RELATIONSHIPS =
%i[creator label attendees].freeze
Instance Attribute Summary collapse
Attributes inherited from BaseModel
#id, #relationships, #type
Instance Method Summary
collapse
Methods inherited from BaseModel
#initialize, #inspect, to_model
Instance Attribute Details
#all_day ⇒ Boolean
11
12
13
|
# File 'lib/timetree/models/event.rb', line 11
def all_day
@all_day
end
|
43
44
45
|
# File 'lib/timetree/models/event.rb', line 43
def attendees
@attendees
end
|
#calendar_id ⇒ String
36
37
38
|
# File 'lib/timetree/models/event.rb', line 36
def calendar_id
@calendar_id
end
|
#category ⇒ Striing
7
8
9
|
# File 'lib/timetree/models/event.rb', line 7
def category
@category
end
|
#created_at ⇒ Time
33
34
35
|
# File 'lib/timetree/models/event.rb', line 33
def created_at
@created_at
end
|
39
40
41
|
# File 'lib/timetree/models/event.rb', line 39
def creator
@creator
end
|
#description ⇒ String
25
26
27
|
# File 'lib/timetree/models/event.rb', line 25
def description
@description
end
|
#end_at ⇒ Time
17
18
19
|
# File 'lib/timetree/models/event.rb', line 17
def end_at
@end_at
end
|
#end_timezone ⇒ String
19
20
21
|
# File 'lib/timetree/models/event.rb', line 19
def end_timezone
@end_timezone
end
|
41
42
43
|
# File 'lib/timetree/models/event.rb', line 41
def label
@label
end
|
#location ⇒ String
27
28
29
|
# File 'lib/timetree/models/event.rb', line 27
def location
@location
end
|
#recurrence ⇒ Array<String>
21
22
23
|
# File 'lib/timetree/models/event.rb', line 21
def recurrence
@recurrence
end
|
#recurring_uuid ⇒ String
23
24
25
|
# File 'lib/timetree/models/event.rb', line 23
def recurring_uuid
@recurring_uuid
end
|
#start_at ⇒ Time
13
14
15
|
# File 'lib/timetree/models/event.rb', line 13
def start_at
@start_at
end
|
#start_timezone ⇒ Striing
15
16
17
|
# File 'lib/timetree/models/event.rb', line 15
def start_timezone
@start_timezone
end
|
#title ⇒ Striing
9
10
11
|
# File 'lib/timetree/models/event.rb', line 9
def title
@title
end
|
#updated_at ⇒ Time
31
32
33
|
# File 'lib/timetree/models/event.rb', line 31
def updated_at
@updated_at
end
|
#url ⇒ String
29
30
31
|
# File 'lib/timetree/models/event.rb', line 29
def url
@url
end
|
Instance Method Details
Creates an event to the associated calendar.
55
56
57
58
|
# File 'lib/timetree/models/event.rb', line 55
def create
check_client
@client.create_event calendar_id, data_params
end
|
Creates comment to the event.
91
92
93
94
95
96
|
# File 'lib/timetree/models/event.rb', line 91
def (message)
check_client
params = { type: 'activity', attributes: { calendar_id: calendar_id, event_id: id, content: message } }
activity = to_model params
activity.create
end
|
#data_params ⇒ Hash
convert to a TimeTree request body format.
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/timetree/models/event.rb', line 103
def data_params
{
data: {
attributes: {
category: category,
title: title,
all_day: all_day,
start_at: start_at.iso8601,
start_timezone: start_timezone,
end_at: end_at.iso8601,
end_timezone: end_timezone,
description: description,
location: location,
url: url
},
relationships: relationships_params
}
}
end
|
#delete ⇒ true
79
80
81
82
|
# File 'lib/timetree/models/event.rb', line 79
def delete
check_client
@client.delete_event calendar_id, id
end
|
67
68
69
70
|
# File 'lib/timetree/models/event.rb', line 67
def update
check_client
@client.update_event calendar_id, id, data_params
end
|