netki-tether 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/netki.rb +49 -1
- data/netki.gemspec +1 -1
- metadata +1 -2
- data/lib/netki/netki.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62072a344bde76b74e7e5ff12c3bee77e3d0f145
|
4
|
+
data.tar.gz: 5252aae76c76ae160894b86efa2a755dcd304795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4e3cc8349dec2f63dcf8443a480f5ce3c31a542325d4e3f0da14d46d23b729e3832af7008aa161fba3726f225920aeb7c3a123f5fe8f8cdec9df75b6bcd42a
|
7
|
+
data.tar.gz: f56bbdb9f6b9f20394b71d6d0fc3898cf9d881b73e776dbf30b275c9bb6eecab4fe541faca0839cec812103d9fc9a9da425b132342fba3c879b61f1835445530
|
data/README.md
CHANGED
data/lib/netki.rb
CHANGED
@@ -1,5 +1,53 @@
|
|
1
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'httpclient'
|
4
|
+
require 'json'
|
2
5
|
|
3
6
|
module Netki
|
4
7
|
|
8
|
+
# Request Utility Functionality
|
9
|
+
def self.process_request(uri)
|
10
|
+
# Setup Headers
|
11
|
+
headers = {}
|
12
|
+
headers["Content-Type"] = "application/json"
|
13
|
+
|
14
|
+
# Setup Request Options
|
15
|
+
opts = {}
|
16
|
+
opts[:header] = headers
|
17
|
+
method = 'GET'
|
18
|
+
|
19
|
+
client = HTTPClient.new
|
20
|
+
_uri = URI.parse(uri)
|
21
|
+
response = client.request(method, _uri, opts)
|
22
|
+
|
23
|
+
# We should have response content at this point
|
24
|
+
raise "Empty Response Received" if response.content.nil? || response.content.empty?
|
25
|
+
|
26
|
+
# Verify we have the correct content type
|
27
|
+
raise "Non-JSON Content Type" if response.headers['Content-Type'] != 'application/json'
|
28
|
+
|
29
|
+
# Make Sure We Can Decode JSON Response
|
30
|
+
begin
|
31
|
+
ret_data = JSON.parse(response.content)
|
32
|
+
rescue JSON::ParserError => e
|
33
|
+
raise "Invalid JSON Response Received"
|
34
|
+
end
|
35
|
+
return ret_data
|
36
|
+
end
|
37
|
+
|
38
|
+
# Query the Netki Open API for an address
|
39
|
+
def self.wallet_lookup(uri, currency, api_url='https://api.netki.com')
|
40
|
+
wallet_name = URI.parse(uri).host || uri.to_s
|
41
|
+
|
42
|
+
response = process_request("#{api_url}/api/wallet_lookup/#{wallet_name}/#{currency.downcase}")
|
43
|
+
|
44
|
+
netki_address = response['wallet_address']
|
45
|
+
|
46
|
+
unless netki_address.nil? || netki_address == 0
|
47
|
+
return netki_address
|
48
|
+
else
|
49
|
+
return false, "No Address Found"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
5
53
|
end
|
data/netki.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "netki-tether"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.5"
|
8
8
|
spec.licenses = ['BSD-3-Clause']
|
9
9
|
spec.authors = ["Matt David", "Whit Jackson"]
|
10
10
|
spec.email = ["opensource@netki.com"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netki-tether
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt David
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- bin/console
|
126
126
|
- bin/setup
|
127
127
|
- lib/netki.rb
|
128
|
-
- lib/netki/netki.rb
|
129
128
|
- netki.gemspec
|
130
129
|
homepage: https://github.com/whitj00/ruby-lookup-client
|
131
130
|
licenses:
|
data/lib/netki/netki.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'httpclient'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module Netki
|
7
|
-
|
8
|
-
# Request Utility Functionality
|
9
|
-
def self.process_request(uri)
|
10
|
-
# Setup Headers
|
11
|
-
headers = {}
|
12
|
-
headers["Content-Type"] = "application/json"
|
13
|
-
|
14
|
-
# Setup Request Options
|
15
|
-
opts = {}
|
16
|
-
opts[:header] = headers
|
17
|
-
method = 'GET'
|
18
|
-
|
19
|
-
client = HTTPClient.new
|
20
|
-
_uri = URI.parse(uri)
|
21
|
-
response = client.request(method, _uri, opts)
|
22
|
-
|
23
|
-
# We should have response content at this point
|
24
|
-
raise "Empty Response Received" if response.content.nil? || response.content.empty?
|
25
|
-
|
26
|
-
# Verify we have the correct content type
|
27
|
-
raise "Non-JSON Content Type" if response.headers['Content-Type'] != 'application/json'
|
28
|
-
|
29
|
-
# Make Sure We Can Decode JSON Response
|
30
|
-
begin
|
31
|
-
ret_data = JSON.parse(response.content)
|
32
|
-
rescue JSON::ParserError => e
|
33
|
-
raise "Invalid JSON Response Received"
|
34
|
-
end
|
35
|
-
return ret_data
|
36
|
-
end
|
37
|
-
|
38
|
-
# Query the Netki Open API for an address
|
39
|
-
def self.wallet_lookup(uri, currency, api_url='https://api.netki.com')
|
40
|
-
wallet_name = URI.parse(uri).host || uri.to_s
|
41
|
-
|
42
|
-
response = process_request("#{api_url}/api/wallet_lookup/#{wallet_name}/#{currency.downcase}", 'GET')
|
43
|
-
|
44
|
-
netki_address = response['wallet_address']
|
45
|
-
|
46
|
-
unless netki_address.nil? || netki_address == 0
|
47
|
-
return netki_address
|
48
|
-
else
|
49
|
-
return false, "No Address Found"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|