Class: Google::Voice::Base

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

Direct Known Subclasses

Missed, Sms

Instance Method Summary collapse

Constructor Details

#initialize(email, password) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
# File 'lib/google/voice/base.rb', line 9

def initialize(email, password)      
  @email = email
  @password = password
  
  set_rnr_se_token
end

Instance Method Details

#archive(ids) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/google/voice/base.rb', line 32

def archive(ids)
  ids = Array(ids)
  fields = [ 
    Curl::PostField.content('_rnr_se', @_rnr_se),
    Curl::PostField.content('archive', '1')]
  ids.each{|id| fields << Curl::PostField.content('messages', id)}
  @curb.http_post(fields)
  @curb.url = "https://www.google.com/voice/inbox/archiveMessages/"        
  @curb.perform
  @curb.response_code
end

#delete(ids) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/google/voice/base.rb', line 20

def delete(ids)
  ids = Array(ids)
  fields = [ 
    Curl::PostField.content('_rnr_se', @_rnr_se),
    Curl::PostField.content('trash', '1')]
  ids.each{|id| fields << Curl::PostField.content('messages', id)}
  @curb.http_post(fields)
  @curb.url = "https://www.google.com/voice/inbox/deleteMessages/"        
  @curb.perform
  @curb.response_code
end

#finalizeObject



16
17
18
# File 'lib/google/voice/base.rb', line 16

def finalize
  logout
end

#mark(ids, read = true) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/google/voice/base.rb', line 44

def mark(ids, read = true)
  ids = Array(ids)
  fields = [ 
    Curl::PostField.content('_rnr_se', @_rnr_se),
    Curl::PostField.content('read', read ? '1' : '0')]
  ids.each{|id| fields << Curl::PostField.content('messages', id)}
  @curb.http_post(fields)
  @curb.url = "https://www.google.com/voice/inbox/mark/"        
  @curb.perform
  @curb.response_code
end