Class: TimeTree::Event

Inherits:
BaseModel show all
Defined in:
lib/timetree/models/event.rb

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

Constructor Details

This class inherits a constructor from TimeTree::BaseModel

Instance Attribute Details

#all_dayBoolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/timetree/models/event.rb', line 13

def all_day
  @all_day
end

#attendeesArray<TimeTree::User>

Returns:



45
46
47
# File 'lib/timetree/models/event.rb', line 45

def attendees
  @attendees
end

#calendar_idString

calendar’s id.

Returns:

  • (String)


38
39
40
# File 'lib/timetree/models/event.rb', line 38

def calendar_id
  @calendar_id
end

#categoryStriing

Returns:

  • (Striing)


9
10
11
# File 'lib/timetree/models/event.rb', line 9

def category
  @category
end

#created_atTime

Returns:

  • (Time)


35
36
37
# File 'lib/timetree/models/event.rb', line 35

def created_at
  @created_at
end

#creatorTimeTree::User (readonly)

Returns:



41
42
43
# File 'lib/timetree/models/event.rb', line 41

def creator
  @creator
end

#descriptionString

Returns:

  • (String)


27
28
29
# File 'lib/timetree/models/event.rb', line 27

def description
  @description
end

#end_atTime

Returns:

  • (Time)


19
20
21
# File 'lib/timetree/models/event.rb', line 19

def end_at
  @end_at
end

#end_timezoneString

Returns:

  • (String)


21
22
23
# File 'lib/timetree/models/event.rb', line 21

def end_timezone
  @end_timezone
end

#labelTimeTree::Label

Returns:



43
44
45
# File 'lib/timetree/models/event.rb', line 43

def label
  @label
end

#locationString

Returns:

  • (String)


29
30
31
# File 'lib/timetree/models/event.rb', line 29

def location
  @location
end

#recurrenceArray<String>

Returns:

  • (Array<String>)


23
24
25
# File 'lib/timetree/models/event.rb', line 23

def recurrence
  @recurrence
end

#recurring_uuidString

Returns:

  • (String)


25
26
27
# File 'lib/timetree/models/event.rb', line 25

def recurring_uuid
  @recurring_uuid
end

#start_atTime

Returns:

  • (Time)


15
16
17
# File 'lib/timetree/models/event.rb', line 15

def start_at
  @start_at
end

#start_timezoneStriing

Returns:

  • (Striing)


17
18
19
# File 'lib/timetree/models/event.rb', line 17

def start_timezone
  @start_timezone
end

#titleStriing

Returns:

  • (Striing)


11
12
13
# File 'lib/timetree/models/event.rb', line 11

def title
  @title
end

#updated_atTime

Returns:

  • (Time)


33
34
35
# File 'lib/timetree/models/event.rb', line 33

def updated_at
  @updated_at
end

#urlString

Returns:

  • (String)


31
32
33
# File 'lib/timetree/models/event.rb', line 31

def url
  @url
end

Instance Method Details

#createTimeTree::Event

Creates an event to the associated calendar.

Returns:

Raises:

Since:

  • 0.0.1



57
58
59
60
# File 'lib/timetree/models/event.rb', line 57

def create
  check_client
  _create_event
end

#create_comment(message) ⇒ TimeTree::Activity

Creates comment to the event.

Returns:

Raises:

Since:

  • 0.0.1



93
94
95
96
97
98
# File 'lib/timetree/models/event.rb', line 93

def create_comment(message)
  check_client
  params = {type: 'activity', attributes: {calendar_id: calendar_id, event_id: id, content: message}}
  activity = to_model params
  activity.create
end

#data_paramsHash

convert to a TimeTree request body format.

Returns:

  • (Hash)

Since:

  • 0.0.1



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/timetree/models/event.rb', line 105

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

#deletetrue

Deletes the event.

Returns:

  • (true)

    if the operation succeeded.

Raises:

Since:

  • 0.0.1



81
82
83
84
# File 'lib/timetree/models/event.rb', line 81

def delete
  check_client
  _delete_event
end

#updateTimeTree::Event

Updates the event.

Returns:

Raises:

Since:

  • 0.0.1



69
70
71
72
# File 'lib/timetree/models/event.rb', line 69

def update
  check_client
  _update_event
end