DRY up btcpay and lndhub services

Removing initialize methods from the main/manager class also allows for
different iniitalizers in specific task services
This commit is contained in:
2024-02-14 10:44:47 +01:00
parent fee951c05c
commit 69b3afb8f7
5 changed files with 43 additions and 25 deletions

View File

@@ -1,13 +1,13 @@
class LndhubV2 < Lndhub
def post(endpoint, payload, options={})
def post(path, payload, options={})
headers = { "Content-Type" => "application/json" }
if auth_token
headers.merge!({ "Authorization" => "Bearer #{auth_token}" })
elsif options[:admin_token]
headers.merge!({ "Authorization" => "Bearer #{options[:admin_token]}" })
end
res = Faraday.post "#{@base_url}/#{endpoint}", payload.to_json, headers
res = Faraday.post endpoint_url(path), payload.to_json, headers
log_error(res) if res.status != 200
JSON.parse(res.body)