class Handcash::API
API
is the main class for all Handcash
gem functions. For now this is limited to `receive`.
Constants
- MAINNET_URL
- TESTNET_URL
- VERSION
Attributes
network[R]
url[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/handcash/api.rb, line 14 def initialize(opts = {}) # Default to mainnet. @network = opts[:network] || :mainnet case @network when :testnet @url = TESTNET_URL when :mainnet @url = MAINNET_URL else raise "Unsupported network - #{@network}" end end
Public Instance Methods
receive(user)
click to toggle source
# File lib/handcash/api.rb, line 27 def receive(user) uri = URI("#{url}receivingAddress/#{user}") data = Net::HTTP.get(uri) data == '' ? {} : JSON.parse(data) end