piplapis-ruby 4.0.3 → 5.0.0
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.
- data/lib/pipl/client.rb +9 -4
- data/lib/pipl/configurable.rb +2 -1
- data/lib/pipl/consts.rb +3 -1
- data/lib/pipl/containers.rb +4 -2
- data/lib/pipl/default.rb +5 -1
- data/lib/pipl/fields.rb +8 -4
- data/lib/pipl/response.rb +48 -1
- data/lib/pipl/version.rb +1 -1
- metadata +2 -2
data/lib/pipl/client.rb
CHANGED
@@ -99,8 +99,12 @@ module Pipl
|
|
99
99
|
|
100
100
|
unless [Pipl::Configurable::SHOW_SOURCES_ALL,
|
101
101
|
Pipl::Configurable::SHOW_SOURCES_MATCHING,
|
102
|
-
Pipl::Configurable::SHOW_SOURCES_NONE, nil].include? opts[:show_sources]
|
103
|
-
raise ArgumentError.new('show_sources must be one of all, matching or
|
102
|
+
Pipl::Configurable::SHOW_SOURCES_NONE, nil, true, false].include? opts[:show_sources]
|
103
|
+
raise ArgumentError.new('show_sources must be one of all, matching, false or a boolean value')
|
104
|
+
end
|
105
|
+
|
106
|
+
if opts[:match_requirements] and not opts[:match_requirements].is_a? String
|
107
|
+
raise ArgumentError.new('match_requirements must be a String')
|
104
108
|
end
|
105
109
|
|
106
110
|
unless opts.key? :search_pointer
|
@@ -114,10 +118,11 @@ module Pipl
|
|
114
118
|
|
115
119
|
def create_http_request(opts)
|
116
120
|
uri = URI(opts[:api_endpoint])
|
117
|
-
keys = %w(minimum_probability minimum_match hide_sponsored live_feeds show_sources)
|
121
|
+
keys = %w(minimum_probability minimum_match hide_sponsored live_feeds show_sources match_requirements)
|
118
122
|
query_params = ["key=#{opts[:api_key]}"] + keys.map { |k| "#{k}=#{opts[k.to_sym]}" unless opts[k.to_sym].nil? }
|
119
123
|
query_params << opts[:extra] or []
|
120
|
-
uri.query
|
124
|
+
query_params << uri.query
|
125
|
+
uri.query = URI.escape(query_params.compact.join('&'))
|
121
126
|
|
122
127
|
req = Net::HTTP::Post.new(uri.request_uri)
|
123
128
|
req['User-Agent'] = opts[:user_agent]
|
data/lib/pipl/configurable.rb
CHANGED
@@ -7,7 +7,7 @@ module Pipl
|
|
7
7
|
SHOW_SOURCES_NONE = 'false'
|
8
8
|
|
9
9
|
attr_accessor :api_key, :minimum_probability, :minimum_match, :hide_sponsored, :live_feeds, :show_sources
|
10
|
-
attr_accessor :strict_validation, :user_agent
|
10
|
+
attr_accessor :match_requirements, :strict_validation, :user_agent
|
11
11
|
attr_writer :api_endpoint
|
12
12
|
|
13
13
|
class << self
|
@@ -20,6 +20,7 @@ module Pipl
|
|
20
20
|
:hide_sponsored,
|
21
21
|
:live_feeds,
|
22
22
|
:show_sources,
|
23
|
+
:match_requirements,
|
23
24
|
:strict_validation,
|
24
25
|
:api_endpoint,
|
25
26
|
:user_agent
|
data/lib/pipl/consts.rb
CHANGED
@@ -69,6 +69,8 @@ module Pipl
|
|
69
69
|
VI: 'Virgin Islands, U.s.', IS: 'Iceland', IR: 'Iran', AM: 'Armenia', AL: 'Albania', VN: 'Vietnam',
|
70
70
|
AN: 'Netherlands Antilles', AQ: 'Antarctica', AS: 'American Samoa', AR: 'Argentina', AU: 'Australia',
|
71
71
|
VU: 'Vanuat', IO: 'British Indian Ocean Territory', IN: 'India', LB: 'Lebanon', AZ: 'Azerbaijan',
|
72
|
-
IE: 'Ireland', ID: 'Indonesia', PA: 'Panama', UA: 'Ukraine', QA: 'Qatar', MZ: 'Mozambique'
|
72
|
+
IE: 'Ireland', ID: 'Indonesia', PA: 'Panama', UA: 'Ukraine', QA: 'Qatar', MZ: 'Mozambique',
|
73
|
+
BL: 'Saint Barthélemy', BQ: 'Caribbean Netherlands', MF: 'Saint Martin', SS: 'South Sudan',
|
74
|
+
SX: 'Sint Maarten', XK: 'Kosovo', CW: 'Curaçao', RS: 'Serbia'}
|
73
75
|
|
74
76
|
end
|
data/lib/pipl/containers.rb
CHANGED
@@ -231,7 +231,7 @@ module Pipl
|
|
231
231
|
category: h[:@category],
|
232
232
|
origin_url: h[:@origin_url],
|
233
233
|
domain: h[:@domain],
|
234
|
-
source_id: h[:@
|
234
|
+
source_id: h[:@id],
|
235
235
|
person_id: h[:@person_id],
|
236
236
|
match: h[:@match],
|
237
237
|
sponsored: h[:@sponsored],
|
@@ -246,13 +246,14 @@ module Pipl
|
|
246
246
|
|
247
247
|
class Person < FieldsContainer
|
248
248
|
|
249
|
-
attr_reader :id, :match, :search_pointer
|
249
|
+
attr_reader :id, :match, :search_pointer, :inferred
|
250
250
|
|
251
251
|
def initialize(params={})
|
252
252
|
super params
|
253
253
|
@id = params[:id]
|
254
254
|
@match = params[:match]
|
255
255
|
@search_pointer = params[:search_pointer]
|
256
|
+
@inferred = params[:inferred] || false
|
256
257
|
end
|
257
258
|
|
258
259
|
def self.from_hash(h)
|
@@ -260,6 +261,7 @@ module Pipl
|
|
260
261
|
id: h[:@id],
|
261
262
|
match: h[:@match],
|
262
263
|
search_pointer: h[:@search_pointer],
|
264
|
+
inferred: h[:@inferred],
|
263
265
|
}
|
264
266
|
params[:fields] = fields_from_hash(h)
|
265
267
|
self.new(params)
|
data/lib/pipl/default.rb
CHANGED
@@ -4,7 +4,7 @@ module Pipl
|
|
4
4
|
|
5
5
|
module Default
|
6
6
|
|
7
|
-
API_ENDPOINT = 'https://api.pipl.com/search/
|
7
|
+
API_ENDPOINT = 'https://api.pipl.com/search/'.freeze
|
8
8
|
API_KEY = 'sample_key'.freeze
|
9
9
|
USER_AGENT = "piplapis/ruby/#{Pipl::VERSION}".freeze
|
10
10
|
|
@@ -38,6 +38,10 @@ module Pipl
|
|
38
38
|
ENV['PIPL_SHOW_SOURCES']
|
39
39
|
end
|
40
40
|
|
41
|
+
def match_requirements
|
42
|
+
ENV['PIPL_MATCH_REQUIREMENTS']
|
43
|
+
end
|
44
|
+
|
41
45
|
def strict_validation
|
42
46
|
ENV['PIPL_USER_STRICT_VALIDATION']
|
43
47
|
end
|
data/lib/pipl/fields.rb
CHANGED
@@ -9,11 +9,13 @@ module Pipl
|
|
9
9
|
|
10
10
|
include Pipl::Utils
|
11
11
|
|
12
|
-
attr_accessor :valid_since, :inferred
|
12
|
+
attr_accessor :valid_since, :last_seen, :inferred, :current
|
13
13
|
|
14
14
|
def initialize(params={})
|
15
15
|
@valid_since = params[:valid_since]
|
16
|
+
@last_seen = params[:last_seen]
|
16
17
|
@inferred = params[:inferred]
|
18
|
+
@current = params[:current]
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.from_hash(h)
|
@@ -26,10 +28,12 @@ module Pipl
|
|
26
28
|
def self.base_params_from_hash(h)
|
27
29
|
params = {
|
28
30
|
inferred: h[:@inferred],
|
31
|
+
current: h[:@current],
|
29
32
|
type: h[:@type],
|
30
33
|
display: h[:display]
|
31
34
|
}
|
32
35
|
params[:valid_since] = Date.strptime(h[:@valid_since], Pipl::DATE_FORMAT) if h.key? :@valid_since
|
36
|
+
params[:last_seen] = Date.strptime(h[:@last_seen], Pipl::DATE_FORMAT) if h.key? :@last_seen
|
33
37
|
params[:date_range] = Pipl::DateRange.from_hash(h[:date_range]) if h.key? :date_range
|
34
38
|
params
|
35
39
|
end
|
@@ -397,7 +401,9 @@ module Pipl
|
|
397
401
|
|
398
402
|
opts = {width: 100, height: 100, favicon: true, zoom_face: true, use_https: false}.merge(params)
|
399
403
|
schema = opts.delete(:use_https) ? 'https': 'http'
|
400
|
-
|
404
|
+
tokens = @thumbnail_token.gsub(/&dsid=.*/,'')
|
405
|
+
tokens += ',' + opts.delete(:fallback).thumbnail_token.gsub(/&dsid=.*/,'') if opts[:fallback]
|
406
|
+
query_params = ["tokens=#{tokens}"] + opts.map { |k, v| "#{k}=#{v}" unless v.nil? }
|
401
407
|
"#{schema}://thumb.pipl.com/image?#{query_params.compact.join('&')}"
|
402
408
|
end
|
403
409
|
|
@@ -557,8 +563,6 @@ module Pipl
|
|
557
563
|
|
558
564
|
def initialize(params={})
|
559
565
|
super params
|
560
|
-
raise ArgumentError.new("#{params[:content]} is not a valid gender") \
|
561
|
-
unless %w(male female).include? params[:content]
|
562
566
|
@content = params[:content]
|
563
567
|
end
|
564
568
|
|
data/lib/pipl/response.rb
CHANGED
@@ -9,7 +9,7 @@ module Pipl
|
|
9
9
|
class SearchResponse
|
10
10
|
|
11
11
|
attr_reader :query, :person, :sources, :possible_persons, :warnings, :visible_sources, :available_sources
|
12
|
-
attr_reader :search_id, :http_status_code
|
12
|
+
attr_reader :search_id, :http_status_code, :raw_response, :available_data
|
13
13
|
|
14
14
|
def initialize(params={})
|
15
15
|
@query = params[:query]
|
@@ -21,6 +21,8 @@ module Pipl
|
|
21
21
|
@available_sources = params[:available_sources]
|
22
22
|
@search_id = params[:search_id]
|
23
23
|
@http_status_code = params[:http_status_code]
|
24
|
+
@raw_response = params[:raw_response]
|
25
|
+
@available_data = params[:available_data]
|
24
26
|
end
|
25
27
|
|
26
28
|
def self.from_json(json_str)
|
@@ -36,6 +38,8 @@ module Pipl
|
|
36
38
|
params[:available_sources] = h[:@available_sources]
|
37
39
|
params[:search_id] = h[:@search_id]
|
38
40
|
params[:http_status_code] = h[:@http_status_code]
|
41
|
+
params[:raw_response] = json_str
|
42
|
+
params[:available_data] = AvailableData.from_hash(h[:available_data]) if h.key? :available_data
|
39
43
|
|
40
44
|
self.new(params)
|
41
45
|
end
|
@@ -121,6 +125,49 @@ module Pipl
|
|
121
125
|
end
|
122
126
|
|
123
127
|
end
|
128
|
+
|
129
|
+
class AvailableData
|
130
|
+
attr_reader :basic, :premium
|
131
|
+
|
132
|
+
def initialize(params={})
|
133
|
+
@basic = params[:basic]
|
134
|
+
@premium = params[:premium]
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.from_hash(h)
|
138
|
+
params = {}
|
139
|
+
params[:basic] = FieldCount.new(h[:basic]) if h.key? :basic
|
140
|
+
params[:premium] = FieldCount.new(h[:premium]) if h.key? :premium
|
141
|
+
self.new(params)
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
class FieldCount
|
147
|
+
attr_reader :addresses, :ethnicities, :emails, :dobs, :genders, :user_ids, :social_profiles, :educations, :jobs,
|
148
|
+
:images, :languages, :origin_countries, :names, :phones, :relationships, :usernames
|
149
|
+
|
150
|
+
def initialize(params={})
|
151
|
+
@addresses = params[:addresses] || 0
|
152
|
+
@ethnicities = params[:ethnicities] || 0
|
153
|
+
@emails = params[:emails] || 0
|
154
|
+
@dobs = params[:dobs] || 0
|
155
|
+
@genders = params[:genders] || 0
|
156
|
+
@user_ids = params[:user_ids] || 0
|
157
|
+
@social_profiles = params[:social_profiles] || 0
|
158
|
+
@educations = params[:educations] || 0
|
159
|
+
@jobs = params[:jobs] || 0
|
160
|
+
@images = params[:images] || 0
|
161
|
+
@languages = params[:languages] || 0
|
162
|
+
@origin_countries = params[:origin_countries] || 0
|
163
|
+
@names = params[:names] || 0
|
164
|
+
@phones = params[:phones] || 0
|
165
|
+
@relationships = params[:relationships] || 0
|
166
|
+
@usernames = params[:usernames] || 0
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
124
171
|
end
|
125
172
|
|
126
173
|
end
|
data/lib/pipl/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piplapis-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|