Class: Camunda::BaseAPI
- Inherits:
-
Object
show all
- Defined in:
- lib/camunda/base_api.rb
Class Method Summary
collapse
Class Method Details
.build_url(endpoint, params = {}) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/camunda/base_api.rb', line 28
def self.build_url(endpoint, params = {})
url = "#{base_url}/#{Camunda.api_version}/#{endpoint}"
url += "?#{URI.encode_www_form(params)}" unless params.empty?
url
end
|
.get(endpoint, params = {}) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/camunda/base_api.rb', line 10
def self.get(endpoint, params = {})
url = build_url(endpoint, params)
response = RestClient.get(url, )
JSON.parse(response.body)
end
|
35
36
37
38
39
40
41
|
# File 'lib/camunda/base_api.rb', line 35
def self.
{
Authorization: "Bearer #{oauth_token}",
Accept: 'application/json',
'Content-Type': 'application/json'
}
end
|
.post(endpoint, params = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/camunda/base_api.rb', line 17
def self.post(endpoint, params = {})
url = build_url(endpoint)
response = RestClient.post(
url,
params.to_json,
)
JSON.parse(response.body) if response.code == 200
end
|