Skip to content

Commit

Permalink
Add return_if_unmatched to ip enrich (#15)
Browse files Browse the repository at this point in the history
* add return_if_unmatched to ip enrich

* fix

* update tests

* add specs
  • Loading branch information
vvillait88 authored Aug 21, 2023
1 parent 7f65444 commit 62da06d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/peopledatalabs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# gem build peopledatalabs.gemspec
# gem install ./peopledatalabs-2.1.0.gem
# gem install ./peopledatalabs-2.1.1.gem
# irb
# require 'peopledatalabs'
# rake spec PDL_API_KEY=API_KEY
Expand Down
3 changes: 2 additions & 1 deletion lib/peopledatalabs/resources/enrichment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def self.company(params:)
get(path: '/v5/company/enrich', headers: headers, params: params)
end

def self.ip(ip:, return_ip_location: false, return_ip_metadata: false, return_person: false)
def self.ip(ip:, return_ip_location: false, return_ip_metadata: false, return_person: false, return_if_unmatched: false)
params = {
'ip' => ip,
'return_ip_location' => return_ip_location,
'return_ip_metadata' => return_ip_metadata,
'return_person' => return_person,
'return_if_unmatched' => return_if_unmatched,
}
headers = {
'Accept-Encoding' => 'gzip',
Expand Down
2 changes: 1 addition & 1 deletion lib/peopledatalabs/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Peopledatalabs
VERSION = "2.1.0"
VERSION = "2.1.1"
end
6 changes: 3 additions & 3 deletions peopledatalabs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 2.3"
spec.add_development_dependency "bundler", "~> 2.4"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec", "~> 3.12"

spec.add_runtime_dependency "http", "~> 5.0"
spec.add_runtime_dependency "http", "~> 5.1"
spec.add_runtime_dependency "forwardable", "~> 1.3"
end
11 changes: 9 additions & 2 deletions spec/peopledatalabs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
result = Peopledatalabs::Enrichment.ip(ip: '72.212.42.169', return_ip_metadata: true)
expect(result['status']).to eq(200)
expect(result).to be_an_instance_of(Hash)
expect(result['data']['ip']['location']).to be_an_instance_of(Hash)
expect(result['data']['ip']['metadata']).to be_an_instance_of(Hash)
end

it "should return ip record with person" do
Expand All @@ -247,6 +247,13 @@
expect(result['data']['person']).to be_an_instance_of(Hash)
end

it "should return ip record with unmatched" do
result = Peopledatalabs::Enrichment.ip(ip: '72.212.42.168', return_if_unmatched: true, return_ip_location: true)
expect(result['status']).to eq(200)
expect(result).to be_an_instance_of(Hash)
expect(result['data']['ip']['location']).to be_an_instance_of(Hash)
end

it "should error" do
result = Peopledatalabs::Enrichment.ip(ip: nil)
expect(result['status']).to eq(400)
Expand All @@ -256,7 +263,7 @@

describe 'cleaner apis' do
it "it should return company cleaner records" do
result = Peopledatalabs::Cleaner.company(kind: 'name', value: 'peopledatalabs')
result = Peopledatalabs::Cleaner.company(kind: 'name', value: 'twitter')
expect(result['status']).to eq(200)
expect(result).to be_an_instance_of(Hash)
end
Expand Down

0 comments on commit 62da06d

Please sign in to comment.