Class: Google::Voice::Missed

Inherits:
Base
  • Object
show all
Defined in:
lib/google/voice/missed.rb

Instance Method Summary collapse

Methods inherited from Base

#archive, #delete, #finalize, #initialize, #mark

Constructor Details

This class inherits a constructor from Google::Voice::Base

Instance Method Details

#missedObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/google/voice/missed.rb', line 8

def missed
  @curb.url = "https://www.google.com/voice/inbox/recent/missed/"        
  @curb.http_get
  calls = []
  doc = Nokogiri::XML::Document.parse(@curb.body_str)
  box = doc.xpath('/response/json').first.text
  json = JSON.parse(box)
  # Format for messages is [id, {attributes}]
  json['messages'].each do |message|
    if message[1]['type'].to_i == 2
      next
    else
      # Google is using milliseconds since epoch for time
      calls << {
        :id => message[0],
        :phone_number => message[1]['phoneNumber'],
        :start_time => Time.at(message[1]['startTime'].to_i / 1000)} 
    end
  end      
  calls
end