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
41
42
43
44
45
46
|
# File 'lib/camunda/base_api.rb', line 41
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
|
48
49
50
51
52
53
54
|
# File 'lib/camunda/base_api.rb', line 48
def self.
{
Authorization: "Bearer #{oauth_token}",
Accept: 'application/json',
'Content-Type': 'application/json'
}
end
|
.patch(endpoint, params = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/camunda/base_api.rb', line 29
def self.patch(endpoint, params = {})
url = build_url(endpoint)
response = RestClient.patch(
url,
params.to_json,
)
JSON.parse(response.body)
end
|
.post(endpoint, params = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# 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
|