apihub 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19d974c45dfa0c450c3d4810632aa59f71bb23c7
4
- data.tar.gz: 779c54682a4c689ae61c4db6e44ee0e55f6cbd53
3
+ metadata.gz: e2fea1e6fc0edcfddc46493756c86cb3bf655c58
4
+ data.tar.gz: 1ac941bd3036128b03c33f11e6603abbe52c5c40
5
5
  SHA512:
6
- metadata.gz: 17dce255412e8054f2a5d1390ceecf7e37a238c4506f4c1e043afa2c05dc4f4ea68901af899d01a6bac719284344f6324ffbe6ed60585702af78982a4f04d956
7
- data.tar.gz: e26bc6701df3a83fcee6769167c1bebb6c619539928f2951c4ae7f013b687ea10b487e26fd5dcd4de96fa8e1fa92ba602c5638ff41dcc0a6373917e23682f6bb
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
- if key = ENV['APIHUB_KEY']
41
- options[:api_key] ||= key
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
- APIHub.api_key = options[:api_key]
59
+ if key = ENV['APIHUB_KEY']
60
+ options[:api_key] ||= key
61
+ end
50
62
 
51
- person = APIHub::Person.find(values, options)
63
+ object = entity.find(values, options)
52
64
 
53
- if person && person.pending?
54
- puts 'Person lookup queued'
55
- elsif person
56
- ap person.to_hash
65
+ if object && object.pending?
66
+ puts 'Lookup queued'
67
+ elsif object
68
+ ap object.to_hash
57
69
  else
58
- puts 'Person not found'
70
+ puts 'Not found'
59
71
  end
@@ -1,6 +1,6 @@
1
1
  require 'apihub'
2
2
  require 'pp'
3
3
 
4
- APIHub.api_key = ENV['SOURCING_KEY']
4
+ APIHub.api_key = ENV['APIHUB_KEY']
5
5
 
6
6
  pp APIHub::Person[email: 'info@eribium.org']
@@ -19,4 +19,5 @@ module APIHub
19
19
  end
20
20
 
21
21
  autoload :Person, 'apihub/person'
22
+ autoload :Company, 'apihub/company'
22
23
  end
@@ -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
@@ -1,6 +1,6 @@
1
1
  module APIHub
2
2
  class Person < Base
3
- endpoint 'https://profile.apihub.co'
3
+ endpoint 'https://person.apihub.co'
4
4
  path '/v1/people'
5
5
 
6
6
  def self.find(values, options = {})
@@ -1,3 +1,3 @@
1
1
  module APIHub
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-07 00:00:00.000000000 Z
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