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)


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

def all_day
  @all_day
end

#attendeesArray<TimeTree::User>

Returns:



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

def attendees
  @attendees
end

#calendar_idString

calendar’s id.

Returns:

  • (String)


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

def calendar_id
  @calendar_id
end

#categoryStriing

Returns:

  • (Striing)


7
8
9
# File 'lib/timetree/models/event.rb', line 7

def category
  @category
end

#created_atTime

Returns:

  • (Time)


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

def created_at
  @created_at
end

#creatorTimeTree::User (readonly)

Returns:



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

def creator
  @creator
end

#descriptionString

Returns:

  • (String)


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

def description
  @description
end

#end_atTime

Returns:

  • (Time)


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

def end_at
  @end_at
end

#end_timezoneString

Returns:

  • (String)


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

def end_timezone
  @end_timezone
end

#labelTimeTree::Label

Returns:



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

def label
  @label
end

#locationString

Returns:

  • (String)


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

def location
  @location
end

#recurrenceArray<String>

Returns:

  • (Array<String>)


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

def recurrence
  @recurrence
end

#recurring_uuidString

Returns:

  • (String)


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

def recurring_uuid
  @recurring_uuid
end

#start_atTime

Returns:

  • (Time)


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

def start_at
  @start_at
end

#start_timezoneStriing

Returns:

  • (Striing)


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

def start_timezone
  @start_timezone
end

#titleStriing

Returns:

  • (Striing)


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

def title
  @title
end

#updated_atTime

Returns:

  • (Time)


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

def updated_at
  @updated_at
end

#urlString

Returns:

  • (String)


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

def url
  @url
end

Instance Method Details

#createTimeTree::Event

Creates an event to the associated calendar.

Returns:

Raises:

Since:

  • 0.0.1



55
56
57
58
# File 'lib/timetree/models/event.rb', line 55

def create
  check_client
  @client.create_event calendar_id, data_params
end

#create_comment(message) ⇒ TimeTree::Activity

Creates comment to the event.

Returns:

Raises:

Since:

  • 0.0.1



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

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



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

#deletetrue

Deletes the event.

Returns:

  • (true)

    if the operation succeeded.

Raises:

Since:

  • 0.0.1



79
80
81
82
# File 'lib/timetree/models/event.rb', line 79

def delete
  check_client
  @client.delete_event calendar_id, id
end

#updateTimeTree::Event

Updates the event.

Returns:

Raises:

Since:

  • 0.0.1



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