netki-tether 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +0 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +23 -0
- data/README.md +51 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/netki/netki.rb +52 -0
- data/lib/netki.rb +5 -0
- data/netki.gemspec +28 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb01ba0c4e84943956018d30307d61eaab3995ec
|
4
|
+
data.tar.gz: 238263cf44e9a27f39fd99b30c839569c970a8ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 964b34474713ab534d3cbcad654359119cff2d1bc8dc3931d30b8b727f9011290b3002b3173d76c071d6ca3363a7308eeac5c728e984eb38d69ba8011285e2cd
|
7
|
+
data.tar.gz: 0f3d4adf4c5a228e2944d9420754988a6bebcc23b9b8714274b809f63d002e4e8323a5b6d2e0956162e2f7d094d5719b83221c2efc35b85879d3470839d60cc7
|
data/.gitignore
ADDED
Binary file
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2015, Netki, Inc.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted
|
5
|
+
provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
8
|
+
and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
11
|
+
and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
|
14
|
+
or promote products derived from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
17
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
18
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
19
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
20
|
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
21
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
23
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
![Rubygem](https://img.shields.io/gem/dv/netki/stable.svg)
|
2
|
+
|
3
|
+
# Ruby Netki Public Lookup API Client
|
4
|
+
|
5
|
+
This Ruby gem provides a client for [Netki's](https://netki.com) Public Lookup API.
|
6
|
+
|
7
|
+
This is forked from [Netki's Partner API Client](https://github.com/netkicorp/ruby-partner-client) to only include lookup functionality
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'netki-tether'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install netki-tether
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
This gem provides a single command to lookup a Netki address.
|
28
|
+
|
29
|
+
Example:
|
30
|
+
|
31
|
+
```
|
32
|
+
require 'netki'
|
33
|
+
|
34
|
+
Netki.wallet_lookup("wallet.whitjack.bit", "BTC")
|
35
|
+
```
|
36
|
+
|
37
|
+
This would return `"17t9jJkx1XoVXXVR5kBkF34Dv14rQkzFHH"`
|
38
|
+
|
39
|
+
If a wallet is not resolved, it will return `[false, "No Address Found"]`
|
40
|
+
|
41
|
+
See rdoc-generated documentation for this Gem in doc/
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/whitj00/ruby-lookup-client, as well as https://github.com/netkicorp/ruby-partner-client
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative "../lib/netki"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/netki/netki.rb
ADDED
@@ -0,0 +1,52 @@
|
|
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
|
data/lib/netki.rb
ADDED
data/netki.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "netki-tether"
|
7
|
+
spec.version = "0.0.4"
|
8
|
+
spec.licenses = ['BSD-3-Clause']
|
9
|
+
spec.authors = ["Matt David", "Whit Jackson"]
|
10
|
+
spec.email = ["opensource@netki.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Netki Simple Lookup API}
|
13
|
+
spec.description = %q{Netki module that provides access to the Netki Lookup API}
|
14
|
+
spec.homepage = "https://github.com/whitj00/ruby-lookup-client"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "httpclient", "~> 2.6"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "test-unit", "~> 3.1"
|
25
|
+
spec.add_development_dependency "test-unit-mock", "~> 0.3"
|
26
|
+
spec.add_development_dependency "mocha", "~> 1.1"
|
27
|
+
spec.add_development_dependency "webmock", "~> 1.21"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: netki-tether
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt David
|
8
|
+
- Whit Jackson
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httpclient
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.6'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '2.6'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.10'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.10'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: test-unit
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: test-unit-mock
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.3'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.3'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: mocha
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.1'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.1'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: webmock
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.21'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.21'
|
112
|
+
description: Netki module that provides access to the Netki Lookup API
|
113
|
+
email:
|
114
|
+
- opensource@netki.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/netki.rb
|
128
|
+
- lib/netki/netki.rb
|
129
|
+
- netki.gemspec
|
130
|
+
homepage: https://github.com/whitj00/ruby-lookup-client
|
131
|
+
licenses:
|
132
|
+
- BSD-3-Clause
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.8
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Netki Simple Lookup API
|
154
|
+
test_files: []
|