Class: Mobitex::HTTPDelivery

Inherits:
Object
  • Object
show all
Defined in:
lib/mobitex/delivery/http_delivery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ HTTPDelivery

Returns a new instance of HTTPDelivery.



9
10
11
12
13
14
15
# File 'lib/mobitex/delivery/http_delivery.rb', line 9

def initialize(values)
  self.settings = {
      :user            => nil,
      :pass            => nil,
      :return_response => false
  }.merge!(values)
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/mobitex/delivery/http_delivery.rb', line 7

def response
  @response
end

#settingsObject

Returns the value of attribute settings.



6
7
8
# File 'lib/mobitex/delivery/http_delivery.rb', line 6

def settings
  @settings
end

Instance Method Details

#deliver!(message) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mobitex/delivery/http_delivery.rb', line 17

def deliver!(message)
  @response = nil

  message.sanitize!

  raw_response = connection.post('/send.php', {
      :user   => settings[:user],
      :pass   => settings[:pass],
      :type   => message.type,
      :from   => message.from,
      :number => message.to,
      :text   => message.body,
      :ext_id => message.message_id
  })

  @response = Response.parse(raw_response.body)

  settings[:return_response] ? @response : self
end