Refactor ejabberd API integration
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 2s

This commit is contained in:
2025-05-26 14:10:27 +04:00
parent 4bf6985b87
commit d737d9f6b8
19 changed files with 307 additions and 167 deletions
+6 -4
View File
@@ -13,15 +13,17 @@ class RestApiService < ApplicationService
"#{base_url}/#{path.gsub(/^\//, '')}"
end
def parse_responses?
true
end
def get(path, params = {})
res = Faraday.get endpoint_url(path), params, headers
# TODO handle unsuccessful responses with no valid JSON body
JSON.parse(res.body)
parse_responses? ? JSON.parse(res.body) : res
end
def post(path, payload)
res = Faraday.post endpoint_url(path), payload.to_json, headers
# TODO handle unsuccessful responses with no valid JSON body
JSON.parse(res.body)
parse_responses? ? JSON.parse(res.body) : res
end
end