piplapis-ruby 5.0.4 → 5.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a9ec065bf1afe0724361330927ccb35dc910cf36
4
- data.tar.gz: 756f3b62d694449389e39b7c1a148df89d531d69
2
+ SHA256:
3
+ metadata.gz: 113f611d2dd082289e53720edc079b6397493f344f7cbbcb7a86136fb17eb7a0
4
+ data.tar.gz: '06916e4e2a57b73b55c05c34d0eeb89a52436d6b19fd8178f682bfaff1149d3f'
5
5
  SHA512:
6
- metadata.gz: db49fce2bcbe5f2b9e6307c0a125c2f61f5c1f10fa4b59e1dd805600facfefdacd53258e61bff9f716c4ceedc169d411787a7d4d971e3c63a894b9c46ba0daab
7
- data.tar.gz: 178270c9e6675ca1c7f16472620d6342780261d0108e12ccbf2fe3e9e04aa7ce2b6bc42c46d0910d0acc2ef2d5a8804b724c362dac75f79cab9ac3db3ae6e92f
6
+ metadata.gz: 645882962cf240ced9465bda799ab0620058a5eca2dbc0f409568e7dabe8f41d29b8d7b0ccc6881a33d025609c0a61b18d3c3146675eaa30da64d171f49c0cee
7
+ data.tar.gz: bb0261752d58e65c4887077f44f7ccc0abb8bd5c0eadd563d94973d6e9e671e02ee0484630394ac89257ca346ed915127922e02fe563d04e5a2e8ce39dabb542
data/README.md CHANGED
@@ -1,25 +1,22 @@
1
- Pipl API Ruby Library
2
- ===========================
1
+ # Pipl API Ruby Library
3
2
 
4
- This is the official Ruby client library for easily integrating Pipl's APIs into your application.
3
+ This is a Ruby client library for easily integrating Pipl's APIs into your application.
5
4
 
