Class: Coinsimple::Business
- Inherits:
-
Object
- Object
- Coinsimple::Business
- Defined in:
- lib/coinsimple/business.rb
Constant Summary collapse
- NEW_INVOICE_URL =
"https://app.coinsimple.com/api/v1/invoice"
Instance Method Summary collapse
-
#initialize(business_id, api_key) ⇒ Business
constructor
A new instance of Business.
- #send_invoice(invoice) ⇒ Object
Constructor Details
#initialize(business_id, api_key) ⇒ Business
Returns a new instance of Business.
9 10 11 12 |
# File 'lib/coinsimple/business.rb', line 9 def initialize business_id , api_key @api_key=api_key @business_id=business_id end |
Instance Method Details
#send_invoice(invoice) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/coinsimple/business.rb', line 14 def send_invoice invoice =invoice.data [:business_id]=@business_id =Time.now.to_i hash=Hashit.sha256(,@api_key)[3..-1] [:timestamp]= [:hash]=hash res = HTTP.post NEW_INVOICE_URL, json: if res.status >= 400 {"status" => "error" , "error" => "error creating invoice"} else JSON.parse res.to_s end end |