Class: RingCentral::RSS::AtomEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/ringcentral-rss/atom_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ AtomEntry

Returns a new instance of AtomEntry.



8
9
10
# File 'lib/ringcentral-rss/atom_entry.rb', line 8

def initialize(data = nil)
  load_message(data) unless data.nil?
end

Instance Attribute Details

#entryObject

Returns the value of attribute entry.



6
7
8
# File 'lib/ringcentral-rss/atom_entry.rb', line 6

def entry
  @entry
end

Instance Method Details

#build_title(data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ringcentral-rss/atom_entry.rb', line 24

def build_title(data)
  raise 'Data is not a hash' unless data.is_a? Hash

  parts = []

  if data.key?('to') && (data['to'].length > 0) && data['to'][0]['phoneNumber']
    to_phone_number = "#{data['to'][0]['phoneNumber']}"
    parts << "To: #{to_phone_number}" unless to_phone_number.empty?
  end

  if data.key?('from') && !data['from']['phoneNumber'].empty?
    from_phone_number = "#{data['from']['phoneNumber']}"
    parts << "From: #{from_phone_number}"
  end

  "[#{data['direction']} #{data['type']}] " + parts.join('; ')
end

#load_message(data) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ringcentral-rss/atom_entry.rb', line 12

def load_message(data)
  raise 'Data is not a hash' unless data.is_a? Hash

  @entry = Atom::Entry.new do |e|
    e.title = build_title data
    e.links << Atom::Link.new(href: data['uri'])
    e.id = data['id']
    e.updated = Time.parse(data['lastModifiedTime'])
    e.summary = data['subject']
  end
end