class BlockstreamSatellite::Client

Attributes

http_client[RW]
lnd_client[RW]

Public Class Methods

new(options) click to toggle source
# File lib/blockstream_satellite/client.rb, line 8
def initialize(options)
  self.lnd_client = options[:lnd_client]
  self.http_client = options[:http_client]
end

Public Instance Methods

get(path, params = nil, &block) click to toggle source
# File lib/blockstream_satellite/client.rb, line 13
def get(path, params = nil, &block)
  request(:get, path, params, &block)
end
pay(payreq) click to toggle source
# File lib/blockstream_satellite/client.rb, line 21
def pay(payreq)
  self.lnd_client.send_payment_sync(payment_request: payreq)
end
post(path, body = nil, &block) click to toggle source
# File lib/blockstream_satellite/client.rb, line 17
def post(path, body = nil, &block)
  request(:post, path, nil, body, &block)
end
request(http_method, path, params=nil, body=nil) { |req| ... } click to toggle source
# File lib/blockstream_satellite/client.rb, line 25
def request(http_method, path, params=nil, body=nil)
  response = http_client.send(http_method) do |req|
    req.url "/#{path}"
    req.params = params if params
    req.body = body if body
    yield req if block_given?
  end
  Response.new(response)
rescue Faraday::ClientError => error
  return Response.new(error)
end