Class: Txter::Gateway4info

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

Defined Under Namespace

Classes: Request, Response

Constant Summary collapse

API =
'http://gateway.4info.net/msg'

Constants inherited from Gateway

Txter::Gateway::Error, Txter::Gateway::Success

Class Method Summary collapse

Methods inherited from Gateway

current, unblock

Class Method Details

.deliver(message, number) ⇒ Object



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

def self.deliver(message, number)
  Gateway4info.perform Request.new.deliver_message(message, number)
end

.perform(body) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gateway_4info.rb', line 10

def self.perform(body)
  if :live == Txter.mode
    require 'net/http'
    uri = URI.parse API
    body = start do |http|
      http.post(
                 uri.path,
                 body,
                 {'Content-Type' => 'text/xml'}
      ).read_body
    end
    Response.new(body)
  else
    Txter.log "Would have sent to 4info.net: #{body}"
  end
end