apihub 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/bin/apihub +11 -13
- data/lib/apihub.rb +1 -0
- data/lib/apihub/company.rb +6 -2
- data/lib/apihub/person.rb +6 -2
- data/lib/apihub/streaming.rb +6 -0
- data/lib/apihub/streaming/company.rb +7 -0
- data/lib/apihub/streaming/person.rb +7 -0
- data/lib/apihub/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968c7728de504c70dd18e6e8a07ede0c86208eea
|
4
|
+
data.tar.gz: ebf452723ba3193ef318d7173c5489f4f2ee385d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f439d4701289989682fc21f06f4b3b9312709d744d213d0a7babfbf2294877c28cda23101faa53b40085d26235548e56623700788f4afdcff965349cc1f2115
|
7
|
+
data.tar.gz: 23c14c0544c262886bb8c32774b0557cff0a4404dc880d56c07c35e6cf01a2200e92df6d56e56e655308d0ca61df73cc184c87fb828cfc070f50124bfc805286
|
data/README.md
CHANGED
@@ -40,6 +40,21 @@ If the company can't be found, then `nil` will be returned.
|
|
40
40
|
|
41
41
|
See the [documentation](https://apihub.co/docs/company) for more information.
|
42
42
|
|
43
|
+
## Streaming requests
|
44
|
+
|
45
|
+
Often you'll want people or company lookups to block, rather than return blank `202` requests if we need to look up data. You can do this using APIHub's streaming API.
|
46
|
+
|
47
|
+
For example, to look up a company by domain using our streaming API use the `APIHub::Streaming::Company` class:
|
48
|
+
|
49
|
+
company = APIHub::Streaming::Company[domain: 'uber.com']
|
50
|
+
|
51
|
+
If we need to lookup the company, we'll block the network request for 10-20 seconds before responding. This is ideal for scenarios where long network requests don't really matter, such as job queues. Often the streaming API will be easier to implement than webhooks.
|
52
|
+
|
53
|
+
You can similarity look up people using the `APIHub::Streaming::Person` class.
|
54
|
+
|
55
|
+
person = APIHub::Streaming::Person[email: 'info@eribium.org']
|
56
|
+
|
57
|
+
|
43
58
|
## CLI
|
44
59
|
|
45
60
|
The gem also includes a `apihub` executable, which you can use like this:
|
data/bin/apihub
CHANGED
@@ -18,14 +18,6 @@ values = {}
|
|
18
18
|
parser = OptionParser.new do |opts|
|
19
19
|
opts.banner = "Usage: apihub [person|company] [options]"
|
20
20
|
|
21
|
-
opts.on("--twitter HANDLE", String, "Twitter handle") do |v|
|
22
|
-
values[:twitter] = v
|
23
|
-
end
|
24
|
-
|
25
|
-
opts.on("--github HANDLE", String, "GitHub handle") do |v|
|
26
|
-
values[:github] = v
|
27
|
-
end
|
28
|
-
|
29
21
|
opts.on("--email EMAIL", String, "Email") do |v|
|
30
22
|
values[:email] = v
|
31
23
|
end
|
@@ -43,9 +35,9 @@ parser.parse!
|
|
43
35
|
|
44
36
|
case ARGV[0]
|
45
37
|
when 'person'
|
46
|
-
entity = APIHub::Person
|
38
|
+
entity = APIHub::Streaming::Person
|
47
39
|
when 'company'
|
48
|
-
entity = APIHub::Company
|
40
|
+
entity = APIHub::Streaming::Company
|
49
41
|
else
|
50
42
|
puts parser
|
51
43
|
exit
|
@@ -60,11 +52,17 @@ if key = ENV['APIHUB_KEY']
|
|
60
52
|
options[:api_key] ||= key
|
61
53
|
end
|
62
54
|
|
55
|
+
if key = options.delete(:api_key)
|
56
|
+
APIHub.api_key = key
|
57
|
+
else
|
58
|
+
puts 'API Key required'
|
59
|
+
puts parser
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
63
|
object = entity.find(values, options)
|
64
64
|
|
65
|
-
if object
|
66
|
-
puts 'Lookup queued'
|
67
|
-
elsif object
|
65
|
+
if object
|
68
66
|
ap object.to_hash
|
69
67
|
else
|
70
68
|
puts 'Not found'
|
data/lib/apihub.rb
CHANGED
data/lib/apihub/company.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module APIHub
|
2
2
|
class Company < Base
|
3
|
-
endpoint 'https://company
|
3
|
+
endpoint 'https://company.apihub.co'
|
4
4
|
path '/v1/companies'
|
5
5
|
|
6
6
|
def self.find(values, options = {})
|
@@ -21,7 +21,11 @@ module APIHub
|
|
21
21
|
raise ArgumentError, 'Invalid values'
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
if response.status == 202
|
25
|
+
self.new(pending: true)
|
26
|
+
else
|
27
|
+
self.new(response)
|
28
|
+
end
|
25
29
|
|
26
30
|
rescue Nestful::ResourceNotFound
|
27
31
|
end
|
data/lib/apihub/person.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module APIHub
|
2
2
|
class Person < Base
|
3
|
-
endpoint 'https://person
|
3
|
+
endpoint 'https://person.apihub.co'
|
4
4
|
path '/v1/people'
|
5
5
|
|
6
6
|
def self.find(values, options = {})
|
@@ -27,7 +27,11 @@ module APIHub
|
|
27
27
|
raise ArgumentError, 'Invalid values'
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
if response.status == 202
|
31
|
+
self.new(pending: true)
|
32
|
+
else
|
33
|
+
self.new(response)
|
34
|
+
end
|
31
35
|
|
32
36
|
rescue Nestful::ResourceNotFound
|
33
37
|
end
|
data/lib/apihub/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacCaw
|
@@ -74,6 +74,9 @@ files:
|
|
74
74
|
- lib/apihub/mash.rb
|
75
75
|
- lib/apihub/person.rb
|
76
76
|
- lib/apihub/resource.rb
|
77
|
+
- lib/apihub/streaming.rb
|
78
|
+
- lib/apihub/streaming/company.rb
|
79
|
+
- lib/apihub/streaming/person.rb
|
77
80
|
- lib/apihub/version.rb
|
78
81
|
homepage: https://github.com/maccman/apihub-ruby
|
79
82
|
licenses:
|