-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
185989c
commit c55d658
Showing
8 changed files
with
344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"success": true, | ||
"id": 301592, | ||
"source": "linkedIn", | ||
"name": "Lizi Hamer", | ||
"firstName": "Lizi", | ||
"lastName": "Hamer", | ||
"logo": "https://app.snov.io/img/peoples/010fcf23c70dfa68d880545ec89a9215.jpg", | ||
"industry": null, | ||
"country": "Singapore", | ||
"locality": "Singapore", | ||
"social": [ | ||
{ | ||
"link": "https://www.linkedin.com/in/lizihamer/", | ||
"type": "linkedIn" | ||
}, | ||
{ | ||
"link": "https://twitter.com/LiziHamer", | ||
"type": "twitter" | ||
} | ||
], | ||
"currentJobs": [ | ||
{ | ||
"companyName": "Octagon", | ||
"position": "Regional Creative Director", | ||
"socialLink": "https://www.linkedin.com/company/165282", | ||
"site": "www.octagon.com", | ||
"locality": "Greater New York City Area", | ||
"state": "Connecticut", | ||
"city": "Stamford", | ||
"street": "290 Harbor Dr", | ||
"street2": "2nd Floor", | ||
"postal": "06902", | ||
"founded": "1983", | ||
"startDate": "2016-01-31", | ||
"endDate": null, | ||
"size": "1-10", | ||
"industry": "Marketing and Advertising", | ||
"companyType": "Public Company", | ||
"country": "United States" | ||
}, | ||
{ | ||
"companyName": "SisuGirls", | ||
"position": "Co Founder", | ||
"socialLink": "https://www.linkedin.com/company/3841118", | ||
"site": "http://www.sisugirls.org", | ||
"locality": null, | ||
"state": "SG", | ||
"city": "Singapore", | ||
"street": "33-03 Hong Leong Building", | ||
"street2": null, | ||
"postal": null, | ||
"founded": "2014", | ||
"startDate": "2015-07-31", | ||
"endDate": null, | ||
"size": "1-10", | ||
"industry": "Health, Wellness and Fitness", | ||
"companyType": null, | ||
"country": "Singapore" | ||
} | ||
], | ||
"previousJobs": [ | ||
{ | ||
"companyName": "Fusion Co-innovation Labs", | ||
"position": "Creative Entrepreneur", | ||
"socialLink": null, | ||
"site": null, | ||
"locality": null, | ||
"state": null, | ||
"city": null, | ||
"street": null, | ||
"street2": null, | ||
"postal": null, | ||
"founded": null, | ||
"startDate": "2013-05-31", | ||
"endDate": "2013-10-31", | ||
"size": null, | ||
"industry": null, | ||
"companyType": null, | ||
"country": null | ||
}, | ||
{ | ||
"companyName": "Russell Commission", | ||
"position": "Youth Advisory Board Member", | ||
"socialLink": null, | ||
"site": null, | ||
"locality": null, | ||
"state": null, | ||
"city": null, | ||
"street": null, | ||
"street2": null, | ||
"postal": null, | ||
"founded": null, | ||
"startDate": "2004-06-30", | ||
"endDate": "2006-06-30", | ||
"size": null, | ||
"industry": null, | ||
"companyType": null, | ||
"country": null | ||
} | ||
], | ||
"lastUpdateDate": "2018-02-07 10:12:28" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require 'active_support/core_ext/array' | ||
|
||
module Snov | ||
class GetProfileByEmail | ||
attr_reader :client, :email | ||
|
||
def initialize(email:, client: Snov.client) | ||
@client = client | ||
@email = email.to_str | ||
end | ||
|
||
def each(&block) | ||
prospects.each(&block) | ||
end | ||
|
||
def prospect | ||
@prospect ||= ProspectResult.new(raw_result) | ||
end | ||
|
||
def method_missing(method_name, *arguments, &block) | ||
if prospect.respond_to?(method_name) | ||
prospect.public_send(method_name, *arguments, &block) | ||
else | ||
super | ||
end | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
prospect.respond_to?(method_name) || super | ||
end | ||
|
||
def raw_result | ||
@raw_result ||= client.post("/v1/get-profile-by-email", | ||
'email' => email) | ||
.deep_transform_keys! { |key| key.underscore } | ||
end | ||
|
||
class Job | ||
include ActiveModel::Model | ||
|
||
attr_accessor :company_name, :position, :social_link, :site, :locality, :state, :city | ||
attr_accessor :street, :street2, :postal, :founded, :start_date, :end_date, :size | ||
attr_accessor :industry, :company_type, :country | ||
end | ||
|
||
class Social | ||
include ActiveModel::Model | ||
|
||
attr_accessor :link, :type | ||
end | ||
|
||
class List | ||
include ActiveModel::Model | ||
|
||
attr_accessor :id, :name | ||
end | ||
|
||
class ProspectResult | ||
include ActiveModel::Model | ||
|
||
attr_accessor :id, :name, :first_name, :last_name, :industry, :country, :locality, :success, :source | ||
attr_accessor :logo, :last_update_date, :message | ||
attr_reader :social, :current_jobs, :previous_jobs | ||
|
||
def social=(val) | ||
@social = Array.wrap(val).map do |rel| | ||
Social.new(rel) | ||
end | ||
end | ||
|
||
def current_jobs=(val) | ||
@current_jobs = Array.wrap(val).map do |rel| | ||
Job.new(rel) | ||
end | ||
end | ||
|
||
def previous_jobs=(val) | ||
@previous_jobs = Array.wrap(val).map do |rel| | ||
Job.new(rel) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"success": true, | ||
"id": 301592, | ||
"source": "linkedIn", | ||
"name": "Lizi Hamer", | ||
"firstName": "Lizi", | ||
"lastName": "Hamer", | ||
"logo": "https://app.snov.io/img/peoples/010fcf23c70dfa68d880545ec89a9215.jpg", | ||
"industry": null, | ||
"country": "Singapore", | ||
"locality": "Singapore", | ||
"social": [ | ||
{ | ||
"link": "https://www.linkedin.com/in/lizihamer/", | ||
"type": "linkedIn" | ||
}, | ||
{ | ||
"link": "https://twitter.com/LiziHamer", | ||
"type": "twitter" | ||
} | ||
], | ||
"currentJobs": [ | ||
{ | ||
"companyName": "Octagon", | ||
"position": "Regional Creative Director", | ||
"socialLink": "https://www.linkedin.com/company/165282", | ||
"site": "www.octagon.com", | ||
"locality": "Greater New York City Area", | ||
"state": "Connecticut", | ||
"city": "Stamford", | ||
"street": "290 Harbor Dr", | ||
"street2": "2nd Floor", | ||
"postal": "06902", | ||
"founded": "1983", | ||
"startDate": "2016-01-31", | ||
"endDate": null, | ||
"size": "1-10", | ||
"industry": "Marketing and Advertising", | ||
"companyType": "Public Company", | ||
"country": "United States" | ||
}, | ||
{ | ||
"companyName": "SisuGirls", | ||
"position": "Co Founder", | ||
"socialLink": "https://www.linkedin.com/company/3841118", | ||
"site": "http://www.sisugirls.org", | ||
"locality": null, | ||
"state": "SG", | ||
"city": "Singapore", | ||
"street": "33-03 Hong Leong Building", | ||
"street2": null, | ||
"postal": null, | ||
"founded": "2014", | ||
"startDate": "2015-07-31", | ||
"endDate": null, | ||
"size": "1-10", | ||
"industry": "Health, Wellness and Fitness", | ||
"companyType": null, | ||
"country": "Singapore" | ||
} | ||
], | ||
"previousJobs": [ | ||
{ | ||
"companyName": "Fusion Co-innovation Labs", | ||
"position": "Creative Entrepreneur", | ||
"socialLink": null, | ||
"site": null, | ||
"locality": null, | ||
"state": null, | ||
"city": null, | ||
"street": null, | ||
"street2": null, | ||
"postal": null, | ||
"founded": null, | ||
"startDate": "2013-05-31", | ||
"endDate": "2013-10-31", | ||
"size": null, | ||
"industry": null, | ||
"companyType": null, | ||
"country": null | ||
}, | ||
{ | ||
"companyName": "Russell Commission", | ||
"position": "Youth Advisory Board Member", | ||
"socialLink": null, | ||
"site": null, | ||
"locality": null, | ||
"state": null, | ||
"city": null, | ||
"street": null, | ||
"street2": null, | ||
"postal": null, | ||
"founded": null, | ||
"startDate": "2004-06-30", | ||
"endDate": "2006-06-30", | ||
"size": null, | ||
"industry": null, | ||
"companyType": null, | ||
"country": null | ||
} | ||
], | ||
"lastUpdateDate": "2018-02-07 10:12:28" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Snov | ||
RSpec.describe GetProfileByEmail do | ||
subject { described_class.new(client: client, email: "gavin.vanrooyen@octagon.com") } | ||
|
||
let(:client) { instance_double(Client) } | ||
|
||
before do | ||
json = File.read(__dir__ + "/get_profile_by_email_spec.json") | ||
allow(client).to receive(:post).with("/v1/get-profile-by-email", "email" => "gavin.vanrooyen@octagon.com") | ||
.and_return(MultiJson.load(json)) | ||
end | ||
|
||
it 'returns all' do | ||
expect(subject).to have_attributes(name: 'Lizi Hamer') | ||
expect(subject.social.first).to have_attributes(link: 'https://www.linkedin.com/in/lizihamer/') | ||
end | ||
end | ||
end |