rapportive 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +20 -0
- data/Rakefile +1 -0
- data/lib/rapportive.rb +75 -0
- data/lib/rapportive/version.rb +3 -0
- data/rapportive.gemspec +29 -0
- data/spec/rapportive_spec.rb +30 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d8144e32ba2be9f3909bdd3b5479ed5e7bc8864
|
4
|
+
data.tar.gz: 23af7effe0bdb5b2b7fa59fe88ab73efbf087485
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f23522aad4149b31c5b57aa483e46a3164a48dba7d7e71cd302bdce995a6e24af5333c84a14865e96b19f422a794534596fe6a4a49a3a03be32a65dbf799c188
|
7
|
+
data.tar.gz: 66d8db10e31b44460ebe58e2f5b32d08a05e92363415b7e4797884035fd97eee38085b2ba8371bed2c30d1785cdccd0c319d0461170c2bcbc00a005bc1d337df
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alfredo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
rapportive
|
2
|
+
==========
|
3
|
+
|
4
|
+
Ruby Gem to automate Rapportive Queries
|
5
|
+
|
6
|
+
Inspired by https://github.com/jordan-wright/rapportive
|
7
|
+
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
|
11
|
+
<pre><code>
|
12
|
+
client = Rapportive::Search.new
|
13
|
+
|
14
|
+
client.search("alfredo@cool-tabs.com")
|
15
|
+
</code></pre>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rapportive.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "rapportive/version"
|
2
|
+
require "httpi"
|
3
|
+
require "json"
|
4
|
+
STATUS_URL = 'https://rapportive.com/login_status' #?user_email={0}
|
5
|
+
URL = 'https://profiles.rapportive.com/contacts/email' #/{0}
|
6
|
+
module Rapportive
|
7
|
+
class Search
|
8
|
+
attr_accessor :session_token
|
9
|
+
def initialize
|
10
|
+
url = URL
|
11
|
+
request = HTTPI::Request.new
|
12
|
+
request.url = STATUS_URL
|
13
|
+
request.query = {:user_email => "fake_#{rand(10000)}@wadus.com"}#Fake email to get token session
|
14
|
+
@session_token = JSON.parse(HTTPI.get(request).body)["session_token"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def search(email=nil)
|
18
|
+
raise "Should include an email as argument" if email.nil?
|
19
|
+
request = HTTPI::Request.new
|
20
|
+
request.url = "#{URL}/#{email}"
|
21
|
+
request.headers = {'X-Session-Token' => @session_token}
|
22
|
+
begin
|
23
|
+
result = JSON.parse(HTTPI.get(request).body)
|
24
|
+
if result["success"] == "nothing_useful"
|
25
|
+
# No se ha encontrado nada
|
26
|
+
return {error: "Not Found"}
|
27
|
+
elsif result["error_code"] || result["error"]
|
28
|
+
result
|
29
|
+
else
|
30
|
+
# data["success"] == "image_and_occupation_and_useful_membership"
|
31
|
+
Person.new(result["contact"])
|
32
|
+
end
|
33
|
+
rescue Exception => e
|
34
|
+
e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
class Person
|
41
|
+
attr_accessor :email, :twitter_username, :name, :location, :headline, :images, :phones, :occupations, :memberships
|
42
|
+
def initialize(data={})
|
43
|
+
@email = data["email"]
|
44
|
+
@twitter_username = data["twitter_username"]
|
45
|
+
@name = data["name"]
|
46
|
+
@location = data["location"]
|
47
|
+
@headline = data["headline"]
|
48
|
+
@images = !data["images"].empty? ? data["images"].map{|a| a["url"]} : [data["image_url_raw"]]
|
49
|
+
@phones = data["phones"]
|
50
|
+
@occupations = data["occupations"].inject([]){|a, occ| a << Occupation.new(occ)}
|
51
|
+
@memberships = data["memberships"].inject([]){|a, mem| a << Membership.new(mem)}
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Occupation
|
57
|
+
attr_accessor :job_title, :company
|
58
|
+
|
59
|
+
def initialize(data={})
|
60
|
+
@job_title = data["job_title"]
|
61
|
+
@company = data["company"]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Membership
|
66
|
+
attr_accessor :profile_url, :profile_id, :username, :site_name
|
67
|
+
|
68
|
+
def initialize(data={})
|
69
|
+
@profile_url = data["profile_url"]
|
70
|
+
@profile_id = data["profile_id"]
|
71
|
+
@site_name = data["site_name"]
|
72
|
+
@username = data["username"]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/rapportive.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rapportive/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rapportive"
|
8
|
+
spec.version = Rapportive::VERSION
|
9
|
+
spec.authors = ["Alfredo Solano"]
|
10
|
+
spec.email = ["cantorrodista@gmail.com"]
|
11
|
+
spec.description = %q{Automate rapportive queries}
|
12
|
+
spec.summary = %q{Automate rapportive queries}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "debugger", "~> 1.6.5"
|
25
|
+
|
26
|
+
spec.add_dependency 'httpi', '~> 2.1.0'
|
27
|
+
spec.add_dependency 'json'
|
28
|
+
spec.add_dependency 'httpclient'
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rapportive'
|
2
|
+
describe Rapportive::Search do
|
3
|
+
it "should create a new Rapportive client with a valid token" do
|
4
|
+
client = Rapportive::Search.new
|
5
|
+
client.should_not be_nil
|
6
|
+
client.session_token.should_not be_nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should search for an email" do
|
10
|
+
client = Rapportive::Search.new
|
11
|
+
client.should_not be_nil
|
12
|
+
client.session_token.should_not be_nil
|
13
|
+
result = client.search('cantorrodista@gmail.com')
|
14
|
+
result.should_not be_nil
|
15
|
+
result.twitter_username.should == "cantorrodista"
|
16
|
+
result.name.should == "Alfredo Solano Rodrigo"
|
17
|
+
result.occupations.first.should_not be_nil
|
18
|
+
result.memberships.first.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return no result for a not valid email" do
|
22
|
+
client = Rapportive::Search.new
|
23
|
+
client.should_not be_nil
|
24
|
+
client.session_token.should_not be_nil
|
25
|
+
result = client.search('xxxx@ddddddddd.com')
|
26
|
+
result.should_not be_nil
|
27
|
+
result[:error].should == "Not Found"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapportive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alfredo Solano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.14.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.14.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: debugger
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.5
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httpi
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: httpclient
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Automate rapportive queries
|
112
|
+
email:
|
113
|
+
- cantorrodista@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/rapportive.rb
|
124
|
+
- lib/rapportive/version.rb
|
125
|
+
- rapportive.gemspec
|
126
|
+
- spec/rapportive_spec.rb
|
127
|
+
homepage: ''
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.4.6
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Automate rapportive queries
|
151
|
+
test_files:
|
152
|
+
- spec/rapportive_spec.rb
|