Class: Mailsolution::HTTP

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

Instance Method Summary collapse

Constructor Details

#initialize(aid) ⇒ HTTP

Returns a new instance of HTTP.



7
8
9
10
11
12
13
14
15
# File 'lib/mailsolution.rb', line 7

def initialize(aid)
  require 'uri'
  @aid = aid.to_i
  @redirect = "http://62.27.38.101/host/h.php?TYPE=r&AID=#{aid}"
  @action = "NEW"
  @attributes = ""
  @domain = "62.27.38.101"
  self
end

Instance Method Details

#attributes=(attrs) ⇒ Object



17
18
19
# File 'lib/mailsolution.rb', line 17

def attributes=(attrs)
  @attributes = attrs.map{|k,v| "&#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}"}.join
end

#deliverObject



34
35
36
37
38
39
# File 'lib/mailsolution.rb', line 34

def deliver
  require 'net/http'
  begin
    Timeout.timeout(10) { Net::HTTP.get_response(@domain, path, "80") }
  end
end

#pathObject



26
27
28
# File 'lib/mailsolution.rb', line 26

def path
  "/c/n?AID=#{URI.escape(@aid.to_s)}&ACTION=#{URI.escape(@action)}#{@attributes}&RED=#{URI.escape(@redirect)}"
end

#to_sObject



30
31
32
# File 'lib/mailsolution.rb', line 30

def to_s
  "http://#{@domain}#{path}"
end

#update_attributes(attrs) ⇒ Object



21
22
23
24
# File 'lib/mailsolution.rb', line 21

def update_attributes(attrs)
  @attributes += attrs.map{|k,v| "&#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}"}.join
  self
end