lushao 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 +4 -4
- data/Gemfile +4 -4
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +7 -7
- data/lib/lushao.rb +10 -10
- data/lib/lushao/api.rb +31 -31
- data/lib/lushao/person.rb +41 -36
- data/lib/lushao/version.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b300115f830841e77a5a783e573342f9a4f9883b
|
|
4
|
+
data.tar.gz: 3202ac47a771311e16cc0ac9d43d1ac0678cc0f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66d75df965ebc5e18a80bd3fc48d9bbaaf614e017ba56875168e1c57636b13e5fae2c36a48b5dd61058763a9e581cb1694cef1d6bf015ca32da2b614c0667e90
|
|
7
|
+
data.tar.gz: e49d8c9ef7367f74c7774ab5076d12cc7c92fcc00b50557f4f1053539820e3fce698d71a85c5956afbe4aa19726a441015bc21412fc9987d4b37529793e67673
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in lushao.gemspec
|
|
4
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in lushao.gemspec
|
|
4
|
+
gemspec
|
data/Rakefile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
|
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "lushao"
|
|
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
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "lushao"
|
|
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
|
|
5
|
-
bundle install
|
|
6
|
-
|
|
7
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
|
|
5
|
+
bundle install
|
|
6
|
+
|
|
7
|
+
# Do any other automated setup that you need to do here
|
data/lib/lushao.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'lushao/api'))
|
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'lushao/version'))
|
|
3
|
-
|
|
4
|
-
module Lushao
|
|
5
|
-
extend self
|
|
6
|
-
|
|
7
|
-
def new(key)
|
|
8
|
-
Api.new(key)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'lushao/api'))
|
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'lushao/version'))
|
|
3
|
+
|
|
4
|
+
module Lushao
|
|
5
|
+
extend self
|
|
6
|
+
|
|
7
|
+
def new(key)
|
|
8
|
+
Api.new(key)
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/lushao/api.rb
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
require 'uri'
|
|
2
|
-
|
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'person'))
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module Lushao
|
|
7
|
-
class Api
|
|
8
|
-
attr_reader :key
|
|
9
|
-
|
|
10
|
-
def initialize(key)
|
|
11
|
-
@key = key
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def find_person_with_company(company, first_name, last_name)
|
|
15
|
-
Lushao::Person.new(company, first_name, last_name,0, self.key).get_results
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def find_person_with_domain(domain, first_name, last_name)
|
|
19
|
-
Lushao::Person.new(domain, first_name, last_name,1, self.key).get_results
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def find_company_with_name(name)
|
|
23
|
-
Lushao::Person.new(name,0, self.key).get_results
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def find_company_with_domain(domain)
|
|
27
|
-
Lushao::Person.new(domain,1, self.key).get_results
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
end
|
|
1
|
+
require 'uri'
|
|
2
|
+
|
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'person'))
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module Lushao
|
|
7
|
+
class Api
|
|
8
|
+
attr_reader :key
|
|
9
|
+
|
|
10
|
+
def initialize(key)
|
|
11
|
+
@key = key
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def find_person_with_company(company, first_name, last_name,property=nil)
|
|
15
|
+
Lushao::Person.new(company, first_name, last_name,0, self.key,property).get_results
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def find_person_with_domain(domain, first_name, last_name,property=nil)
|
|
19
|
+
Lushao::Person.new(domain, first_name, last_name,1, self.key,property).get_results
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def find_company_with_name(name)
|
|
23
|
+
Lushao::Person.new(name,0, self.key).get_results
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def find_company_with_domain(domain)
|
|
27
|
+
Lushao::Person.new(domain,1, self.key).get_results
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/lushao/person.rb
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
require 'faraday'
|
|
2
|
-
require 'json'
|
|
3
|
-
|
|
4
|
-
API_PERSON_URL = 'https://api.lusha.co/person?'
|
|
5
|
-
|
|
6
|
-
module Lushao
|
|
7
|
-
class Person
|
|
8
|
-
attr_reader :emailAddresses, :phoneNumbers
|
|
9
|
-
|
|
10
|
-
def initialize(company_or_domain, first_name, last_name,flag_company_or_domain, key)
|
|
11
|
-
@company_or_domain = company_or_domain
|
|
12
|
-
@first_name = first_name
|
|
13
|
-
@last_name = last_name
|
|
14
|
-
@flag_company_or_domain=flag_company_or_domain
|
|
15
|
-
@key = key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
API_PERSON_URL = 'https://api.lusha.co/person?'
|
|
5
|
+
|
|
6
|
+
module Lushao
|
|
7
|
+
class Person
|
|
8
|
+
attr_reader :emailAddresses, :phoneNumbers
|
|
9
|
+
|
|
10
|
+
def initialize(company_or_domain, first_name, last_name,flag_company_or_domain, key,property)
|
|
11
|
+
@company_or_domain = company_or_domain
|
|
12
|
+
@first_name = first_name
|
|
13
|
+
@last_name = last_name
|
|
14
|
+
@flag_company_or_domain=flag_company_or_domain
|
|
15
|
+
@key = key
|
|
16
|
+
@property = property
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_results
|
|
20
|
+
response = apiresponse
|
|
21
|
+
Struct.new(*response.keys).new(*response.values) unless response.empty?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def apiresponse
|
|
27
|
+
property_params=""
|
|
28
|
+
if @property
|
|
29
|
+
property_params="&property=#{@property}"
|
|
30
|
+
end
|
|
31
|
+
if @flag_company_or_domain == 0
|
|
32
|
+
url = URI.parse(URI.encode("#{API_PERSON_URL}firstName=#{@first_name}&lastName=#{@last_name}&company=#{@company_or_domain}#{property_params}"))
|
|
33
|
+
else
|
|
34
|
+
url = URI.parse(URI.encode("#{API_PERSON_URL}firstName=#{@first_name}&lastName=#{@last_name}&domain=#{@company_or_domain}#{property_params}"))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
response = Faraday.new(url, :headers => {'api_key' => @key}).get
|
|
38
|
+
response.success? ? JSON.parse(response.body, {symbolize_names: true}) : []
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/lushao/version.rb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module Lushao
|
|
2
|
-
VERSION = "0.0.
|
|
3
|
-
end
|
|
1
|
+
module Lushao
|
|
2
|
+
VERSION = "0.0.2"
|
|
3
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lushao
|
|
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
|
- Louis Perello
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
103
|
version: '0'
|
|
104
104
|
requirements: []
|
|
105
105
|
rubyforge_project:
|
|
106
|
-
rubygems_version: 2.
|
|
106
|
+
rubygems_version: 2.2.5
|
|
107
107
|
signing_key:
|
|
108
108
|
specification_version: 4
|
|
109
109
|
summary: A tiny ruby wrapper around Lusha API
|