Class: Pipl::Client::SearchResponse
- Inherits:
-
Object
- Object
- Pipl::Client::SearchResponse
- Defined in:
- lib/pipl/response.rb
Instance Attribute Summary collapse
-
#available_sources ⇒ Object
readonly
Returns the value of attribute available_sources.
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
-
#person ⇒ Object
readonly
Returns the value of attribute person.
-
#possible_persons ⇒ Object
readonly
Returns the value of attribute possible_persons.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#search_id ⇒ Object
readonly
Returns the value of attribute search_id.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
-
#visible_sources ⇒ Object
readonly
Returns the value of attribute visible_sources.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
- #age ⇒ Object
- #education ⇒ Object
- #email ⇒ Object
- #ethnicity ⇒ Object
- #gender ⇒ Object
- #group_sources_by_category ⇒ Object
- #group_sources_by_domain ⇒ Object
- #group_sources_by_match ⇒ Object
- #image ⇒ Object
-
#initialize(params = {}) ⇒ SearchResponse
constructor
A new instance of SearchResponse.
- #job ⇒ Object
- #language ⇒ Object
- #matching_sources ⇒ Object
- #name ⇒ Object
- #origin_country ⇒ Object
- #phone ⇒ Object
- #relationship ⇒ Object
- #url ⇒ Object
- #user_id ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ SearchResponse
Returns a new instance of SearchResponse.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pipl/response.rb', line 14 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] end |
Instance Attribute Details
#available_sources ⇒ Object (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_code ⇒ Object (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 |
#person ⇒ Object (readonly)
Returns the value of attribute person.
11 12 13 |
# File 'lib/pipl/response.rb', line 11 def person @person end |
#possible_persons ⇒ Object (readonly)
Returns the value of attribute possible_persons.
11 12 13 |
# File 'lib/pipl/response.rb', line 11 def possible_persons @possible_persons end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
11 12 13 |
# File 'lib/pipl/response.rb', line 11 def query @query end |
#search_id ⇒ Object (readonly)
Returns the value of attribute search_id.
12 13 14 |
# File 'lib/pipl/response.rb', line 12 def search_id @search_id end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
11 12 13 |
# File 'lib/pipl/response.rb', line 11 def sources @sources end |
#visible_sources ⇒ Object (readonly)
Returns the value of attribute visible_sources.
11 12 13 |
# File 'lib/pipl/response.rb', line 11 def visible_sources @visible_sources end |
#warnings ⇒ Object (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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pipl/response.rb', line 26 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] self.new(params) end |
Instance Method Details
#address ⇒ Object
71 72 73 |
# File 'lib/pipl/response.rb', line 71 def address @person.address if @person end |
#age ⇒ Object
63 64 65 |
# File 'lib/pipl/response.rb', line 63 def age @person.age if @person end |
#education ⇒ Object
75 76 77 |
# File 'lib/pipl/response.rb', line 75 def education @person.education if @person end |
#email ⇒ Object
95 96 97 |
# File 'lib/pipl/response.rb', line 95 def email @person.email if @person end |
#ethnicity ⇒ Object
83 84 85 |
# File 'lib/pipl/response.rb', line 83 def ethnicity @person.ethnicity if @person end |
#gender ⇒ Object
59 60 61 |
# File 'lib/pipl/response.rb', line 59 def gender @person.gender if @person end |
#group_sources_by_category ⇒ Object
51 52 53 |
# File 'lib/pipl/response.rb', line 51 def group_sources_by_category @sources.group_by { |s| s.category } if @sources end |
#group_sources_by_domain ⇒ Object
47 48 49 |
# File 'lib/pipl/response.rb', line 47 def group_sources_by_domain @sources.group_by { |s| s.domain } if @sources end |
#group_sources_by_match ⇒ Object
55 56 57 |
# File 'lib/pipl/response.rb', line 55 def group_sources_by_match @sources.group_by { |s| s.match } if @sources end |
#image ⇒ Object
103 104 105 |
# File 'lib/pipl/response.rb', line 103 def image @person.image if @person end |
#job ⇒ Object
67 68 69 |
# File 'lib/pipl/response.rb', line 67 def job @person.job if @person end |
#language ⇒ Object
79 80 81 |
# File 'lib/pipl/response.rb', line 79 def language @person.language if @person end |
#matching_sources ⇒ Object
43 44 45 |
# File 'lib/pipl/response.rb', line 43 def matching_sources @sources.select { |s| s.match == 1.0 } if @sources end |
#name ⇒ Object
99 100 101 |
# File 'lib/pipl/response.rb', line 99 def name @person.name if @person end |
#origin_country ⇒ Object
87 88 89 |
# File 'lib/pipl/response.rb', line 87 def origin_country @person.origin_country if @person end |
#phone ⇒ Object
91 92 93 |
# File 'lib/pipl/response.rb', line 91 def phone @person.phone if @person end |
#relationship ⇒ Object
119 120 121 |
# File 'lib/pipl/response.rb', line 119 def relationship @person.relationship if @person end |
#url ⇒ Object
107 108 109 |
# File 'lib/pipl/response.rb', line 107 def url @person.url if @person end |
#user_id ⇒ Object
115 116 117 |
# File 'lib/pipl/response.rb', line 115 def user_id @person.user_id if @person end |
#username ⇒ Object
111 112 113 |
# File 'lib/pipl/response.rb', line 111 def username @person.username if @person end |