Class: ONEAccess::API::Base
- Inherits:
-
Object
- Object
- ONEAccess::API::Base
show all
- Defined in:
- lib/oneaccess/api/base.rb
Class Method Summary
collapse
Class Method Details
.api_url(method = nil) ⇒ Object
30
31
32
33
34
|
# File 'lib/oneaccess/api/base.rb', line 30
def api_url(method = nil)
url = "#{Configuration.base_url}#{resource_api_path}"
return url if method.nil?
"#{url}/#{method}"
end
|
.resource_api_path ⇒ Object
24
25
26
27
28
|
# File 'lib/oneaccess/api/base.rb', line 24
def resource_api_path
const_get("RESOURCE_API_PATH")
rescue StandardError
nil
end
|
.send_get(method, params = {}) ⇒ Object
12
13
14
15
16
|
# File 'lib/oneaccess/api/base.rb', line 12
def send_get(method, params = {})
RestClient.get(api_url(method), { params: params }.merge())
rescue RestClient::Exception => e
raise create_api_error(e)
end
|
.send_post(method, body) ⇒ Object
18
19
20
21
22
|
# File 'lib/oneaccess/api/base.rb', line 18
def send_post(method, body)
RestClient.post(api_url(method), body.to_json, { content_type: :json }.merge())
rescue RestClient::Exception => e
raise create_api_error(e)
end
|