Class: Nordea::Request
- Inherits:
-
Object
- Object
- Nordea::Request
- Defined in:
- lib/nordea/request.rb
Constant Summary collapse
- HOST_NAME =
'gfs.nb.se'
- HOST_PORT =
443
- SCRIPT_NAME =
'/bin2/gfskod'
- USER_AGENT =
'Nokia9110/1.0'
Instance Method Summary collapse
- #connection ⇒ Object
- #headers ⇒ Object
-
#initialize(command, extra_params = {}) ⇒ Request
constructor
A new instance of Request.
- #parse_xml ⇒ Object
- #query ⇒ Object
- #request ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(command, extra_params = {}) ⇒ Request
Returns a new instance of Request.
8 9 10 11 |
# File 'lib/nordea/request.rb', line 8 def initialize(command, extra_params = {}) @command, @extra_params = command, extra_params request end |
Instance Method Details
#connection ⇒ Object
13 14 15 16 17 |
# File 'lib/nordea/request.rb', line 13 def connection http = Net::HTTP.new(HOST_NAME, HOST_PORT) http.use_ssl = true http end |
#headers ⇒ Object
28 29 30 |
# File 'lib/nordea/request.rb', line 28 def headers { "User-Agent" => USER_AGENT } end |
#parse_xml ⇒ Object
19 20 21 |
# File 'lib/nordea/request.rb', line 19 def parse_xml Hpricot.XML(response) end |
#query ⇒ Object
36 37 38 39 40 |
# File 'lib/nordea/request.rb', line 36 def query @extra_params.merge({ "OBJECT" => @command }). inject([]) { |all, (key, value)| all << "#{key}=#{value}" }. join("&") end |
#request ⇒ Object
23 24 25 26 |
# File 'lib/nordea/request.rb', line 23 def request res = connection.post(SCRIPT_NAME, query, headers) @result = res.body end |
#response ⇒ Object
32 33 34 |
# File 'lib/nordea/request.rb', line 32 def response @result end |