Skip to content

Commit

Permalink
feat(Encoding): accept gzip (#4)
Browse files Browse the repository at this point in the history
* feat(Encoding): accept gzip

* chore(Veresion): update
  • Loading branch information
jamesbaez authored May 16, 2022
1 parent 8303f98 commit 0c77cdb
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 37 deletions.
3 changes: 2 additions & 1 deletion lib/peopledatalabs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@


# gem build peopledatalabs.gemspec
# gem install ./peopledatalabs-1.0.0.gem
# gem install ./peopledatalabs-1.0.2.gem
# irb
# require 'peopledatalabs'
# rake spec PDL_API_KEY=API_KEY

# Usage
# First set api key
Expand Down
14 changes: 8 additions & 6 deletions lib/peopledatalabs/api_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ def self.get(path:, headers: {}, params: {})
return request unless request['status'] == 200

response = HTTP
.timeout(Peopledatalabs.read_timeout)
.headers(headers)
.get(url(path), params: query_authentication(params))
.use(:auto_inflate)
.timeout(Peopledatalabs.read_timeout)
.headers(headers)
.get(url(path), params: query_authentication(params))
handle_response(response)
end

Expand All @@ -21,9 +22,10 @@ def self.post(path:, headers: {}, body: {})
return request unless request['status'] == 200

response = HTTP
.timeout(Peopledatalabs.read_timeout)
.headers(header_authentication(headers))
.post(url(path), json: body)
.use(:auto_inflate)
.timeout(Peopledatalabs.read_timeout)
.headers(header_authentication(headers))
.post(url(path), json: body)
handle_response(response)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/peopledatalabs/resources/autocomplete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def self.retrieve(field:, text: '', size: 10, pretty: false)
'pretty' => pretty,
};

# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/autocomplete', params: params)
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/autocomplete', headers: headers, params: params)
end
end
end
5 changes: 2 additions & 3 deletions lib/peopledatalabs/resources/bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
module Peopledatalabs
class Bulk < APIResource
def self.people(params:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
post(path: '/v5/person/bulk', body: params)
headers = { 'Accept-Encoding' => 'gzip' }
post(path: '/v5/person/bulk', headers: headers, body: params)
end
end
end
15 changes: 6 additions & 9 deletions lib/peopledatalabs/resources/cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
module Peopledatalabs
class Cleaner < APIResource
def self.company(kind:, value:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/company/clean', params: { kind => value })
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/company/clean', headers: headers, params: { kind => value })
end

def self.school(kind:, value:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/school/clean', params: { kind => value })
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/school/clean', headers: headers, params: { kind => value })
end

def self.location(value:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/location/clean', params: { 'location' => value })
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/location/clean', headers: headers, params: { 'location' => value })
end


Expand Down
10 changes: 4 additions & 6 deletions lib/peopledatalabs/resources/enrichment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
module Peopledatalabs
class Enrichment < APIResource
def self.person(params:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/person/enrich', params: params)
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/person/enrich', headers: headers, params: params)
end

def self.company(params:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/company/enrich', params: params)
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/company/enrich', headers: headers, params: params)
end

end
Expand Down
5 changes: 2 additions & 3 deletions lib/peopledatalabs/resources/identify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
module Peopledatalabs
class Identify < APIResource
def self.person(params:)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/person/identify', params: params)
headers = { 'Accept-Encoding' => 'gzip' }
get(path: '/v5/person/identify', headers: headers, params: params)
end
end
end
5 changes: 2 additions & 3 deletions lib/peopledatalabs/resources/retrieve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
module Peopledatalabs
class Retrieve < APIResource
def self.person(person_id:, pretty: false)
# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
get(path: "/v5/person/retrieve/#{person_id}", params: { 'pretty' => pretty })
headers = { 'Accept-Encoding' => 'gzip' }
get(path: "/v5/person/retrieve/#{person_id}", headers: headers, params: { 'pretty' => pretty })
end
end
end
5 changes: 2 additions & 3 deletions lib/peopledatalabs/resources/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def self.search(searchType:, query:, kind:, titlecase: false, dataset: 'all', si
'scroll_token' => scroll_token
}

# TODO: possibly add gzip encoding
# headers = { 'Accept-Encoding' => 'gzip' }
post(path: "/v5/#{kind}/search", body: body)
headers = { 'Accept-Encoding' => 'gzip' }
post(path: "/v5/#{kind}/search", headers: headers, body: body)
end
end
end
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 = "1.0.1"
VERSION = "1.0.2"
end

0 comments on commit 0c77cdb

Please sign in to comment.