Class: FinTS::HTTPSConnection
- Inherits:
-
Object
- Object
- FinTS::HTTPSConnection
- Defined in:
- lib/fints/https_connection.rb
Instance Method Summary collapse
-
#initialize(url) ⇒ HTTPSConnection
constructor
A new instance of HTTPSConnection.
- #send_msg(msg) ⇒ Object
Constructor Details
#initialize(url) ⇒ HTTPSConnection
Returns a new instance of HTTPSConnection.
3 4 5 |
# File 'lib/fints/https_connection.rb', line 3 def initialize(url) @url = URI(url) end |
Instance Method Details
#send_msg(msg) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fints/https_connection.rb', line 7 def send_msg(msg) = msg.to_s.encode('iso-8859-1') FinTS::Client.logger.debug("<< #{}") data = Base64.encode64() response = Net::HTTP.start(@url.host, @url.port, use_ssl: @url.scheme == 'https') do |http| http.post(@url.path, data, {'Content-Type' => 'text/plain'}) end code = response.code.to_i if code < 200 || code > 299 raise ConnectionError, "Bad status code #{code}" end res = Base64.decode64(response.body).force_encoding('iso-8859-1').encode('utf-8') FinTS::Client.logger.debug(">> #{res}") res end |