akkounts/app/services/lndhub_v2.rb
Râu Cao 2f90393eb6
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 3s
Lndhub v2 service inherits from v1, only adds v2-specific code
2023-06-05 13:53:24 +03:00

26 lines
754 B
Ruby

class LndhubV2 < Lndhub
def post(endpoint, 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
log_error(res) if res.status != 200
JSON.parse(res.body)
end
def create_account(payload={})
post "v2/users", payload, admin_token: Rails.application.credentials.lndhub[:admin_token]
end
def create_invoice(payload)
# Payload: { amount: 1000, description: "", description_hash: "" }
post "v2/invoices", payload
end
end