Class: Xapo::API
- Inherits:
-
Object
- Object
- Xapo::API
- Defined in:
- lib/xapo_api.rb
Instance Method Summary collapse
- #credit(to, amount, request_id, currency: Xapo::Currency::BTC, comments: "", subject: "") ⇒ Object
-
#initialize(service_url, app_id, app_secret) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(service_url, app_id, app_secret) ⇒ API
Returns a new instance of API.
26 27 28 29 30 31 |
# File 'lib/xapo_api.rb', line 26 def initialize(service_url, app_id, app_secret) @service_url = service_url @app_id = app_id @app_secret = app_secret @credit_resource = '/credit/' end |
Instance Method Details
#credit(to, amount, request_id, currency: Xapo::Currency::BTC, comments: "", subject: "") ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/xapo_api.rb', line 33 def credit(to, amount, request_id, currency: Xapo::Currency::BTC, comments: "", subject: "") = XapoUtils. payload = { :to => to, :currency => currency, :amount => amount, :comments => comments, :subject => subject, :timestamp => , :unique_request_id => request_id } json_payload = JSON.generate(payload) encrypted_payload = XapoUtils.encrypt(json_payload, @app_secret, false) uri = URI(@service_url + @credit_resource) query = URI.encode_www_form(:appID => @app_id, :hash => encrypted_payload) uri.query = query res = Net::HTTP.get_response(uri) return JSON.parse(res.body) end |