apihub 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -1
- data/bin/apihub +22 -10
- data/examples/email.rb +1 -1
- data/lib/apihub.rb +1 -0
- data/lib/apihub/company.rb +37 -0
- data/lib/apihub/person.rb +1 -1
- data/lib/apihub/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fea1e6fc0edcfddc46493756c86cb3bf655c58
|
4
|
+
data.tar.gz: 1ac941bd3036128b03c33f11e6603abbe52c5c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ff7541653d6f7cf5ee22436a5b9f597fcdc2ffe95a7a5cb439e54f014ab487e7cdd1ce3af8cf6664e3e861baece31427da4611145834f25d18d1add20c9fab
|
7
|
+
data.tar.gz: f98cf398160db54dcf7375adbf7e7ef66931eb0f72798ef2471f5cefeb48e14a5e97eb0feb01480f7d3bcb3fddab71e76bc1b2afac02d2ab9e04ec249bcc55c5
|
data/README.md
CHANGED
@@ -28,11 +28,23 @@ Then you can lookup people by email address:
|
|
28
28
|
|
29
29
|
If the person can't be found, then `nil` will be returned.
|
30
30
|
|
31
|
+
See the [documentation](https://apihub.co/docs/person) for more information.
|
32
|
+
|
33
|
+
## Company lookup
|
34
|
+
|
35
|
+
You can lookup company data by domain name:
|
36
|
+
|
37
|
+
company = APIHub::Company[domain: 'uber.com']
|
38
|
+
|
39
|
+
If the company can't be found, then `nil` will be returned.
|
40
|
+
|
41
|
+
See the [documentation](https://apihub.co/docs/company) for more information.
|
42
|
+
|
31
43
|
## CLI
|
32
44
|
|
33
45
|
The gem also includes a `apihub` executable, which you can use like this:
|
34
46
|
|
35
|
-
$ apihub --email info@eribium.org
|
47
|
+
$ apihub person --email info@eribium.org
|
36
48
|
|
37
49
|
{
|
38
50
|
"name": {
|
@@ -41,3 +53,19 @@ The gem also includes a `apihub` executable, which you can use like this:
|
|
41
53
|
"familyName": "MacCaw"
|
42
54
|
},
|
43
55
|
...
|
56
|
+
|
57
|
+
Or to look up a company:
|
58
|
+
|
59
|
+
$ apihub company --domain uber.com
|
60
|
+
|
61
|
+
{
|
62
|
+
"name": "Uber",
|
63
|
+
"legalName": "Uber, Inc.",
|
64
|
+
"categories": [
|
65
|
+
"Transport"
|
66
|
+
],
|
67
|
+
"founders": [
|
68
|
+
"Travis Kalanick",
|
69
|
+
"Garrett Camp"
|
70
|
+
],
|
71
|
+
...
|
data/bin/apihub
CHANGED
@@ -16,7 +16,7 @@ options = {}
|
|
16
16
|
values = {}
|
17
17
|
|
18
18
|
parser = OptionParser.new do |opts|
|
19
|
-
opts.banner = "Usage: apihub [options]"
|
19
|
+
opts.banner = "Usage: apihub [person|company] [options]"
|
20
20
|
|
21
21
|
opts.on("--twitter HANDLE", String, "Twitter handle") do |v|
|
22
22
|
values[:twitter] = v
|
@@ -30,6 +30,10 @@ parser = OptionParser.new do |opts|
|
|
30
30
|
values[:email] = v
|
31
31
|
end
|
32
32
|
|
33
|
+
opts.on("--domain DOMAIN", String, "Domain") do |v|
|
34
|
+
values[:domain] = v
|
35
|
+
end
|
36
|
+
|
33
37
|
opts.on("--api-key KEY", String, "APIHub") do |v|
|
34
38
|
options[:api_key] = v
|
35
39
|
end
|
@@ -37,8 +41,14 @@ end
|
|
37
41
|
|
38
42
|
parser.parse!
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
case ARGV[0]
|
45
|
+
when 'person'
|
46
|
+
entity = APIHub::Person
|
47
|
+
when 'company'
|
48
|
+
entity = APIHub::Company
|
49
|
+
else
|
50
|
+
puts parser
|
51
|
+
exit
|
42
52
|
end
|
43
53
|
|
44
54
|
if values == {}
|
@@ -46,14 +56,16 @@ if values == {}
|
|
46
56
|
exit
|
47
57
|
end
|
48
58
|
|
49
|
-
|
59
|
+
if key = ENV['APIHUB_KEY']
|
60
|
+
options[:api_key] ||= key
|
61
|
+
end
|
50
62
|
|
51
|
-
|
63
|
+
object = entity.find(values, options)
|
52
64
|
|
53
|
-
if
|
54
|
-
puts '
|
55
|
-
elsif
|
56
|
-
ap
|
65
|
+
if object && object.pending?
|
66
|
+
puts 'Lookup queued'
|
67
|
+
elsif object
|
68
|
+
ap object.to_hash
|
57
69
|
else
|
58
|
-
puts '
|
70
|
+
puts 'Not found'
|
59
71
|
end
|
data/examples/email.rb
CHANGED
data/lib/apihub.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module APIHub
|
2
|
+
class Company < Base
|
3
|
+
endpoint 'https://company.apihub.co'
|
4
|
+
path '/v1/companies'
|
5
|
+
|
6
|
+
def self.find(values, options = {})
|
7
|
+
unless values.is_a?(Hash)
|
8
|
+
values = {:id => values}
|
9
|
+
end
|
10
|
+
|
11
|
+
options = options.dup
|
12
|
+
params = options.delete(:params) || {}
|
13
|
+
|
14
|
+
if domain = values[:domain]
|
15
|
+
response = get(uri(:domain, domain), params, options)
|
16
|
+
|
17
|
+
elsif id = values[:id]
|
18
|
+
response = get(id, params, options)
|
19
|
+
|
20
|
+
else
|
21
|
+
raise ArgumentError, 'Invalid values'
|
22
|
+
end
|
23
|
+
|
24
|
+
if response.status == 202
|
25
|
+
self.new(pending: true)
|
26
|
+
else
|
27
|
+
self.new(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
rescue Nestful::ResourceNotFound
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
alias_method :[], :find
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/apihub/person.rb
CHANGED
data/lib/apihub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apihub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacCaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- bin/apihub
|
70
70
|
- examples/email.rb
|
71
71
|
- lib/apihub.rb
|
72
|
+
- lib/apihub/company.rb
|
72
73
|
- lib/apihub/person.rb
|
73
74
|
- lib/apihub/version.rb
|
74
75
|
homepage: https://github.com/maccman/apihub-ruby
|