lib/oneaccess/api/base.rb in oneaccess-0.1.6 vs lib/oneaccess/api/base.rb in oneaccess-0.1.7

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: true + require "rest-client" require "json" require_relative "../response/api_error" require_relative "../error/api_error" @@ -12,12 +13,18 @@ RestClient.get(api_url(method), { params: params }.merge(auth_headers)) rescue RestClient::Exception => e raise create_api_error(e) end + def send_post(method, body) + RestClient.post(api_url(method), body.to_json, { content_type: :json }.merge(auth_headers)) + rescue RestClient::Exception => e + raise create_api_error(e) + end + def resource_api_path const_get("RESOURCE_API_PATH") - rescue + rescue StandardError nil end def api_url(method = nil) url = "#{Configuration.base_url}#{resource_api_path}"