Class: Zm::Client::AppointmentJsnsBuilder
- Inherits:
-
Object
- Object
- Zm::Client::AppointmentJsnsBuilder
- Defined in:
- lib/zm/client/appointment/appointment_jsns_builder.rb
Overview
class for account appointment
Instance Method Summary collapse
- #attendees_to_jsns ⇒ Object
- #body_html_jsns ⇒ Object
- #body_text_jsns ⇒ Object
- #body_to_jsns ⇒ Object
- #comp_to_jsns ⇒ Object
- #end_at_jsns ⇒ Object
-
#initialize(appointment) ⇒ AppointmentJsnsBuilder
constructor
A new instance of AppointmentJsnsBuilder.
- #organizer_to_jsns ⇒ Object
- #recipients_to_jsns ⇒ Object
- #start_at_jsns ⇒ Object
- #time_format ⇒ Object
- #to_delete ⇒ Object
- #to_jsns ⇒ Object (also: #to_create)
- #to_update ⇒ Object
Constructor Details
#initialize(appointment) ⇒ AppointmentJsnsBuilder
Returns a new instance of AppointmentJsnsBuilder.
8 9 10 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 8 def initialize(appointment) @appointment = appointment end |
Instance Method Details
#attendees_to_jsns ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 85 def attendees_to_jsns @appointment.attendees.map do |attendee| { a: attendee.email, d: attendee.display_name, role: attendee.role, ptst: attendee.ptst, rsvp: attendee.rsvp }.reject { |_, v| v.nil? } end end |
#body_html_jsns ⇒ Object
66 67 68 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 66 def body_html_jsns { ct: 'text/html', content: { _content: @appointment.body.html } } end |
#body_text_jsns ⇒ Object
62 63 64 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 62 def body_text_jsns { ct: 'text/plain', content: { _content: @appointment.body.text } } end |
#body_to_jsns ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 53 def body_to_jsns [ { ct: 'multipart/alternative', mp: [body_text_jsns, body_html_jsns] } ] end |
#comp_to_jsns ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 70 def comp_to_jsns [ { allDay: @appointment.allDay, at: attendees_to_jsns, e: end_at_jsns, s: start_at_jsns, or: organizer_to_jsns, name: @appointment.name, fb: @appointment.fb, transp: @appointment.transp }.reject { |_, v| v.nil? } ] end |
#end_at_jsns ⇒ Object
97 98 99 100 101 102 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 97 def end_at_jsns { d: @appointment.end_at.strftime(time_format), tz: @appointment.timezone } end |
#organizer_to_jsns ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 111 def organizer_to_jsns return nil if @appointment.organizer.nil? { a: @appointment.organizer.email, d: @appointment.organizer.display_name }.reject { |_, v| v.nil? } end |
#recipients_to_jsns ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 43 def recipients_to_jsns @appointment.recipients.map do |recipient| { t: recipient.field, a: recipient.email, p: recipient.display_name }.reject { |_, v| v.nil? } end end |
#start_at_jsns ⇒ Object
104 105 106 107 108 109 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 104 def start_at_jsns { d: @appointment.start_at.strftime(time_format), tz: @appointment.timezone } end |
#time_format ⇒ Object
120 121 122 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 120 def time_format @time_format ||= @appointment.allDay ? '%Y%m%d' : '%Y%m%dT%H%M00' end |
#to_delete ⇒ Object
12 13 14 15 16 17 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 12 def to_delete { comp: 0, id: @appointment.id } end |
#to_jsns ⇒ Object Also known as: to_create
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 19 def to_jsns { m: { l: @appointment.l, su: @appointment.name, e: recipients_to_jsns, mp: body_to_jsns, inv: { comp: comp_to_jsns } } } end |
#to_update ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 35 def to_update jsns = to_jsns jsns[:comp] = 0 jsns[:id] = @appointment.id jsns[:m][:inv][:uid] = @appointment.uid jsns end |