Skip to content

Commit

Permalink
Merge pull request clearbit#18 from clearbit/rh-prospector-titles
Browse files Browse the repository at this point in the history
Send title params as the API expects them.
  • Loading branch information
robholland committed May 18, 2016
2 parents c753293 + ea6c556 commit 8e09110
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clearbit/prospector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def verified(self):

def getEmailResponse(self):
if (self.email_response):
return self.email_response
return self.email_response

self.email_response = self.__class__.get('/people/%s/email' % self['id'])
self.email_response = self.get('/people/%s/email' % self['id'])
return self.email_response
4 changes: 4 additions & 0 deletions clearbit/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def extract_options(cls, values):
options.update(cls.options)

params = {k: v for k, v in values.items() if k not in cls.valid_options}
for k in list(params):
if isinstance(params[k], list):
params[k + '[]'] = params.pop(k)

options.setdefault('params', {}).update(params)

key = options.pop('key', clearbit.key)
Expand Down
11 changes: 11 additions & 0 deletions clearbit/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,16 @@ def test_endpoint(self, requests):
Enrichment.find(email='[email protected]')
requests.get.assert_called_with('https://person.clearbit.com/v2/combined/find', params={'email': '[email protected]'}, auth=('k', ''))

class TestProspector(unittest.TestCase):
@patch('clearbit.resource.requests')
def test_search(self, requests):
Prospector.search(domain='example.com')
requests.get.assert_called_with('https://prospector.clearbit.com/v1/people/search', params={'domain': 'example.com'}, auth=('k', ''))

@patch('clearbit.resource.requests')
def test_search_titles(self, requests):
Prospector.search(domain='example.com', titles=['Sales Director', 'Marketing Director'])
requests.get.assert_called_with('https://prospector.clearbit.com/v1/people/search', params={'domain': 'example.com', 'titles[]': ['Sales Director', 'Marketing Director']}, auth=('k', ''))

if __name__ == '__main__':
unittest.main()

0 comments on commit 8e09110

Please sign in to comment.