class TimeTree::Calendar

Model for TimeTree calendar.

Constants

RELATIONSHIPS
TIME_FIELDS

Attributes

color[RW]

@return [String]

created_at[RW]

@return [Time]

description[RW]

@return [String]

image_url[RW]

@return [String]

name[RW]

@return [String]

order[RW]

@return [Integer]

Public Instance Methods

event(event_id) click to toggle source

Get the event's information.

@param event_id [String] event's id. @return [TimeTree::Event] @raise [TimeTree::Error] if @client, @id or the event_id arg is empty. @raise [TimeTree::ApiError] if the http response status will not success. @since 0.0.1

# File lib/timetree/models/calendar.rb, line 33
def event(event_id)
  check_client
  get_event(event_id)
end
labels() click to toggle source

Get a calendar's label information used in event.

@return [Array<TimeTree::Label>] @raise [TimeTree::Error] if @client or @id is empty. @raise [TimeTree::ApiError] if the http response status will not success. @since 0.0.1

# File lib/timetree/models/calendar.rb, line 75
def labels
  return @labels if defined? @labels

  check_client
  @labels = get_labels
end
members() click to toggle source

Get a calendar's member information.

@return [Array<TimeTree::User>] @raise [TimeTree::Error] if @client or @id is empty. @raise [TimeTree::ApiError] if the http response status will not success. @since 0.0.1

# File lib/timetree/models/calendar.rb, line 61
def members
  return @members if defined? @members

  check_client
  @members = get_members
end
upcoming_events(days: 7, timezone: 'UTC') click to toggle source

Get the events' information after a request date.

@param days [Integer] The number of days to get. @param timezone [String] Timezone. @return [Array<TimeTree::Event>] @raise [TimeTree::Error] if @client or @id is empty. @raise [TimeTree::ApiError] if the http response status will not success. @since 0.0.1

# File lib/timetree/models/calendar.rb, line 49
def upcoming_events(days: 7, timezone: 'UTC')
  check_client
  get_upcoming_event(days, timezone)
end

Private Instance Methods

get_event(event_id) click to toggle source
# File lib/timetree/models/calendar.rb, line 84
def get_event(event_id)
  if @client.is_a?(CalendarApp::Client)
    @client.event(event_id)
  else
    @client.event(id, event_id)
  end
end
get_labels() click to toggle source
# File lib/timetree/models/calendar.rb, line 108
def get_labels
  if @client.is_a?(CalendarApp::Client)
    raise Error.new 'CalendarApp does not support label api'
  else
    @client.calendar_labels(id)
  end
end
get_members() click to toggle source
# File lib/timetree/models/calendar.rb, line 100
def get_members
  if @client.is_a?(CalendarApp::Client)
    @client.calendar_members
  else
    @client.calendar_members(id)
  end
end
get_upcoming_event(days, timezone) click to toggle source
# File lib/timetree/models/calendar.rb, line 92
def get_upcoming_event(days, timezone)
  if @client.is_a?(CalendarApp::Client)
    @client.upcoming_events(days: days, timezone: timezone)
  else
    @client.upcoming_events(id, days: days, timezone: timezone)
  end
end