Class: Roseflow::LinkedIn::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/roseflow/linkedin/person.rb,
lib/roseflow/linkedin/person/object.rb,
lib/roseflow/linkedin/person/experience.rb,
lib/roseflow/linkedin/person/role_query.rb,
lib/roseflow/linkedin/person/lookup_query.rb,
lib/roseflow/linkedin/person/profile_query.rb

Defined Under Namespace

Classes: Experience, ExperienceMapper, LookupQuery, Object, ProfileQuery, RoleQuery

Instance Method Summary collapse

Constructor Details

#initialize(client = Roseflow::Proxycurl::Client.new) ⇒ Person

Returns a new instance of Person.



11
12
13
# File 'lib/roseflow/linkedin/person.rb', line 11

def initialize(client = Roseflow::Proxycurl::Client.new)
  @client = client
end

Instance Method Details

#find(url, **options) ⇒ Object



15
16
17
18
19
20
# File 'lib/roseflow/linkedin/person.rb', line 15

def find(url, **options)
  query = ProfileQuery.new(url: url, **options)
  response = @client.find_person(query)
  return Person::Object.new(JSON.parse(response.body).merge(profile_url: url)) if person_found?(response)
  return nil if person_not_found?(response)
end

#lookup(query) ⇒ Object



22
23
24
25
26
27
# File 'lib/roseflow/linkedin/person.rb', line 22

def lookup(query)
  query = LookupQuery.new(query)
  response = @client.lookup_person(query)
  return JSON.parse(response.body).dig("url") if person_found?(response)
  return nil if person_not_found?(response)
end

#role(query) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/roseflow/linkedin/person.rb', line 29

def role(query)
  query = RoleQuery.new(query)
  response = @client.find_person_in_role(query)
  if person_found?(response)
    url = JSON.parse(response.body).dig("linkedin_profile_url")
    return find(url)
  end

  return nil if person_not_found?(response)
end