Class: Vaultoro::BasicAPI::Client
- Inherits:
-
Object
- Object
- Vaultoro::BasicAPI::Client
- Defined in:
- lib/vaultoro/basic_api/client.rb
Class Method Summary collapse
Class Method Details
.get(endpoint, params = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vaultoro/basic_api/client.rb', line 9 def self.get(endpoint, params = {}) begin uri = URI.parse([Vaultoro.api_uri, endpoint].join) uri.query = URI.encode_www_form(params) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri, headers) response = http.request(request) rescue StandardError => error puts "Request failed (#{error.})" end end |
.post(endpoint, params = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vaultoro/basic_api/client.rb', line 23 def self.post(endpoint, params = {}) begin uri = URI.parse([Vaultoro.api_uri, endpoint].join) uri.query = URI.encode_www_form(params) # body = URI.encode_www_form(params) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri, headers) request.add_field "Content-Type", "application/x-www-form-urlencoded" # request.body = body response = http.request(request) rescue StandardError => error puts "Request failed (#{error.})" end end |