Class: Pipl::Client::SearchResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/pipl/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ SearchResponse

Returns a new instance of SearchResponse.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pipl/response.rb', line 15

def initialize(params={})
  @query = params[:query]
  @person = params[:person]
  @sources = params[:sources]
  @possible_persons = params[:possible_persons]
  @warnings = params[:warnings]
  @visible_sources = params[:visible_sources]
  @available_sources = params[:available_sources]
  @search_id = params[:search_id]
  @http_status_code = params[:http_status_code]
  @raw_response = params[:raw_response]
  @available_data = params[:available_data]
  @match_requirements = params[:match_requirements]
  @source_category_requirements = params[:source_category_requirements]
end

Instance Attribute Details

#available_dataObject (readonly)

Returns the value of attribute available_data.



12
13
14
# File 'lib/pipl/response.rb', line 12

def available_data
  @available_data
end

#available_sourcesObject (readonly)

Returns the value of attribute available_sources.



11
12
13
# File 'lib/pipl/response.rb', line 11

def available_sources
  @available_sources
end

#http_status_codeObject (readonly)

Returns the value of attribute http_status_code.



12
13
14
# File 'lib/pipl/response.rb', line 12

def http_status_code
  @http_status_code
end

#match_requirementsObject (readonly)

Returns the value of attribute match_requirements.



12
13
14
# File 'lib/pipl/response.rb', line 12

def match_requirements
  @match_requirements
end

#personObject (readonly)

Returns the value of attribute person.



11
12
13
# File 'lib/pipl/response.rb', line 11

def person
  @person
end

#possible_personsObject (readonly)

Returns the value of attribute possible_persons.



11
12
13
# File 'lib/pipl/response.rb', line 11

def possible_persons
  @possible_persons
end

#queryObject (readonly)

Returns the value of attribute query.



11
12
13
# File 'lib/pipl/response.rb', line 11

def query
  @query
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



12
13
14
# File 'lib/pipl/response.rb', line 12

def raw_response
  @raw_response
end

#search_idObject (readonly)

Returns the value of attribute search_id.



12
13
14
# File 'lib/pipl/response.rb', line 12

def search_id
  @search_id
end

#source_category_requirementsObject (readonly)

Returns the value of attribute source_category_requirements.



13
14
15
# File 'lib/pipl/response.rb', line 13

def source_category_requirements
  @source_category_requirements
end

#sourcesObject (readonly)

Returns the value of attribute sources.



11
12
13
# File 'lib/pipl/response.rb', line 11

def sources
  @sources
end

#visible_sourcesObject (readonly)

Returns the value of attribute visible_sources.



11
12
13
# File 'lib/pipl/response.rb', line 11

def visible_sources
  @visible_sources
end

#warningsObject (readonly)

Returns the value of attribute warnings.



11
12
13
# File 'lib/pipl/response.rb', line 11

def warnings
  @warnings
end

Class Method Details

.from_json(json_str) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pipl/response.rb', line 31

def self.from_json(json_str)
  h = JSON.parse(json_str, symbolize_names: true)

  params = {}
  params[:query] = Pipl::Person.from_hash(h[:query]) if h.key? :query
  params[:person] = Pipl::Person.from_hash(h[:person]) if h.key? :person
  params[:sources] = h[:sources].map { |s| Pipl::Source.from_hash(s) } if h.key? :sources
  params[:possible_persons] = h[:possible_persons].map { |p| Pipl::Person.from_hash(p) } if h.key? :possible_persons
  params[:warnings] = h[:warnings]
  params[:visible_sources] = h[:@visible_sources]
  params[:available_sources] = h[:@available_sources]
  params[:search_id] = h[:@search_id]
  params[:http_status_code] = h[:@http_status_code]
  params[:raw_response] = json_str
  params[:match_requirements] = h[:match_requirements]
  params[:source_category_requirements] = h[:source_category_requirements]
  params[:available_data] = AvailableData.from_hash(h[:available_data]) if h.key? :available_data

  self.new(params)
end

Instance Method Details

#addressObject



80
81
82
# File 'lib/pipl/response.rb', line 80

def address
  @person.address if @person
end

#ageObject



72
73
74
# File 'lib/pipl/response.rb', line 72

def age
  @person.age if @person
end

#educationObject



84
85
86
# File 'lib/pipl/response.rb', line 84

def education
  @person.education if @person
end

#emailObject



104
105
106
# File 'lib/pipl/response.rb', line 104

def email
  @person.email if @person
end

#ethnicityObject



92
93
94
# File 'lib/pipl/response.rb', line 92

def ethnicity
  @person.ethnicity if @person
end

#genderObject



68
69
70
# File 'lib/pipl/response.rb', line 68

def gender
  @person.gender if @person
end

#group_sources_by_categoryObject



60
61
62
# File 'lib/pipl/response.rb', line 60

def group_sources_by_category
  @sources.group_by { |s| s.category } if @sources
end

#group_sources_by_domainObject



56
57
58
# File 'lib/pipl/response.rb', line 56

def group_sources_by_domain
  @sources.group_by { |s| s.domain } if @sources
end

#group_sources_by_matchObject



64
65
66
# File 'lib/pipl/response.rb', line 64

def group_sources_by_match
  @sources.group_by { |s| s.match } if @sources
end

#imageObject



112
113
114
# File 'lib/pipl/response.rb', line 112

def image
  @person.image if @person
end

#jobObject



76
77
78
# File 'lib/pipl/response.rb', line 76

def job
  @person.job if @person
end

#languageObject



88
89
90
# File 'lib/pipl/response.rb', line 88

def language
  @person.language if @person
end

#matching_sourcesObject



52
53
54
# File 'lib/pipl/response.rb', line 52

def matching_sources
  @sources.select { |s| s.match == 1.0 } if @sources
end

#nameObject



108
109
110
# File 'lib/pipl/response.rb', line 108

def name
  @person.name if @person
end

#origin_countryObject



96
97
98
# File 'lib/pipl/response.rb', line 96

def origin_country
  @person.origin_country if @person
end

#phoneObject



100
101
102
# File 'lib/pipl/response.rb', line 100

def phone
  @person.phone if @person
end

#relationshipObject



128
129
130
# File 'lib/pipl/response.rb', line 128

def relationship
  @person.relationship if @person
end

#urlObject



116
117
118
# File 'lib/pipl/response.rb', line 116

def url
  @person.url if @person
end

#user_idObject



124
125
126
# File 'lib/pipl/response.rb', line 124

def user_id
  @person.user_id if @person
end

#usernameObject



120
121
122
# File 'lib/pipl/response.rb', line 120

def username
  @person.username if @person
end