Class: Nylas::Event

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/nylas/event.rb

Overview

Structure to represent a the Event Schema.

Instance Attribute Summary collapse

Attributes included from Model

#api

Instance Method Summary collapse

Methods included from Model

#auth_method, #create, #destroy, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #save_all_attributes, #to_json, #update, #update_all_attributes

Instance Attribute Details

#notify_participantsObject

Returns the value of attribute notify_participants.



48
49
50
# File 'lib/nylas/event.rb', line 48

def notify_participants
  @notify_participants
end

Instance Method Details

#busy?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/nylas/event.rb', line 50

def busy?
  busy
end

#generate_ics(ical_uid: nil, method: nil, prodid: nil) ⇒ String

Generate an ICS file server-side, from an Event

Parameters:

  • ical_uid (String) (defaults to: nil)

    Unique identifier used events across calendaring systems

  • method (String) (defaults to: nil)

    Description of invitation and response methods for attendees

  • prodid (String) (defaults to: nil)

    Company-specific unique product identifier

Returns:

  • (String)

    String for writing directly into an ICS file

Raises:

  • (ArgumentError)


76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/nylas/event.rb', line 76

def generate_ics(ical_uid: nil, method: nil, prodid: nil)
  raise ArgumentError, "Cannot generate an ICS file for an event without a Calendar ID or when set" unless
    calendar_id && self.when

  payload = build_ics_event_payload(ical_uid, method, prodid)
  response = api.execute(
    method: :post,
    path: "#{resources_path}/to-ics",
    payload: JSON.dump(payload)
  )

  response[:ics]
end

#read_only?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/nylas/event.rb', line 54

def read_only?
  read_only
end

#rsvp(status, notify_participants:) ⇒ Object



65
66
67
68
69
# File 'lib/nylas/event.rb', line 65

def rsvp(status, notify_participants:)
  rsvp = Rsvp.new(api: api, status: status, notify_participants: notify_participants,
                  event_id: id, account_id: )
  rsvp.save
end

#saveObject



58
59
60
61
62
63
# File 'lib/nylas/event.rb', line 58

def save
  validate
  format_reminder_minutes

  super
end