class BlockstreamSatellite::Order
Attributes
attributes[RW]
file[RW]
Public Class Methods
create(options)
click to toggle source
# File lib/blockstream_satellite/order.rb, line 27 def self.create(options) if path = options.delete(:path) options[:file] = UploadIO.new(options[:file], 'text/plain') # TODO: get rid of this content type here options[:file] = File.open(path) end options[:bid] ||= (options[:file] || options[:message]).size * 51 # default price response = BlockstreamSatellite.client.post('order', options) if response.success? Order.new(response.body).tap { |o| o.file = options[:file] } else response end end
get(order)
click to toggle source
# File lib/blockstream_satellite/order.rb, line 41 def self.get(order) Order.new(order).tap do |o| o.refresh end end
new(attributes)
click to toggle source
# File lib/blockstream_satellite/order.rb, line 12 def initialize(attributes) self.attributes = attributes.with_indifferent_access end
Public Instance Methods
bump(bid_increase)
click to toggle source
# File lib/blockstream_satellite/order.rb, line 65 def bump(bid_increase) response = BlockstreamSatellite.client.post("order/#{self.uuid}/bump", bid_increase: bid_increase) do |req| req.headers['X-Auth-Token'] = self.auth_token end if response.success? self.attributes['lightning_invoice'] = response['lightning_invoice'] else response end end
pay()
click to toggle source
# File lib/blockstream_satellite/order.rb, line 56 def pay response = BlockstreamSatellite.client.pay(self.payreq) if response.payment_error == '' self.refresh else response end end
payreq()
click to toggle source
# File lib/blockstream_satellite/order.rb, line 23 def payreq lightning_invoice['payreq'] end
refresh()
click to toggle source
# File lib/blockstream_satellite/order.rb, line 47 def refresh response = BlockstreamSatellite.client.get("order/#{self.uuid}") do |req| req.headers['X-Auth-Token'] = self.auth_token end if response.success? self.attributes.merge!(response.body) end end