Class: Professionali::ApiCore
- Inherits:
-
Object
- Object
- Professionali::ApiCore
show all
- Defined in:
- lib/professionali/api_core.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(token) ⇒ ApiCore
Returns a new instance of ApiCore.
5
6
7
|
# File 'lib/professionali/api_core.rb', line 5
def initialize token
@token = token
end
|
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
3
4
5
|
# File 'lib/professionali/api_core.rb', line 3
def token
@token
end
|
Instance Method Details
#api_call(path, method = "get", params = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/professionali/api_core.rb', line 9
def api_call path, method = "get", params = {}
params = params.merge(access_token: @token)
begin
case method
when "get"
response = RestClient.get api_url(path), params: params
when "put"
response = RestClient.put api_url(path), params: params, accept: :json
when "post"
response = RestClient.post api_url(path), params: params, accept: :json
else
response = RestClient.send method, api_url(path), params: params
end
rescue => e
raise_errors e.response
end
Professionali::Mash.from_json response.body
end
|
#get ⇒ Object
51
52
53
|
# File 'lib/professionali/api_core.rb', line 51
def get
:get
end
|
#post ⇒ Object
47
48
49
|
# File 'lib/professionali/api_core.rb', line 47
def post
:post
end
|
#raise_errors(response) ⇒ Object