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



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 76

def attendees_to_jsns
  @item.attendees.map do |attendee|
    h = {
      a: attendee.email,
      d: attendee.display_name,
      role: attendee.role,
      ptst: attendee.ptst,
      rsvp: attendee.rsvp
    }
    h.compact!
    h
  end
end

#body_html_jsnsObject



56
57
58
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 56

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

#body_text_jsnsObject



52
53
54
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 52

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

#body_to_jsnsObject



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

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

#comp_to_jsnsObject



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

def comp_to_jsns
  h = {
    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
  }
  h.compact!

  [h]
end

#end_at_jsnsObject



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

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

#organizer_to_jsnsObject



104
105
106
107
108
109
110
111
112
113
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 104

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

  h = {
    a: @item.organizer.email,
    d: @item.organizer.display_name
  }
  h.compact!
  h
end

#recipients_to_jsnsObject



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

def recipients_to_jsns
  @item.recipients.map do |recipient|
    h = {
      t: recipient.field,
      a: recipient.email,
      p: recipient.display_name
    }
    h.compact!
    h
  end
end

#start_at_jsnsObject



97
98
99
100
101
102
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 97

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

#time_formatObject



115
116
117
118
119
# File 'lib/zm/client/appointment/appointment_jsns_builder.rb', line 115

def time_format
  return @time_format if defined? @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] = SoapUtils::OFF
  jsns[:id] = @item.id
  jsns[:m][:inv][:uid] = @item.uid
  jsns
end