Class: KannelClient

Inherits:
Object
  • Object
show all
Defined in:
lib/kannel_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ KannelClient

Returns a new instance of KannelClient.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kannel_client.rb', line 8

def initialize(attributes={})
  self.username         = attributes[:username]
  self.password         = attributes[:password]
  self.url              = attributes[:url]
  self.dlr_callback_url = attributes[:dlr_callback_url]
  self.dlr_mask         = attributes[:dlr_mask]
  self.smsc             = attributes[:smsc]
  self.coding           = attributes[:coding]
  self.charset          = attributes[:charset]
  self.validity         = attributes[:validity]
end

Instance Attribute Details

#charsetObject

Returns the value of attribute charset.



6
7
8
# File 'lib/kannel_client.rb', line 6

def charset
  @charset
end

#codingObject

Returns the value of attribute coding.



6
7
8
# File 'lib/kannel_client.rb', line 6

def coding
  @coding
end

#dlr_callback_urlObject

Returns the value of attribute dlr_callback_url.



6
7
8
# File 'lib/kannel_client.rb', line 6

def dlr_callback_url
  @dlr_callback_url
end

#dlr_maskObject

Returns the value of attribute dlr_mask.



6
7
8
# File 'lib/kannel_client.rb', line 6

def dlr_mask
  @dlr_mask
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/kannel_client.rb', line 6

def password
  @password
end

#smscObject

Returns the value of attribute smsc.



6
7
8
# File 'lib/kannel_client.rb', line 6

def smsc
  @smsc
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/kannel_client.rb', line 6

def url
  @url
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/kannel_client.rb', line 6

def username
  @username
end

#validityObject

Returns the value of attribute validity.



6
7
8
# File 'lib/kannel_client.rb', line 6

def validity
  @validity
end

Instance Method Details

#send_quiet_sms(from, to, text) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kannel_client.rb', line 39

def send_quiet_sms(from,to,text)
  uri = URI(self.url)
  params = { 
    smsc:       self.smsc,
    username:   self.username,
    password:   self.password,
    from:       from,
    to:         to,
    text:       text,
    coding:     2,
    mclass:     0,
    pid:        64,
    charset:    self.charset,
    validity:   self.validity
  }
  uri.query = URI.encode_www_form(params)
  response = Net::HTTP.get_response(uri)

  return response
end

#send_sms(from, to, text) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kannel_client.rb', line 20

def send_sms(from,to,text)
  uri = URI(self.url)
  params = { 
    smsc:       self.smsc,
    username:   self.username,
    password:   self.password,
    from:       from,
    to:         to,
    text:       text,
    coding:     self.coding,
    charset:    self.charset,
    validity:   self.validity 
  }
  uri.query = URI.encode_www_form(params)
  response = Net::HTTP.get_response(uri)

  return response
end