Class: Request

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Request

Returns a new instance of Request.

Yields:

  • (_self)

Yield Parameters:

  • _self (Request)

    the object that the method was called on



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

def initialize(&block)
  yield self

  @headers = {
    "Content-Type"   => "text/plain; charset=Windows-1251",
    "Content-Length" => @body.size.to_s,
    "X-Eport-Auth"   => "point=#{@point}; sign=\"#{signature(@body)}\"; encoding=\"hex\""
  }.merge(additional_headers || {})
end

Instance Attribute Details

#additional_headersObject

Returns the value of attribute additional_headers.



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

def additional_headers
  @additional_headers
end

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#pointObject

Returns the value of attribute point.



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

def point
  @point
end

#private_key_pathObject

Returns the value of attribute private_key_path.



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

def private_key_path
  @private_key_path
end

Instance Method Details

#confirmObject



18
19
20
21
22
23
24
25
# File 'lib/request.rb', line 18

def confirm
  http = Net::HTTP.new(@host, 443)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  puts @headers.inspect
  resp, data = http.post(@path, @body, @headers)
  data
end