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: Setting.lndhub_admin_token end def create_invoice(payload) # Payload: { amount: 1000, description: "", description_hash: "" } post "v2/invoices", payload end end