Sha256: 4963238e82af07fa23239b644576dfd5b5c32dbb91cdc22ef5c21a5cdfdc2ead
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require 'rubygems' require 'bundler/setup' require 'httpclient' require 'json' module Netki # Request Utility Functionality def self.process_request(uri) # Setup Headers headers = {} headers["Content-Type"] = "application/json" # Setup Request Options opts = {} opts[:header] = headers method = 'GET' client = HTTPClient.new _uri = URI.parse(uri) response = client.request(method, _uri, opts) # We should have response content at this point raise "Empty Response Received" if response.content.nil? || response.content.empty? # Verify we have the correct content type raise "Non-JSON Content Type" if response.headers['Content-Type'] != 'application/json' # Make Sure We Can Decode JSON Response begin ret_data = JSON.parse(response.content) rescue JSON::ParserError => e raise "Invalid JSON Response Received" end return ret_data end # Query the Netki Open API for an address def self.wallet_lookup(uri, currency, api_url='https://api.netki.com') wallet_name = URI.parse(uri).host || uri.to_s response = process_request("#{api_url}/api/wallet_lookup/#{wallet_name}/#{currency.downcase}") netki_address = response['wallet_address'] unless netki_address.nil? || netki_address == 0 return netki_address else return false, "No Address Found" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
netki-tether-0.0.6 | lib/netki.rb |
netki-tether-0.0.5 | lib/netki.rb |