Add Mastodon API service class, auth token config

Add a new REST API service class to keep things DRY
This commit is contained in:
2025-05-17 14:17:57 +04:00
parent c43e43d89c
commit f0cfde560b
6 changed files with 68 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
#
# API Docs: https://docs.btcpayserver.org/API/Greenfield/v1/
#
class BtcpayManagerService < ApplicationService
class BtcpayManagerService < RestApiService
private
def base_url
@@ -19,18 +19,4 @@ class BtcpayManagerService < ApplicationService
"Authorization" => "token #{auth_token}"
}
end
def endpoint_url(path)
"#{base_url}/#{path.gsub(/^\//, '')}"
end
def get(path, params = {})
res = Faraday.get endpoint_url(path), params, headers
JSON.parse(res.body)
end
def post(path, payload)
res = Faraday.post endpoint_url(path), payload.to_json, headers
JSON.parse(res.body)
end
end