class AstroPay::Curl
Public Class Methods
enable_ssl()
click to toggle source
Gets the configuration flag for SSL use with Astropay connections.
@return [Boolean]
# File lib/astro_pay/curl.rb, line 7 def self.enable_ssl AstroPay.configuration.enable_ssl end
post(url, params_hash)
click to toggle source
Performs a POST request to the given URL with the given parameters. @param url [String] to where the request will be made. @param params_hash [Hash] parameters to be sent with the request. @return [Hash] of the response or, if an error rises, [String] of
the response content.
@note When SSL is enabled, no certificate is actually verified due to
SSLv3 incompatibilities.
# File lib/astro_pay/curl.rb, line 18 def self.post(url, params_hash) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) unless enable_ssl http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(params_hash) response = http.request(request) begin JSON.parse(response.body) rescue response.body end end