Class: Zm::Client::AppointmentJsnsBuilder

Inherits:
BaseAccountJsnsBuilder show all
Defined in:
lib/zm/client/appointment/appointment_jsns_builder.rb

Overview

class for account appointment

Instance Method Summary collapse

Methods inherited from BaseAccountJsnsBuilder

#build, #initialize, #to_color, #to_delete, #to_move, #to_patch, #to_rename, #to_tag, #to_trash

Constructor Details

This class inherits a constructor from Zm::Client::BaseAccountJsnsBuilder

Instance Method Details

#attendees_to_jsnsObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 73

def attendees_to_jsns
  @item.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_jsnsObject



54
55
56
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 54

def body_html_jsns
  { ct: ContentType::HTML, content: { _content: @item.body.html } }
end

#body_text_jsnsObject



50
51
52
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 50

def body_text_jsns
  { ct: ContentType::TEXT, content: { _content: @item.body.text } }
end

#body_to_jsnsObject



41
42
43
44
45
46
47
48
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 41

def body_to_jsns
  [
    {
      ct: ContentPart::ALTERNATIVE,
      mp: [body_text_jsns, body_html_jsns]
    }
  ]
end

#comp_to_jsnsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 58

def comp_to_jsns
  [
    {
      allDay: @item.allDay,
      at: attendees_to_jsns,
      e: end_at_jsns,
      s: start_at_jsns,
      or: organizer_to_jsns,
      name: @item.name,
      fb: @item.fb,
      transp: @item.transp
    }.reject { |_, v| v.nil? }
  ]
end

#end_at_jsnsObject



85
86
87
88
89
90
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 85

def end_at_jsns
  {
    d: @item.end_at.strftime(time_format),
    tz: @item.timezone
  }
end

#organizer_to_jsnsObject



99
100
101
102
103
104
105
106
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 99

def organizer_to_jsns
  return nil if @item.organizer.nil?

  {
    a: @item.organizer.email,
    d: @item.organizer.display_name
  }.reject { |_, v| v.nil? }
end

#recipients_to_jsnsObject



31
32
33
34
35
36
37
38
39
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 31

def recipients_to_jsns
  @item.recipients.map do |recipient|
    {
      t: recipient.field,
      a: recipient.email,
      p: recipient.display_name
    }.reject { |_, v| v.nil? }
  end
end

#start_at_jsnsObject



92
93
94
95
96
97
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 92

def start_at_jsns
  {
    d: @item.start_at.strftime(time_format),
    tz: @item.timezone
  }
end

#time_formatObject



108
109
110
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 108

def time_format
  @time_format ||= @item.allDay ? '%Y%m%d' : '%Y%m%dT%H%M00'
end

#to_jsnsObject Also known as: to_create



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 7

def to_jsns
  {
    m: {
      l: @item.l,
      su: @item.name,
      e: recipients_to_jsns,
      mp: body_to_jsns,
      inv: {
        comp: comp_to_jsns
      }
    }
  }
end

#to_updateObject



23
24
25
26
27
28
29
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 23

def to_update
  jsns = to_jsns
  jsns[:comp] = 0
  jsns[:id] = @item.id
  jsns[:m][:inv][:uid] = @item.uid
  jsns
end