Module: Flutterwave::Utils::NetworkManager
- Defined in:
- lib/flutterwave/utils/network_manager.rb
Constant Summary collapse
- BASE_URL =
Flutterwave::Utils::Constants::BASE_URL
Class Method Summary collapse
Class Method Details
.post(url, body) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flutterwave/utils/network_manager.rb', line 11 def self.post(url, body) uri = URI.parse("#{BASE_URL}#{url}") request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') request.body = body.to_json response = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(request) end JSON.parse(response.body) rescue SocketError, TypeError, EOFError, JSON::ParserError return nil end |