class Coinsimple::Business

Constants

NEW_INVOICE_URL

Public Class Methods

new(business_id , api_key) click to toggle source
# File lib/coinsimple/business.rb, line 9
def initialize business_id , api_key
  @api_key=api_key
  @business_id=business_id
end

Public Instance Methods

send_invoice(invoice) click to toggle source
# File lib/coinsimple/business.rb, line 14
def send_invoice invoice
  options=invoice.data
  options[:business_id]=@business_id
  timestamp=Time.now.to_i
  hash=Hashit.sha256(timestamp,@api_key)[3..-1]
  options[:timestamp]=timestamp
  options[:hash]=hash

  res = HTTP.post NEW_INVOICE_URL, json: options
  if res.status >= 400
    {"status" => "error" , "error" => "error creating invoice"}
  else
    JSON.parse res.to_s
  end
end