Class: TimeTree::Calendar

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

Overview

Model for TimeTree calendar.

Constant Summary collapse

TIME_FIELDS =
%i[created_at].freeze
RELATIONSHIPS =
%i[labels members].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

#colorString

Returns:

  • (String)


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

def color
  @color
end

#created_atTime

Returns:

  • (Time)


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

def created_at
  @created_at
end

#descriptionString

Returns:

  • (String)


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

def description
  @description
end

#image_urlString

Returns:

  • (String)


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

def image_url
  @image_url
end

#nameString

Returns:

  • (String)


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

def name
  @name
end

#orderInteger

Returns:

  • (Integer)


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

def order
  @order
end

Instance Method Details

#event(event_id) ⇒ TimeTree::Event

Get the event’s information.

event’s id.

Parameters:

  • event_id (String)

Returns:

Raises:

Since:

  • 0.0.1



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

def event(event_id)
  check_client
  @client.event id, event_id
end

#labelsArray<TimeTree::Label>

Get a calendar’s label information used in event.

Returns:

Raises:

Since:

  • 0.0.1



73
74
75
76
77
78
# File 'lib/timetree/models/calendar.rb', line 73

def labels
  return @labels if defined? @labels

  check_client
  @labels = @client.calendar_labels id
end

#membersArray<TimeTree::User>

Get a calendar’s member information.

Returns:

Raises:

Since:

  • 0.0.1



59
60
61
62
63
64
# File 'lib/timetree/models/calendar.rb', line 59

def members
  return @members if defined? @members

  check_client
  @members = @client.calendar_members id
end

#upcoming_events(days: 7, timezone: 'UTC') ⇒ Array<TimeTree::Event>

Get the events’ information after a request date.

The number of days to get. Timezone.

Parameters:

  • days (Integer) (defaults to: 7)
  • timezone (String) (defaults to: 'UTC')

Returns:

Raises:

Since:

  • 0.0.1



47
48
49
50
# File 'lib/timetree/models/calendar.rb', line 47

def upcoming_events(days: 7, timezone: 'UTC')
  check_client
  @client.upcoming_events id, days: days, timezone: timezone
end