piplapis-ruby 5.0.5 → 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.
data/lib/pipl/default.rb CHANGED
@@ -1,66 +1,71 @@
1
- require_relative 'version'
2
-
3
- module Pipl
4
-
5
- module Default
6
-
7
- API_ENDPOINT = 'https://api.pipl.com/search/'.freeze
8
- USER_AGENT = "piplapis/ruby/#{Pipl::VERSION}".freeze
9
-
10
- class << self
11
-
12
- def options
13
- Hash[Pipl::Configurable.keys.map{|key| [key, send(key)]}]
14
- end
15
-
16
- def api_key
17
- ENV['PIPL_API_KEY']
18
- end
19
-
20
- def minimum_probability
21
- ENV['PIPL_MINIMUM_PROBABILITY']
22
- end
23
-
24
- def minimum_match
25
- ENV['PIPL_MINIMUM_MATCH']
26
- end
27
-
28
- def hide_sponsored
29
- ENV['PIPL_HIDE_SPONSORED']
30
- end
31
-
32
- def live_feeds
33
- ENV['PIPL_LIVE_FEEDS']
34
- end
35
-
36
- def show_sources
37
- ENV['PIPL_SHOW_SOURCES']
38
- end
39
-
40
- def match_requirements
41
- ENV['PIPL_MATCH_REQUIREMENTS']
42
- end
43
-
44
- def source_category_requirements
45
- ENV['PIPL_SOURCE_CATEGORY_REQUIREMENTS']
46
- end
47
-
48
- def infer_persons
49
- ENV['PIPL_INFER_PERSONS']
50
- end
51
-
52
- def strict_validation
53
- ENV['PIPL_USER_STRICT_VALIDATION']
54
- end
55
-
56
- def api_endpoint
57
- ENV.fetch 'PIPL_API_ENDPOINT', API_ENDPOINT
58
- end
59
-
60
- def user_agent
61
- ENV.fetch 'PIPL_USER_AGENT', USER_AGENT
62
- end
63
-
64
- end
65
- end
66
- end
1
+ require_relative 'version'
2
+
3
+ module Pipl
4
+
5
+ module Default
6
+
7
+ # API_ENDPOINT = 'https://api.pipl.com/search/'.freeze
8
+ API_ENDPOINT = 'https://qa-api.pipl.pro/apis/gateway/search/'.freeze
9
+ USER_AGENT = "piplapis/ruby/#{Pipl::VERSION}".freeze
10
+
11
+ class << self
12
+
13
+ def options
14
+ Hash[Pipl::Configurable.keys.map{|key| [key, send(key)]}]
15
+ end
16
+
17
+ def api_key
18
+ ENV['PIPL_API_KEY']
19
+ end
20
+
21
+ def minimum_probability
22
+ ENV['PIPL_MINIMUM_PROBABILITY']
23
+ end
24
+
25
+ def minimum_match
26
+ ENV['PIPL_MINIMUM_MATCH']
27
+ end
28
+
29
+ def hide_sponsored
30
+ ENV['PIPL_HIDE_SPONSORED']
31
+ end
32
+
33
+ def live_feeds
34
+ ENV['PIPL_LIVE_FEEDS']
35
+ end
36
+
37
+ def show_sources
38
+ ENV['PIPL_SHOW_SOURCES']
39
+ end
40
+
41
+ def match_requirements
42
+ ENV['PIPL_MATCH_REQUIREMENTS']
43
+ end
44
+
45
+ def source_category_requirements
46
+ ENV['PIPL_SOURCE_CATEGORY_REQUIREMENTS']
47
+ end
48
+
49
+ def infer_persons
50
+ ENV['PIPL_INFER_PERSONS']
51
+ end
52
+
53
+ def strict_validation
54
+ ENV['PIPL_USER_STRICT_VALIDATION']
55
+ end
56
+
57
+ def api_endpoint
58
+ ENV.fetch 'PIPL_API_ENDPOINT', API_ENDPOINT
59
+ end
60
+
61
+ def user_agent
62
+ ENV.fetch 'PIPL_USER_AGENT', USER_AGENT
63
+ end
64
+
65
+ def top_match
66
+ ENV['PIPL_TOP_MATCH']
67
+ end
68
+
69
+ end
70
+ end
71
+ end
data/lib/pipl/errors.rb CHANGED
@@ -1,62 +1,62 @@
1
- module Pipl
2
-
3
- class AbstractMethodInvoked < StandardError;
4
- end
5
-
6
- class Client
7
-
8
- class APIError < Exception
9
- attr_reader :status_code
10
- attr_reader :qps_allotted, :qps_current, :qps_live_allotted, :qps_live_current, :qps_demo_allotted,
11
- :qps_demo_current, :quota_allotted, :quota_current, :quota_reset, :demo_usage_allotted,
12
- :demo_usage_current, :demo_usage_expiry
13
-
14
- def initialize(message, status_code, params={})
15
- super message
16
- @status_code = status_code
17
- @qps_allotted = params[:qps_allotted]
18
- @qps_current = params[:qps_current]
19
- @qps_live_allotted = params[:qps_live_allotted]
20
- @qps_live_current = params[:qps_live_current]
21
- @qps_demo_allotted = params[:qps_demo_allotted]
22
- @qps_demo_current = params[:qps_demo_current]
23
- @quota_allotted = params[:quota_allotted]
24
- @quota_current = params[:quota_current]
25
- @quota_reset = params[:quota_reset]
26
- @demo_usage_allotted = params[:demo_usage_allotted]
27
- @demo_usage_current = params[:demo_usage_current]
28
- @demo_usage_expiry = params[:demo_usage_expiry]
29
- end
30
-
31
- def is_user_error?
32
- (400..499).member?(@status_code)
33
- end
34
-
35
- def is_pipl_error?
36
- not is_user_error?
37
- end
38
-
39
- def self.deserialize(json_str, headers={})
40
- h = JSON.parse(json_str, symbolize_names: true)
41
- params = Utils::extract_rate_limits(headers)
42
- self.new(h[:error], h[:@http_status_code], params)
43
- end
44
-
45
- def self.from_http_response(resp)
46
- begin
47
- self.deserialize(resp.body, resp)
48
- rescue
49
- Pipl::Client::APIError.new resp.message, resp.code
50
- end
51
- end
52
-
53
- # Here for backward compatibility
54
- def self.from_json(json_str)
55
- self.deserialize(json_str)
56
- end
57
-
58
- end
59
-
60
- end
61
-
62
- end
1
+ module Pipl
2
+
3
+ class AbstractMethodInvoked < StandardError;
4
+ end
5
+
6
+ class Client
7
+
8
+ class APIError < Exception
9
+ attr_reader :status_code
10
+ attr_reader :qps_allotted, :qps_current, :qps_live_allotted, :qps_live_current, :qps_demo_allotted,
11
+ :qps_demo_current, :quota_allotted, :quota_current, :quota_reset, :demo_usage_allotted,
12
+ :demo_usage_current, :demo_usage_expiry
13
+
14
+ def initialize(message, status_code, params={})
15
+ super message
16
+ @status_code = status_code
17
+ @qps_allotted = params[:qps_allotted]
18
+ @qps_current = params[:qps_current]
19
+ @qps_live_allotted = params[:qps_live_allotted]
20
+ @qps_live_current = params[:qps_live_current]
21
+ @qps_demo_allotted = params[:qps_demo_allotted]
22
+ @qps_demo_current = params[:qps_demo_current]
23
+ @quota_allotted = params[:quota_allotted]
24
+ @quota_current = params[:quota_current]
25
+ @quota_reset = params[:quota_reset]
26
+ @demo_usage_allotted = params[:demo_usage_allotted]
27
+ @demo_usage_current = params[:demo_usage_current]
28
+ @demo_usage_expiry = params[:demo_usage_expiry]
29
+ end
30
+
31
+ def is_user_error?
32
+ (400..499).member?(@status_code)
33
+ end
34
+
35
+ def is_pipl_error?
36
+ ! is_user_error?
37
+ end
38
+
39
+ def self.deserialize(json_str, headers={})
40
+ h = JSON.parse(json_str, symbolize_names: true)
41
+ params = Utils::extract_rate_limits(headers)
42
+ self.new(h[:error], h[:@http_status_code], params)
43
+ end
44
+
45
+ def self.from_http_response(resp)
46
+ begin
47
+ self.deserialize(resp.body, resp)
48
+ rescue
49
+ Pipl::Client::APIError.new resp.message, resp.code
50
+ end
51
+ end
52
+
53
+ # Here for backward compatibility
54
+ def self.from_json(json_str)
55
+ self.deserialize(json_str)
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end