6
- * Full details about Pipl's API - [https://pipl.com/dev/](https://pipl.com/dev/)
7
- * This library is available in other languages - [https://pipl.com/dev/guide/code_libraries](https://pipl.com/dev/guide/code_libraries)
5
+ - Full details about Pipl's APIs - [https://pipl.com/api](https://pipl.com/api)
6
+ - This library is available in other languages - [https://docs.pipl.com/docs/code-libraries](https://docs.pipl.com/docs/code-libraries)
8
7
 
9
- Library Requirements
10
- --------------------
8
+ ## Library Requirements
11
9
 
12
- * Ruby 1.9 and above.
10
+ - From Ruby SDK version 5.2.0 and above, Ruby 3.0 and above is supported
13
11
 
14
- Getting Started & Code Snippets
15
- -------------------------------
12
+ ## Getting Started & Code Snippets
16
13
 
17
14
  **Pipl's Search API**
18
- * Code snippets - [https://pipl.com/dev/guide/code_snippets](https://pipl.com/dev/guide/code_snippets)
19
- * Full reference - [https://pipl.com/dev/reference/](https://pipl.com/dev/reference/)
20
15
 
16
+ - API Portal - [https://pipl.com/api/](https://pipl.com/api/)
17
+ - Code snippets - [https://docs.pipl.com/docs/code-snippets](https://docs.pipl.com/docs/code-snippets)
18
+ - Full reference - [https://docs.pipl.com/reference/](https://docs.pipl.com/reference/)
21
19
 
22
- Credits
23
- -------
20
+ ## Credits
24
21
 
25
22
  Thanks to [srochy](https://github.com/srochy) for writing the first version this library!
data/lib/pipl/client.rb CHANGED
@@ -14,8 +14,18 @@ module Pipl
14
14
 
15
15
  include Pipl::Configurable
16
16
 
17
- QUERY_PARAMS = %w(minimum_probability minimum_match hide_sponsored live_feeds show_sources match_requirements
18
- source_category_requirements infer_persons)
17
+ QUERY_PARAMS = %w(
18
+ minimum_probability
19
+ minimum_match
20
+ hide_sponsored
21
+ live_feeds
22
+ show_sources
23
+ match_requirements
24
+ source_category_requirements
25
+ infer_persons
26
+ top_match
27
+ api_version
28
+ )
19
29
 
20
30
  def initialize(options = {})
21
31
  Pipl::Configurable.keys.each do |key|
@@ -35,7 +45,7 @@ module Pipl
35
45
  http, req = create_http_request(opts)
36
46
  if opts.key? :callback
37
47
  do_send_async http, req, opts[:callback]
38
- elsif opts[:async] and block_given?
48
+ elsif opts[:async] && block_given?
39
49
  do_send_async http, req, Proc.new
40
50
  else
41
51
  do_send http, req
@@ -52,6 +62,8 @@ module Pipl
52
62
  person.add_field Pipl::Email.new(address: opts[:email]) if opts[:email]
53
63
  person.add_field Pipl::Username.new(content: opts[:username]) if opts[:username]
54
64
  person.add_field Pipl::Address.new(raw: opts[:raw_address]) if opts[:raw_address]
65
+ person.add_field Pipl::Url.new(url: opts[:url]) if opts[:url]
66
+ person.add_field Pipl::Vehicle.new(vin: opts[:vin]) if opts[:vin]
55
67
 
56
68
  if opts[:first_name] || opts[:middle_name] || opts[:last_name]
57
69
  person.add_field Pipl::Name.new(first: opts[:first_name], middle: opts[:middle_name], last: opts[:last_name])
@@ -77,26 +89,26 @@ module Pipl
77
89
  end
78
90
 
79
91
  def validate_search_params(opts)
80
- unless opts[:api_key] and not opts[:api_key].empty?
92
+ unless opts[:api_key] && !opts[:api_key].empty?
81
93
  raise ArgumentError.new('API key is missing')
82
94
  end
83
95
 
84
- if opts[:search_pointer] and opts[:search_pointer].empty?
96
+ if opts[:search_pointer] && opts[:search_pointer].empty?
85
97
  raise ArgumentError.new('Given search pointer is empty')
86
98
  end
87
99
 
88
100
  unless opts.key? :search_pointer
89
- unless opts[:person] and opts[:person].is_searchable?
90
- raise ArgumentError.new('No valid name/username/user_id/phone/email/address or search pointer in request')
101
+ unless opts[:person] && opts[:person].is_searchable?
102
+ raise ArgumentError.new('No valid name/username/user_id/phone/email/address/vin or search pointer in request')
91
103
  end
92
104
  end
93
105
 
94
106
  if opts[:strict_validation]
95
- if opts[:minimum_probability] and not (0..1).include? opts[:minimum_probability]
107
+ if opts[:minimum_probability] && !(0..1).include?(opts[:minimum_probability])
96
108
  raise ArgumentError.new('minimum_probability must be a float in 0..1')
97
109
  end
98
110
 
99
- if opts[:minimum_match] and not (0..1).include? opts[:minimum_match]
111
+ if opts[:minimum_match] && !(0..1).include?(opts[:minimum_match])
100
112
  raise ArgumentError.new('minimum_match must be a float in 0..1')
101
113
  end
102
114
 
@@ -106,34 +118,46 @@ module Pipl
106
118
  raise ArgumentError.new('show_sources must be one of all, matching, false or a boolean value')
107
119
  end
108
120
 
109
- if opts[:match_requirements] and not opts[:match_requirements].is_a? String
121
+ if opts[:match_requirements] && !opts[:match_requirements].is_a?(String)
110
122
  raise ArgumentError.new('match_requirements must be a String')
111
123
  end
112
124
 
113
- if opts[:source_category_requirements] and not opts[:source_category_requirements].is_a? String
125
+ if opts[:source_category_requirements] && !opts[:source_category_requirements].is_a?(String)
114
126
  raise ArgumentError.new('source_category_requirements must be a String')
115
127
  end
116
128
 
117
- if opts[:infer_persons] and not [nil, false, true].include? opts[:infer_persons]
129
+ if opts[:infer_persons] && ! [nil, false, true].include?(opts[:infer_persons])
118
130
  raise ArgumentError.new('infer_persons must be true, false or nil')
119
131
  end
120
132
 
133
+ if opts[:top_match] && ! [nil, false, true].include?(opts[:top_match])
134
+ raise ArgumentError.new('top_match must be true, false or nil')
135
+ end
136
+
121
137
  unless opts.key? :search_pointer
122
138
  unsearchable = opts[:person].unsearchable_fields
123
- if unsearchable and not unsearchable.empty?
139
+ if unsearchable && ! unsearchable.empty?
124
140
  raise ArgumentError.new("Some fields are unsearchable: #{unsearchable}")
125
141
  end
126
142
  end
127
143
  end
128
144
  end
129
145
 
146
+ def get_api_version(opts)
147
+ api_version = opts[:api_version].to_s.gsub(/\.0$/, "") unless opts[:api_version].nil?
148
+ api_version ? api_version : DEFAULT_API_VERSION
149
+ end
150
+
130
151
  def create_http_request(opts)
131
- uri = URI(opts[:api_endpoint])
132
- query_params = ["key=#{opts[:api_key]}"] +
133
- QUERY_PARAMS.map { |k| "#{k}=#{opts[k.to_sym]}" unless opts[k.to_sym].nil? }
134
- query_params << opts[:extra] or []
152
+ api_version = get_api_version(opts)
153
+ uri = URI("#{opts[:api_endpoint]}v#{api_version}/")
154
+ query_params = ["key=#{opts[:api_key]}"]
155
+ QUERY_PARAMS.each do |k|
156
+ query_params << "#{k}=#{URI.encode_www_form_component(opts[k.to_sym])}" unless opts[k.to_sym].nil?
157
+ end
158
+ query_params << opts[:extra]
135
159
  query_params << uri.query
136
- uri.query = URI.escape(query_params.compact.join('&'))
160
+ uri.query = query_params.compact.join('&')
137
161
 
138
162
  req = Net::HTTP::Post.new(uri.request_uri)
139
163
  req['User-Agent'] = opts[:user_agent]
@@ -5,27 +5,30 @@ module Pipl
5
5
  SHOW_SOURCES_ALL = 'all'
6
6
  SHOW_SOURCES_MATCHING = 'matching'
7
7
  SHOW_SOURCES_NONE = 'false'
8
+ DEFAULT_API_VERSION = 5
8
9
 
9
10
  attr_accessor :api_key, :minimum_probability, :minimum_match, :hide_sponsored, :live_feeds, :show_sources
10
11
  attr_accessor :match_requirements, :source_category_requirements, :infer_persons, :strict_validation, :user_agent
12
+ attr_accessor :top_match
11
13
  attr_writer :api_endpoint
12
14
 
13
15
  class << self
14
16
 
15
17
  def keys
16
18
  @keys ||= [
17
- :api_key,
18
- :minimum_probability,
19
- :minimum_match,
20
- :hide_sponsored,
21
- :live_feeds,
22
- :show_sources,
23
- :match_requirements,
24
- :source_category_requirements,
25
- :infer_persons,
26
- :strict_validation,
27
- :api_endpoint,
28
- :user_agent
19
+ :api_key,
20
+ :minimum_probability,
21
+ :minimum_match,
22
+ :hide_sponsored,
23
+ :live_feeds,
24
+ :show_sources,
25
+ :match_requirements,
26
+ :source_category_requirements,
27
+ :infer_persons,
28
+ :strict_validation,
29
+ :api_endpoint,
30
+ :user_agent,
31
+ :top_match
29
32
  ]
30
33
  end
31
34
 
@@ -22,10 +22,11 @@ module Pipl
22
22
  OriginCountry: 'origin_countries',
23
23
  Relationship: 'relationships',
24
24
  Tag: 'tags',
25
+ Vehicle: 'vehicles',
25
26
  }
26
27
 
27
28
  attr_reader :names, :addresses, :phones, :emails, :jobs, :educations, :images, :usernames, :user_ids, :urls
28
- attr_reader :relationships, :tags, :ethnicities, :languages, :origin_countries, :dob, :gender
29
+ attr_reader :relationships, :tags, :ethnicities, :languages, :origin_countries, :dob, :gender, :vehicles
29
30
 
30
31
  def initialize(params={})
31
32
  @names = []
@@ -45,6 +46,7 @@ module Pipl
45
46
  @tags = []
46
47
  @dob = nil
47
48
  @gender = nil
49
+ @vehicles = []
48
50
 
49
51
  add_fields params[:fields] if params.key? :fields
50
52
  end
@@ -72,7 +74,7 @@ module Pipl
72
74
  fields = instance_variable_get("@#{container}")
73
75
  h[container.to_sym] = fields.map { |field| field.to_hash }.compact unless fields.empty?
74
76
  end
75
- h.reject { |_, value| value.nil? or (value.kind_of?(Array) and value.empty?) }
77
+ h.reject { |_, value| value.nil? || (value.kind_of?(Array) && value.empty?) }
76
78
  end
77
79
 
78
80
  def add_fields(fields)
@@ -157,6 +159,10 @@ module Pipl
157
159
  @relationships.first unless @relationships.empty?
158
160
  end
159
161
 
162
+ def vehicle
163
+ @vehicles.first unless @vehicles.empty?
164
+ end
165
+
160
166
  end
161
167
 
162
168
 
@@ -269,20 +275,21 @@ module Pipl
269
275
 
270
276
  def to_hash
271
277
  h = {}
272
- h[:search_pointer] = @search_pointer if @search_pointer and not @search_pointer.empty?
278
+ h[:search_pointer] = @search_pointer if @search_pointer && ! @search_pointer.empty?
273
279
  h.update(fields_to_hash)
274
280
  h
275
281
  end
276
282
 
277
283
  def is_searchable?
278
- not @search_pointer.nil? or
279
- @names.any? { |f| f.is_searchable? } or
280
- @emails.any? { |f| f.is_searchable? } or
281
- @phones.any? { |f| f.is_searchable? } or
282
- @usernames.any? { |f| f.is_searchable? } or
283
- @user_ids.any? { |f| f.is_searchable? } or
284
- @urls.any? { |f| f.is_searchable? } or
285
- @addresses.any? { |f| f.is_sole_searchable? }
284
+ !@search_pointer.nil? ||
285
+ @names.any? { |f| f.is_searchable? } ||
286
+ @emails.any? { |f| f.is_searchable? } ||
287
+ @phones.any? { |f| f.is_searchable? } ||
288
+ @usernames.any? { |f| f.is_searchable? } ||
289
+ @user_ids.any? { |f| f.is_searchable? } ||
290
+ @urls.any? { |f| f.is_searchable? } ||
291
+ @addresses.any? { |f| f.is_sole_searchable? } ||
292
+ @vehicles.any? { |f| f.is_searchable? }
286
293
  end
287
294
 
288
295
  def unsearchable_fields
data/lib/pipl/default.rb CHANGED
@@ -4,8 +4,8 @@ module Pipl
4
4
 
5
5
  module Default
6
6
 
7
- API_ENDPOINT = 'https://api.pipl.com/search/'.freeze
8
- API_KEY = 'sample_key'.freeze
7
+ # API_ENDPOINT = 'https://api.pipl.com/search/'.freeze
8
+ API_ENDPOINT = 'https://qa-api.pipl.pro/apis/gateway/search/'.freeze
9
9
  USER_AGENT = "piplapis/ruby/#{Pipl::VERSION}".freeze
10
10
 
11
11
  class << self
@@ -15,7 +15,7 @@ module Pipl
15
15
  end
16
16
 
17
17
  def api_key
18
- ENV.fetch 'PIPL_API_KEY', API_KEY
18
+ ENV['PIPL_API_KEY']
19
19
  end
20
20
 
21
21
  def minimum_probability
@@ -62,6 +62,10 @@ module Pipl
62
62
  ENV.fetch 'PIPL_USER_AGENT', USER_AGENT
63
63
  end
64
64
 
65
+ def top_match
66
+ ENV['PIPL_TOP_MATCH']
67
+ end
68
+
65
69
  end
66
70
  end
67
71
  end
data/lib/pipl/errors.rb CHANGED
@@ -33,7 +33,7 @@
33
33
  end
34
34
 
35
35
  def is_pipl_error?
36
- not is_user_error?
36
+ ! is_user_error?
37
37
  end
38
38
 
39
39
  def self.deserialize(json_str, headers={})
@@ -59,4 +59,4 @@
59
59
 
60
60
  end
61
61
 
62
- end
62
+ end
data/lib/pipl/fields.rb CHANGED
@@ -90,7 +90,7 @@ module Pipl
90
90
  first = Pipl::Utils.alpha_chars(@first || '')
91
91
  last = Pipl::Utils.alpha_chars(@last || '')
92
92
  raw = Pipl::Utils.alpha_chars(@raw || '')
93
- (first.length > 1 and last.length > 1) or raw.length > 3
93
+ first.length > 0 || last.length > 0 || raw.length > 0
94
94
  end
95
95
 
96
96
  def to_s
@@ -146,12 +146,12 @@ module Pipl
146
146
  end
147
147
 
148
148
  def is_valid_country?
149
- @country and Pipl::COUNTRIES.key? @country.upcase.to_sym
149
+ @country && Pipl::COUNTRIES.key?(@country.upcase.to_sym)
150
150
  end
151
151
 
152
152
  def is_valid_state?
153
- is_valid_country? and Pipl::STATES.key?(@country.upcase.to_sym) and
154
- @state and Pipl::STATES[@country.upcase.to_sym].key?(@state.upcase.to_sym)
153
+ is_valid_country? && Pipl::STATES.key?(@country.upcase.to_sym) and
154
+ @state && Pipl::STATES[@country.upcase.to_sym].key?(@state.upcase.to_sym)
155
155
  end
156
156
 
157
157
  def to_hash
@@ -161,11 +161,11 @@ module Pipl
161
161
  end
162
162
 
163
163
  def is_searchable?
164
- [@raw, @country, @state, @city].any? {|x| not x.to_s.empty?}
164
+ [@raw, @country, @state, @city].any? {|x| ! x.to_s.empty?}
165
165
  end
166
166
 
167
167
  def is_sole_searchable?
168
- not @raw.to_s.empty? or [@city, @street, @house].all? {|x| not x.to_s.empty?}
168
+ ! @raw.to_s.empty? || [@city, @street, @house].all? {|x| ! x.to_s.empty?}
169
169
  end
170
170
 
171
171
  def country_full
@@ -184,12 +184,12 @@ module Pipl
184
184
  vals = [@street, @city, state, country]
185
185
  s = vals.any? ? vals.select { |v| v }.join(', ') : ''
186
186
 
187
- if @street and (@house or @apartment)
188
- prefix = [@house, @apartment].select { |v| v and not v.empty? }.join('-')
187
+ if @street && (@house || @apartment)
188
+ prefix = [@house, @apartment].select { |v| v && ! v.empty? }.join('-')
189
189
  s = prefix + ' ' + (s || '')
190
190
  end
191
191
 
192
- if @po_box and @street.nil?
192
+ if @po_box && @street.nil?
193
193
  s = "P.O. Box #{@po_box} " + (s || '')
194
194
  end
195
195
 
@@ -222,7 +222,7 @@ module Pipl
222
222
  # @!attribute display_international
223
223
  # @return [String] Well formatted international representation of this phone number for display purposes.
224
224
 
225
- attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international
225
+ attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip
226
226
 
227
227
  def initialize(params={})
228
228
  super params
@@ -233,6 +233,7 @@ module Pipl
233
233
  @raw = params[:raw]
234
234
  @display = params[:display]
235
235
  @display_international = params[:display_international]
236
+ @voip = params[:@voip] unless params[:@voip].nil?
236
237
  end
237
238
 
238
239
  def self.extra_metadata
@@ -245,7 +246,7 @@ module Pipl
245
246
  end
246
247
 
247
248
  def is_searchable?
248
- (@raw and not @raw.empty?) or not @number.nil?
249
+ (@raw && ! @raw.empty?) || ! @number.nil?
249
250
  end
250
251
 
251
252
  end
@@ -282,11 +283,11 @@ module Pipl
282
283
  end
283
284
 
284
285
  def is_valid_email?
285
- not RE_EMAIL.match(@address).nil?
286
+ ! RE_EMAIL.match(@address).nil?
286
287
  end
287
288
 
288
289
  def is_searchable?
289
- is_valid_email? or (not @address_md5.nil? and @address_md5.length == 32)
290
+ is_valid_email? || (! @address_md5.nil? && @address_md5.length == 32)
290
291
  end
291
292
 
292
293
  def to_hash
@@ -326,13 +327,13 @@ module Pipl
326
327
  def to_s
327
328
  return @display if @display
328
329
 
329
- if @title and @organization
330
+ if @title && @organization
330
331
  s = @title + ' at ' + @organization
331
332
  else
332
333
  s = @title || @organization
333
334
  end
334
335
 
335
- if s and @industry
336
+ if s && @industry
336
337
  if @date_range
337
338
  range = @date_range.years_range
338
339
  s += ' (%s, %d-%d)' % [@industry, range[0], range[1]]
@@ -341,7 +342,7 @@ module Pipl
341
342
  end
342
343
  else
343
344
  s = ((s || '') + ' ' + (@industry || '')).strip
344
- if s and @date_range
345
+ if s && @date_range
345
346
  range = @date_range.years_range
346
347
  s += ' (%d-%d)' % [range[0], range[1]]
347
348
  end
@@ -373,13 +374,13 @@ module Pipl
373
374
  def to_s
374
375
  return @display if @display
375
376
 
376
- if @degree and @school
377
+ if @degree && @school
377
378
  s = @degree + ' from ' + @school
378
379
  else
379
380
  s = @degree || @school
380
381
  end
381
382
 
382
- if s and @date_range
383
+ if s && @date_range
383
384
  range = @date_range.years_range
384
385
  s += ' (%d-%d)' % [range[0], range[1]]
385
386
  end
@@ -428,7 +429,7 @@ module Pipl
428
429
  end
429
430
 
430
431
  def is_searchable?
431
- !@content.nil? and Pipl::Utils.alnum_chars(@content).length > 3
432
+ !@content.nil? && Pipl::Utils.alnum_chars(@content).length > 2
432
433
  end
433
434
 
434
435
  end
@@ -437,7 +438,7 @@ module Pipl
437
438
  class UserID < Username
438
439
 
439
440
  def is_searchable?
440
- not /.+@.+/.match(@content).nil?
441
+ ! /.+@.+/.match(@content).nil?
441
442
  end
442
443
 
443
444
  end
@@ -468,7 +469,7 @@ module Pipl
468
469
  end
469
470
 
470
471
  def self.from_age_range(start_age, end_age)
471
- raise ArgumentError.new('start_age and end_age can\'t be negative') if start_age < 0 or end_age < 0
472
+ raise ArgumentError.new('start_age and end_age can\'t be negative') if start_age < 0 || end_age < 0
472
473
 
473
474
  if start_age > end_age
474
475
  start_age, end_age = end_age, start_age
@@ -482,7 +483,7 @@ module Pipl
482
483
  end
483
484
 
484
485
  def to_s
485
- @display or Pipl::Utils.to_utf8(age.to_s)
486
+ @display || Pipl::Utils.to_utf8(age.to_s)
486
487
  end
487
488
 
488
489
  def age
@@ -490,14 +491,14 @@ module Pipl
490
491
  dob = @date_range.middle
491
492
  today = Date.today
492
493
  diff = today.year - dob.year
493
- diff = diff - 1 if dob.month > today.month or (dob.month >= today.month and dob.day > today.day)
494
+ diff = diff - 1 if dob.month > today.month || (dob.month >= today.month && dob.day > today.day)
494
495
  diff
495
496
  end
496
497
  end
497
498
 
498
499
  def age_range
499
500
  if @date_range
500
- return [self.age, self.age] unless @date_range.start and @date_range.end
501
+ return [self.age, self.age] unless @date_range.start && @date_range.end
501
502
  start_age = DOB.new({date_range: Pipl::DateRange.new(@date_range.start, @date_range.start)}).age
502
503
  end_age = DOB.new({date_range: Pipl::DateRange.new(@date_range.end, @date_range.end)}).age
503
504
  return end_age, start_age
@@ -511,7 +512,7 @@ module Pipl
511
512
  end
512
513
 
513
514
  def is_searchable?
514
- not @date_range.nil?
515
+ ! @date_range.nil?
515
516
  end
516
517
 
517
518
  end
@@ -559,7 +560,11 @@ module Pipl
559
560
  end
560
561
 
561
562
  def is_searchable?
562
- not @url.to_s.empty?
563
+ ! @url.to_s.empty?
564
+ end
565
+
566
+ def to_hash
567
+ {url: @url} if @url
563
568
  end
564
569
 
565
570
  end
@@ -635,8 +640,8 @@ module Pipl
635
640
 
636
641
  def to_s
637
642
  return @display if @display
638
- return "#{@language}_#{@region}" if @language and @region
639
- return @language if @language and not @language.empty?
643
+ return "#{@language}_#{@region}" if @language && @region
644
+ return @language if @language && ! @language.empty?
640
645
  @region
641
646
  end
642
647
 
@@ -687,27 +692,27 @@ module Pipl
687
692
  def initialize(start, end_)
688
693
  @start = start
689
694
  @end = end_
690
- if @start and @end and @start > @end
695
+ if @start && @end && @start > @end
691
696
  @start, @end = @end, @start
692
697
  end
693
698
  end
694
699
 
695
700
  # def ==(other)
696
- # other.instance_of?(self.class) and inspect == other.inspect
701
+ # other.instance_of?(self.class) && inspect == other.inspect
697
702
  # end
698
703
  #
699
704
  # alias_method :eql?, :==
700
705
 
701
706
  def is_exact?
702
- @start and @end and @start == @end
707
+ @start && @end && @start == @end
703
708
  end
704
709
 
705
710
  def middle
706
- @start and @end ? @start + ((@end - @start) / 2) : @start or @end
711
+ @start && @end ? @start + ((@end - @start) / 2) : @start || @end
707
712
  end
708
713
 
709
714
  def years_range
710
- [@start.year, @end.year] if @start and @end
715
+ [@start.year, @end.year] if @start && @end
711
716
  end
712
717
 
713
718
  def self.from_years_range(start_year, end_year)
@@ -729,4 +734,71 @@ module Pipl
729
734
  end
730
735
  end
731
736
 
737
+ class Vehicle < Field
738
+ attr_accessor :vin, :year, :make, :model, :color, :vehicle_type, :display
739
+
740
+ def initialize(params={})
741
+ @vin = params[:vin]
742
+ @year = params[:year]
743
+ @make = params[:make]
744
+ @model = params[:model]
745
+ @color = params[:color]
746
+ @vehicle_type = params[:vehicle_type]
747
+ @display = params[:display]
748
+ end
749
+
750
+ def to_hash
751
+ {vin: @vin, year: @year, make: @make, model: @model, color: @color, vehicle_type: @vehicle_type}
752
+ .reject { |_, value| value.nil? }
753
+ end
754
+
755
+ def validate_vin(vin)
756
+ vin_valid = true
757
+ if vin
758
+ vin_valid = vin.length == 17 &&
759
+ !(vin.downcase.chars.to_set & %w[i o q]).any? &&
760
+ !%w[u z 0].include?(vin[9].downcase) &&
761
+ vin.match?(/\A\w+\z/)
762
+ vin_valid &&= validate_vin_checksum(vin) if vin_valid
763
+ end
764
+ vin_valid
765
+ end
766
+
767
+ def validate_vin_checksum(vin)
768
+ vin = vin.downcase
769
+ check_digit = vin[8]
770
+
771
+ return false if check_digit.nil? # Handle the case when check_digit is nil
772
+
773
+ replace_map = {
774
+ "1" => ["a", "j"],
775
+ "2" => ["b", "k", "s"],
776
+ "3" => ["c", "l", "t"],
777
+ "4" => ["d", "m", "u"],
778
+ "5" => ["e", "n", "v"],
779
+ "6" => ["f", "w"],
780
+ "7" => ["g", "p", "x"],
781
+ "8" => ["h", "y"],
782
+ "9" => ["r", "z"]
783
+ }
784
+ positional_weights = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
785
+
786
+ replace_map.each do |digit, replacements|
787
+ replacements.each do |c|
788
+ vin.gsub!(c, digit)
789
+ end
790
+ end
791
+
792
+ checksum = vin.chars.each_with_index.reject { |_, i| i == 8 }.sum { |num, i| num.to_i * positional_weights[i] } % 11
793
+
794
+ checksum = 'x' if checksum == 10
795
+ checksum.to_s == check_digit.to_s # Convert check_digit to string for comparison
796
+ end
797
+
798
+ def is_searchable?
799
+ validate_vin(@vin)
800
+ end
801
+
802
+ end
803
+
732
804
  end
data/lib/pipl/response.rb CHANGED
@@ -168,6 +168,10 @@ module Pipl
168
168
  @person.relationship if @person
169
169
  end
170
170
 
171
+ def vehicle
172
+ @person.vehicle if @person
173
+ end
174
+
171
175
  end
172
176
 
173
177
  class AvailableData
@@ -188,14 +192,16 @@ module Pipl
188
192
  end
189
193
 
190
194
  class FieldCount
191
- attr_reader :addresses, :ethnicities, :emails, :dobs, :genders, :user_ids, :social_profiles, :educations, :jobs,
192
- :images, :languages, :origin_countries, :names, :phones, :mobile_phones, :landline_phones,
193
- :relationships, :usernames
195
+ attr_reader :addresses, :ethnicities, :emails, :work_emails, :personal_emails, :dobs, :genders, :user_ids, :social_profiles, :educations, :jobs,
196
+ :images, :languages, :origin_countries, :names, :phones, :mobile_phones, :landline_phones, :voip_phones,
197
+ :relationships, :usernames, :vehicles
194
198
 
195
199
  def initialize(params={})
196
200
  @addresses = params[:addresses] || 0
197
201
  @ethnicities = params[:ethnicities] || 0
198
202
  @emails = params[:emails] || 0
203
+ @work_emails = params[:work_emails] || 0
204
+ @personal_emails = params[:personal_emails] || 0
199
205
  @dobs = params[:dobs] || 0
200
206
  @genders = params[:genders] || 0
201
207
  @user_ids = params[:user_ids] || 0
@@ -208,9 +214,11 @@ module Pipl
208
214
  @names = params[:names] || 0
209
215
  @phones = params[:phones] || 0
210
216
  @mobile_phones = params[:mobile_phones] || 0
217
+ @voip_phones = params[:voip_phones] || 0
211
218
  @landline_phones = params[:landline_phones] || 0
212
219
  @relationships = params[:relationships] || 0
213
220
  @usernames = params[:usernames] || 0
221
+ @vehicles = params[:vehicles] || 0
214
222
  end
215
223
 
216
224
  end
data/lib/pipl/utils.rb CHANGED
@@ -16,7 +16,7 @@ module Pipl
16
16
  end
17
17
 
18
18
  def is_valid_url?(url)
19
- not ((url =~ URI::ABS_URI).nil?)
19
+ ! ((url =~ URI::ABS_URI).nil?)
20
20
  end
21
21
 
22
22
  def alpha_chars(s)
data/lib/pipl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pipl
2
- VERSION = '5.0.4'.freeze
3
- end
2
+ VERSION = '5.2.0'.freeze
3
+ end
data/pipl.gemspec CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |spec|
7
7
  spec.summary = 'Ruby bindings for the Pipl API'
8
8
  spec.description = 'Pipl is the most comprehensive people search on the web. See https://pipl.com for details.'
9
9
  spec.homepage = 'https://github.com/piplcom/piplapis-ruby'
10
- spec.authors = ['Edo Shor']
11
- spec.email = ['edo.shor@pipl.com']
12
- spec.license = 'Apache 2.0'
10
+ spec.authors = ['Pipl.com']
11
+ spec.email = ['support@pipl.com']
12
+ spec.license = 'Apache-2.0'
13
13
  spec.version = Pipl::VERSION.dup
14
14
  spec.files = %w(LICENSE README.md pipl.gemspec)
15
15
  spec.files += Dir.glob('lib/**/*.rb')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piplapis-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Edo Shor
7
+ - Pipl.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2023-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -27,7 +27,7 @@ dependencies:
27
27
  description: Pipl is the most comprehensive people search on the web. See https://pipl.com
28
28
  for details.
29
29
  email:
30
- - edo.shor@pipl.com
30
+ - support@pipl.com
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
@@ -48,7 +48,7 @@ files:
48
48
  - pipl.gemspec
49
49
  homepage: https://github.com/piplcom/piplapis-ruby
50
50
  licenses:
51
- - Apache 2.0
51
+ - Apache-2.0
52
52
  metadata: {}
53
53
  post_install_message:
54
54
  rdoc_options: []
@@ -65,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubyforge_project:
69
- rubygems_version: 2.5.1
68
+ rubygems_version: 3.0.3.1
70
69
  signing_key:
71
70
  specification_version: 4
72
71
  summary: Ruby bindings for the Pipl API