Class: AstroPay::Curl
- Inherits:
-
Object
- Object
- AstroPay::Curl
- Defined in:
- lib/astro_pay/curl.rb
Class Method Summary collapse
-
.enable_ssl ⇒ Boolean
Gets the configuration flag for SSL use with Astropay connections.
-
.post(url, params_hash) ⇒ Hash
Performs a POST request to the given URL with the given parameters.
Class Method Details
.enable_ssl ⇒ Boolean
Gets the configuration flag for SSL use with Astropay connections.
7 8 9 |
# File 'lib/astro_pay/curl.rb', line 7 def self.enable_ssl AstroPay.configuration.enable_ssl end |
.post(url, params_hash) ⇒ Hash
Note:
When SSL is enabled, no certificate is actually verified due to SSLv3 incompatibilities.
Performs a POST request to the given URL with the given parameters.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 |