├── whitepages ├── test │ ├── __init__.py │ ├── testperson.py │ ├── testlocation.py │ ├── testphone.py │ └── testbusiness.py ├── error.py ├── helper.py ├── __init__.py ├── business.py ├── person.py ├── phone.py └── location.py ├── CHANGES.txt ├── MANIFSET.in ├── setup.py ├── README.md └── LICENSE.txt /whitepages/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CHANGES.txt: -------------------------------------------------------------------------------- 1 | 04/23/2015 2 | Initial Release -------------------------------------------------------------------------------- /MANIFSET.in: -------------------------------------------------------------------------------- 1 | include *.txt 2 | include *.md 3 | recursive-include docs -------------------------------------------------------------------------------- /whitepages/error.py: -------------------------------------------------------------------------------- 1 | class WhitePagesError(Exception): 2 | pass 3 | 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from setuptools import setup 4 | 5 | setup( 6 | name='whitepages', 7 | version='0.0.1', 8 | author='Michal Monselise', 9 | author_email='michal.monselise@gmail.com', 10 | packages=['whitepages', 'whitepages.test'], 11 | # url='https://github.com/michalmonselise/whitepages', 12 | license='LICENSE.txt', 13 | description='Python wrapper for White Pages API', 14 | long_description=open('README.md').read(), 15 | requires=['unittest2'], 16 | ) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | whitepages 2 | 3 | This package is a wrapper for the White Pages API. 4 | 5 | It enables us to perform 4 different kinds of searches: person, business, location (reverse address), and phone (reverse phone). 6 | At the moment identity score is not enabled. 7 | 8 | After obtaining a key, we can generate a WhitePages object and then perform a search. 9 | 10 | For example: 11 | 12 | from whitepages import WhitePages 13 | w = WhitePages(key) 14 | person_result = w.person(name='Jane Smith') 15 | business_result = w.business(name="Michaels Toyota", city=Seattle") 16 | location_result = w.location(street_line_1="123 Broadway",city="New York", state="NY") 17 | phone_result = w.phone(phone_number="206-123-4567") 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /whitepages/helper.py: -------------------------------------------------------------------------------- 1 | import json 2 | import urllib 3 | 4 | from error import WhitePagesError 5 | 6 | 7 | def validate_url(result): 8 | if 'error' in result.keys(): 9 | error_detail = result['error'] 10 | raise WhitePagesError, error_detail 11 | 12 | 13 | def url_encoder(params): 14 | encoded_params = urllib.urlencode(params) 15 | return encoded_params 16 | 17 | 18 | def return_json(url): 19 | result_dict = json.load(urllib.urlopen(url)) 20 | return result_dict 21 | 22 | 23 | def dictIsEmpty(input_dict): 24 | return not bool(input_dict) 25 | 26 | 27 | def remove_blank_fields(input_dict): 28 | return dict((k, v) for k, v in input_dict.iteritems() if v is not None) 29 | 30 | 31 | def add_key(white_pages_object, request_dict): 32 | request_dict['api_key'] = white_pages_object.api_key 33 | return request_dict 34 | 35 | 36 | def query(white_pages_object, request_object): 37 | url = request_object.url() 38 | input_dict = remove_blank_fields(request_object.to_dict()) 39 | if dictIsEmpty(input_dict): 40 | error_detail = 'You have not entered any valid arguments' 41 | raise WhitePagesError, error_detail 42 | input_dict = add_key(white_pages_object, input_dict) 43 | url_query = url + url_encoder(input_dict) 44 | json_blob = return_json(url_query) 45 | validate_url(json_blob) 46 | json_result = json_blob['results'] 47 | result = [] 48 | for pr in json_result: 49 | result.append(request_object.whitePagesObject(pr)) 50 | return result -------------------------------------------------------------------------------- /whitepages/__init__.py: -------------------------------------------------------------------------------- 1 | from helper import query 2 | from business import BusinessRequest 3 | from location import LocationRequest 4 | from person import PersonRequest 5 | from phone import PhoneRequest 6 | 7 | 8 | class WhitePages(): 9 | def __init__(self, api_key): 10 | self.api_key = api_key 11 | 12 | def person(self, name=None, first_name=None, middle_name=None, last_name=None, suffix=None, title=None, 13 | street_line_1=None, street_line_2=None, city=None, postal_code=None, state_code=None, 14 | country_code=None, use_historical=None, use_metro=None): 15 | return query(self, PersonRequest(name, first_name, middle_name, last_name, suffix, title, street_line_1, 16 | street_line_2, city, postal_code, state_code, country_code, use_historical, 17 | use_metro)) 18 | 19 | def phone(self, phone_number=None, response_type=None): 20 | return query(self, PhoneRequest(phone_number, response_type)) 21 | 22 | def business(self, name=None, street_line_1=None, street_line_2=None, city=None, postal_code=None, 23 | state=None, country_code=None): 24 | return query(self, BusinessRequest(name, street_line_1, street_line_2, city, postal_code, state, country_code)) 25 | 26 | def location(self, street_line_1=None, street_line_2=None, city=None, postal_code=None, state_code=None, 27 | country_code=None, lat=None, lon=None, radius=None): 28 | return query(self, LocationRequest(street_line_1, street_line_2, city, postal_code, state_code, 29 | country_code, lat, lon, radius)) -------------------------------------------------------------------------------- /whitepages/business.py: -------------------------------------------------------------------------------- 1 | class WhitePagesBusiness(): 2 | def __init__(self, business_result): 3 | import phone 4 | import location 5 | if self.attr('id', business_result): 6 | self.id = business_result['id'] 7 | else: 8 | self.id = None 9 | if self.attr('name', business_result): 10 | self.name = business_result['name'] 11 | else: 12 | self.name = None 13 | if self.attr('locations', business_result): 14 | self.locations = [location.WhitePagesLocation(l) for l in business_result['locations']] 15 | else: 16 | self.locations = None 17 | if self.attr('phones',business_result): 18 | self.phones = [phone.WhitePagesPhoneNumber(p) for p in business_result['phones']] 19 | else: 20 | self.phone = None 21 | 22 | def attr(self, attribute, result): 23 | if attribute in result: 24 | if result[attribute] is not None: 25 | return True 26 | return False 27 | 28 | class BusinessRequest(): 29 | def __init__(self, name, street_line_1, street_line_2, city, postal_code, 30 | state, country_code): 31 | self.name = name 32 | self.street_line_1 = street_line_1 33 | self.street_line_2 = street_line_2 34 | self.city = city 35 | self.postal_code = postal_code 36 | self.state = state 37 | self.country_code = country_code 38 | 39 | def url(self): 40 | return 'https://proapi.whitepages.com/2.1/business.json?' 41 | 42 | def to_dict(self): 43 | return vars(self) 44 | 45 | def whitePagesObject(self, query_dict): 46 | return WhitePagesBusiness(query_dict) 47 | 48 | 49 | -------------------------------------------------------------------------------- /whitepages/person.py: -------------------------------------------------------------------------------- 1 | class WhitePagesPerson(): 2 | def __init__(self, person_result): 3 | import phone 4 | import location 5 | if self.attr('best_name', person_result): 6 | self.best_name = person_result['best_name'] 7 | else: 8 | self.best_name = None 9 | if self.attr('age_range', person_result): 10 | self.age_range = person_result['age_range'] 11 | else: 12 | self.age_range = None 13 | if self.attr('gender', person_result): 14 | self.gender = person_result['gender'] 15 | else: 16 | self.gender = None 17 | if self.attr('locations', person_result): 18 | self.locations = [location.WhitePagesLocation(l) for l in person_result['locations']] 19 | else: 20 | self.locations = None 21 | if self.attr('names', person_result): 22 | self.names = person_result['names'] 23 | else: 24 | self.names = None 25 | if self.attr('phones', person_result): 26 | self.phones = [phone.WhitePagesPhoneNumber(p) for p in person_result['phones']] 27 | else: 28 | self.phones = None 29 | if self.attr('type', person_result): 30 | self.type = person_result['type'] 31 | else: 32 | self.type = None 33 | if self.attr('id', person_result): 34 | self.id = person_result['id'] 35 | else: 36 | self.id = None 37 | 38 | def attr(self, attribute, result): 39 | if attribute in result: 40 | if result[attribute] is not None: 41 | return True 42 | return False 43 | 44 | 45 | class PersonRequest(): 46 | def __init__(self, name, first_name, middle_name, last_name, suffix, title, 47 | street_line_1, street_line_2, city, postal_code, state_code, 48 | country_code, use_historical, use_metro): 49 | self.name = name 50 | self.first_name = first_name 51 | self.last_name = last_name 52 | self.middle_name = middle_name 53 | self.suffix = suffix 54 | self.title = title 55 | self.street_line_1 = street_line_1 56 | self.street_line_2 = street_line_2 57 | self.city = city 58 | self.postal_code = postal_code 59 | self.state_code = state_code 60 | self.country_code = country_code 61 | self.use_historical = use_historical 62 | self.use_metro = use_metro 63 | 64 | def url(self): 65 | return 'https://proapi.whitepages.com/2.1/person.json?' 66 | 67 | def to_dict(self): 68 | return vars(self) 69 | 70 | def whitePagesObject(self, query_dict): 71 | return WhitePagesPerson(query_dict) 72 | -------------------------------------------------------------------------------- /whitepages/phone.py: -------------------------------------------------------------------------------- 1 | from warnings import warn 2 | 3 | class PhoneRequest(): 4 | def __init__(self, phone_number, response_type): 5 | self.phone_number = phone_number 6 | self.response_type = response_type 7 | 8 | def url(self): 9 | return 'https://proapi.whitepages.com/2.1/phone.json?' 10 | 11 | def to_dict(self): 12 | return vars(self) 13 | 14 | def whitePagesObject(self, query_dict): 15 | return WhitePagesPhoneNumber(query_dict) 16 | 17 | 18 | class WhitePagesPhoneNumber(): 19 | def __init__(self, phone_result): 20 | import location 21 | if self.attr('phone_number', phone_result): 22 | self.phone_number = phone_result['phone_number'] 23 | else: 24 | self.phone_number = None 25 | if self.attr('extension', phone_result): 26 | self.extension = phone_result['extension'] 27 | else: 28 | self.extension = None 29 | if self.attr('best_location', phone_result): 30 | self.best_location = phone_result['best_location'] 31 | else: 32 | self.best_location = None 33 | if self.attr('associated_locations', phone_result): 34 | self.associated_locations = [location.WhitePagesLocation(l) for l in phone_result['associated_locations']] 35 | else: 36 | self.associated_locations = None 37 | if self.attr('country_call_code', phone_result): 38 | self.country_calling_code = phone_result['country_calling_code'] 39 | else: 40 | self.country_calling_code = None 41 | if self.attr('belongs_to', phone_result): 42 | self.belongs_to = [belongs_to_object(phone) for phone in phone_result['belongs_to']] 43 | else: 44 | self.belongs_to = None 45 | if self.attr('is_valid', phone_result): 46 | self.is_valid = phone_result['is_valid'] 47 | else: 48 | self.is_valid = None 49 | if self.attr('line_type', phone_result): 50 | self.line_type = phone_result['line_type'] 51 | else: 52 | self.line_type = None 53 | if self.attr('carrier', phone_result): 54 | self.carrier = phone_result['carrier'] 55 | else: 56 | self.carrier = None 57 | if self.attr('do_not_call', phone_result): 58 | self.do_not_call = phone_result['do_not_call'] 59 | else: 60 | self.do_not_call = None 61 | if self.attr('id', phone_result): 62 | self.id = phone_result['id'] 63 | else: 64 | self.id = None 65 | if self.attr('is_prepaid', phone_result): 66 | self.is_prepaid = phone_result['is_prepaid'] 67 | else: 68 | self.is_prepaid = None 69 | if self.attr('reputation', phone_result): 70 | self.reputation = phone_result['reputation'] 71 | else: 72 | self.reputation = None 73 | 74 | def attr(self, attribute, result): 75 | if attribute in result: 76 | if result[attribute] is not None: 77 | return True 78 | return False 79 | 80 | 81 | def belongs_to_object(belongs_to_result): 82 | import business 83 | import person 84 | 85 | if belongs_to_result['id']['type'] == 'Business': 86 | return business.WhitePagesBusiness(belongs_to_result) 87 | else: 88 | if belongs_to_result['id']['type'] == 'Person': 89 | return person.WhitePagesPerson(belongs_to_result) 90 | else: 91 | warning_detail = 'This is not a valid type for belongs_to' 92 | warn(warning_detail) 93 | return belongs_to_result 94 | -------------------------------------------------------------------------------- /whitepages/location.py: -------------------------------------------------------------------------------- 1 | class LocationRequest(): 2 | def __init__(self, street_line_1, street_line_2, city, postal_code, state_code, 3 | country_code, lat, lon, radius): 4 | self.street_line_1 = street_line_1 5 | self.street_line_2 = street_line_2 6 | self.city = city 7 | self.postal_code = postal_code 8 | self.state_code = state_code 9 | self.country_code = country_code 10 | self.lat = lat 11 | self.lon = lon 12 | self.radius = radius 13 | 14 | def url(self): 15 | return 'https://proapi.whitepages.com/2.1/location.json?' 16 | 17 | def to_dict(self): 18 | return vars(self) 19 | 20 | def whitePagesObject(self, query_dict): 21 | return WhitePagesLocation(query_dict) 22 | 23 | 24 | class WhitePagesLocation(): 25 | def __init__(self, location_result): 26 | if self.attr('id', location_result): 27 | self.id = location_result['id'] 28 | else: 29 | self.id = None 30 | if self.attr('type', location_result): 31 | self.type = location_result['type'] 32 | else: 33 | self.type = None 34 | if self.attr('legal_entities_at', location_result): 35 | self.legal_entities_at = location_result['legal_entities_at'] 36 | else: 37 | self.legal_entities_at = None 38 | if self.attr('city', location_result): 39 | self.city = location_result['city'] 40 | else: 41 | self.city = None 42 | if self.attr('postal_code', location_result): 43 | self.postal_code = location_result['postal_code'] 44 | else: 45 | self.postal_code = None 46 | if self.attr('zip4', location_result): 47 | self.zip4 = location_result['zip4'] 48 | else: 49 | self.zip4 = None 50 | if self.attr('state_code', location_result): 51 | self.state_code = location_result['state_code'] 52 | else: 53 | self.state_code = None 54 | if self.attr('country_code', location_result): 55 | self.country_code = location_result['country_code'] 56 | else: 57 | self.country_code = None 58 | if self.attr('address', location_result): 59 | self.address = location_result['address'] 60 | else: 61 | self.address = None 62 | if self.attr('house', location_result): 63 | self.house = location_result['house'] 64 | else: 65 | self.house = None 66 | if self.attr('street_name', location_result): 67 | self.street_name = location_result['street_name'] 68 | else: 69 | self.street_name = None 70 | if self.attr('street_type', location_result): 71 | self.street_type = location_result['street_type'] 72 | else: 73 | self.street_type = None 74 | if self.attr('pre_dir', location_result): 75 | self.pre_dir = location_result['pre_dir'] 76 | else: 77 | self.pre_dir = None 78 | if self.attr('post_dir', location_result): 79 | self.post_dir = location_result['post_dir'] 80 | else: 81 | self.post_dir = None 82 | if self.attr('apt_number', location_result): 83 | self.apt_number = location_result['apt_number'] 84 | else: 85 | self.apt_number = None 86 | if self.attr('apt_type', location_result): 87 | self.apt_type = location_result['apt_type'] 88 | else: 89 | self.apt_type = None 90 | if self.attr('box_number', location_result): 91 | self.box_number = location_result['box_number'] 92 | else: 93 | self.box_number = None 94 | if self.attr('standard_address_line1', location_result): 95 | self.standard_address_line1 = location_result['standard_address_line1'] 96 | else: 97 | self.standard_address_line1 = None 98 | if self.attr('standard_address_line2', location_result): 99 | self.standard_address_line2 = location_result['standard_address_line2'] 100 | else: 101 | self.standard_address_line2 = None 102 | if self.attr('standard_address_location', location_result): 103 | self.standard_address_location = location_result['standard_address_location'] 104 | else: 105 | self.standard_address_location = None 106 | if self.attr('is_receiving_mail', location_result): 107 | self.is_receiving_mail = location_result['is_receiving_mail'] 108 | else: 109 | self.is_receiving_mail = None 110 | if self.attr('not_receiving_mail_reason', location_result): 111 | self.not_receiving_mail_reason = location_result['not_receiving_mail_reason'] 112 | else: 113 | self.not_receiving_mail_reason = None 114 | if self.attr('usage', location_result): 115 | self.usage = location_result['usage'] 116 | else: 117 | self.usage = None 118 | if self.attr('delivery_point', location_result): 119 | self.delivery_point = location_result['delivery_point'] 120 | else: 121 | self.delivery_point = None 122 | if self.attr('box_type', location_result): 123 | self.box_type = location_result['box_type'] 124 | else: 125 | self.box_type = None 126 | if self.attr('address_type', location_result): 127 | self.address_type = location_result['address_type'] 128 | else: 129 | self.address_type = None 130 | if self.attr('lat_long', location_result): 131 | self.lat_long = location_result['lat_long'] 132 | else: 133 | self.lat_long = None 134 | if self.attr('is_deliverable', location_result): 135 | self.is_deliverable = location_result['is_deliverable'] 136 | else: 137 | self.is_deliverable = None 138 | 139 | 140 | def attr(self, attribute, result): 141 | if attribute in result: 142 | if result[attribute] is not None: 143 | return True 144 | return False 145 | -------------------------------------------------------------------------------- /whitepages/test/testperson.py: -------------------------------------------------------------------------------- 1 | import unittest2 as unittest 2 | 3 | from whitepages.person import WhitePagesPerson 4 | 5 | 6 | class TestWhitePagesPerson(unittest.TestCase): 7 | def setUp(self): 8 | self.basic_input = { 9 | "results": [ 10 | { 11 | "id": { 12 | "key": "Person.8e5f2f09-6755-4183-9a0b-a2be09f35756.Durable", 13 | "url": "https://proapi.whitepages.com/2.1/entity/" 14 | "Person.8e5f2f09-6755-4183-9a0b-a2be09f35756.Durable.json?api_key=KEYVAL", 15 | "type": "Person", 16 | "uuid": "8e5f2f09-6755-4183-9a0b-a2be09f35756", 17 | "durability": "Durable" 18 | }, 19 | "type": "Full", 20 | "names": [ 21 | { 22 | "salutation": None, 23 | "first_name": "Scott", 24 | "middle_name": "A", 25 | "last_name": "Sikora", 26 | "suffix": None, 27 | "valid_for": None 28 | } 29 | ], 30 | "age_range": { 31 | "start": 45, 32 | "end": 49 33 | }, 34 | "gender": "Male", 35 | "locations": [ 36 | { 37 | "id": { 38 | "key": "Location.52d627cd-23ba-447e-9db8-e00866d33508.Durable", 39 | "url": "https://proapi.whitepages.com/2.1/entity/" 40 | "Location.52d627cd-23ba-447e-9db8-e00866d33508.Durable.json?api_key=KEYVAL", 41 | "type": "Location", 42 | "uuid": "52d627cd-23ba-447e-9db8-e00866d33508", 43 | "durability": "Durable" 44 | }, 45 | "contact_type": "Home", 46 | "type": "Address", 47 | "legal_entities_at": [ 48 | { 49 | "id": { 50 | "key": "Person.ccc18d4f-3431-4336-bd9c-a3ca2e3980fc.Durable", 51 | "url": "https://proapi.whitepages.com/2.1/entity/" 52 | "Person.ccc18d4f-3431-4336-bd9c-a3ca2e3980fc.Durable.json?" 53 | "api_key=KEYVAL", 54 | "type": "Person", 55 | "uuid": "ccc18d4f-3431-4336-bd9c-a3ca2e3980fc", 56 | "durability": "Durable" 57 | }, 58 | "valid_for": None, 59 | "type": "Full", 60 | "names": [ 61 | { 62 | "salutation": None, 63 | "first_name": "Stacy", 64 | "middle_name": "L", 65 | "last_name": "Sikora", 66 | "suffix": None, 67 | "valid_for": None 68 | } 69 | ], 70 | "age_range": { 71 | "start": 50, 72 | "end": 54 73 | }, 74 | "gender": "Female", 75 | "locations": None, 76 | "phones": None, 77 | "best_name": "Stacy L Sikora", 78 | "best_location": None, 79 | "associated_people": None 80 | }, 81 | { 82 | "id": { 83 | "key": "Person.8e5f2f09-6755-4183-9a0b-a2be09f35756.Durable", 84 | "url": "https://proapi.whitepages.com/2.1/entity/" 85 | "Person.8e5f2f09-6755-4183-9a0b-a2be09f35756.Durable.json?" 86 | "api_key=KEYVAL", 87 | "type": "Person", 88 | "uuid": "8e5f2f09-6755-4183-9a0b-a2be09f35756", 89 | "durability": "Durable" 90 | }, 91 | "valid_for": None, 92 | "type": "Full", 93 | "names": [ 94 | { 95 | "salutation": None, 96 | "first_name": "Scott", 97 | "middle_name": "A", 98 | "last_name": "Sikora", 99 | "suffix": None, 100 | "valid_for": None 101 | } 102 | ], 103 | "age_range": { 104 | "start": 45, 105 | "end": 49 106 | }, 107 | "gender": "Male", 108 | "locations": None, 109 | "phones": None, 110 | "best_name": "Scott A Sikora", 111 | "best_location": None, 112 | "associated_people": None 113 | } 114 | ], 115 | "city": "Seattle", 116 | "postal_code": "98119", 117 | "zip4": "2134", 118 | "state_code": "WA", 119 | "country_code": "US", 120 | "address": "413 E Howe St, Seattle WA 98119-2134", 121 | "house": "413", 122 | "street_name": "Howe", 123 | "street_type": "St", 124 | "apt_type": None, 125 | "is_receiving_mail": True, 126 | "not_receiving_mail_reason": None, 127 | "usage": "Residential", 128 | "delivery_point": "SingleUnit", 129 | "box_type": None, 130 | "address_type": "Street", 131 | "lat_long": { 132 | "latitude": 47.635761, 133 | "longitude": -122.362556, 134 | "accuracy": "RoofTop" 135 | }, 136 | "is_deliverable": True 137 | } 138 | ], 139 | "phones": [], 140 | "best_name": "Scott A Sikora" 141 | } 142 | ], 143 | "messages": [] 144 | } 145 | 146 | def test_person(self): 147 | person_test = [WhitePagesPerson(person) for person in self['results']] 148 | self.assertEqual(person_test[0].best_name, 'Scott A Sikora') 149 | self.assertEqual(person_test[0].gender, 'Male') -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /whitepages/test/testlocation.py: -------------------------------------------------------------------------------- 1 | from unittest2 import TestCase 2 | 3 | from whitepages.location import WhitePagesLocation 4 | 5 | 6 | class TestWhitePagesLocation(TestCase): 7 | def setUp(self): 8 | self.basic_input = { 9 | "results": [ 10 | { 11 | "id": { 12 | "key": "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable", 13 | "url": "https://proapi.whitepages.com/2.1/entity/" 14 | "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable.json?api_key=KEYVAL", 15 | "type": "Location", 16 | "uuid": "efe46385-b057-40c3-8b67-f5a5278e0710", 17 | "durability": "Durable" 18 | }, 19 | "type": "Address", 20 | "legal_entities_at": [ 21 | { 22 | "id": { 23 | "key": "Person.cf0993f8-ea1a-4fe6-9bae-cbca443a09f2.Durable", 24 | "url": "https://proapi.whitepages.com/2.1/entity/" 25 | "Person.cf0993f8-ea1a-4fe6-9bae-cbca443a09f2.Durable.json?api_key=KEYVAL", 26 | "type": "Person", 27 | "uuid": "cf0993f8-ea1a-4fe6-9bae-cbca443a09f2", 28 | "durability": "Durable" 29 | }, 30 | "valid_for": { 31 | "start": { 32 | "year": 2011, 33 | "month": 6, 34 | "day": 28 35 | }, 36 | "stop": None 37 | }, 38 | "type": "Full", 39 | "names": [ 40 | { 41 | "salutation": None, 42 | "first_name": "Roey", 43 | "middle_name": "F", 44 | "last_name": "Horns", 45 | "suffix": None, 46 | "valid_for": None 47 | } 48 | ], 49 | "age_range": { 50 | "start": 45, 51 | "end": 49 52 | }, 53 | "gender": None, 54 | "locations": [ 55 | { 56 | "id": { 57 | "key": "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable", 58 | "url": "https://proapi.whitepages.com/2.1/" 59 | "entity/Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable.json?" 60 | "api_key=KEYVAL", 61 | "type": "Location", 62 | "uuid": "efe46385-b057-40c3-8b67-f5a5278e0710", 63 | "durability": "Durable" 64 | }, 65 | "contact_type": "Home", 66 | "type": "Address", 67 | "legal_entities_at": None, 68 | "city": "Seattle", 69 | "postal_code": "98119", 70 | "zip4": "2043", 71 | "state_code": "WA", 72 | "country_code": "US", 73 | "address": "413 W Howe St, Seattle WA 98119-2043", 74 | "house": "413", 75 | "street_name": "Howe", 76 | "street_type": "St", 77 | "apt_type": None, 78 | "is_receiving_mail": True, 79 | "not_receiving_mail_reason": None, 80 | "usage": "Residential", 81 | "delivery_point": "SingleUnit", 82 | "box_type": None, 83 | "address_type": "Street", 84 | "lat_long": { 85 | "latitude": 47.636105, 86 | "longitude": -122.362549, 87 | "accuracy": "RoofTop" 88 | }, 89 | "is_deliverable": True, 90 | "contained_by_locations": None 91 | } 92 | ], 93 | "phones": [], 94 | "best_name": "Roey F Horns" 95 | }, 96 | { 97 | "id": { 98 | "key": "Person.3c812ed6-4319-44de-b573-c458e4346c9c.Durable", 99 | "url": "https://proapi.whitepages.com/2.1/" 100 | "entity/Person.3c812ed6-4319-44de-b573-c458e4346c9c.Durable.json?api_key=KEYVAL", 101 | "type": "Person", 102 | "uuid": "3c812ed6-4319-44de-b573-c458e4346c9c", 103 | "durability": "Durable" 104 | }, 105 | "valid_for": { 106 | "start": { 107 | "year": 2011, 108 | "month": 6, 109 | "day": 28 110 | }, 111 | "stop": None 112 | }, 113 | "type": "Full", 114 | "names": [ 115 | { 116 | "salutation": None, 117 | "first_name": "Andrea", 118 | "middle_name": None, 119 | "last_name": "Horns", 120 | "suffix": None, 121 | "valid_for": None 122 | } 123 | ], 124 | "age_range": { 125 | "start": 45, 126 | "end": 49 127 | }, 128 | "gender": "Female", 129 | "locations": [ 130 | { 131 | "id": { 132 | "key": "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable", 133 | "url": "https://proapi.whitepages.com/2.1/entity" 134 | "/Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable.json?" 135 | "api_key=KEYVAL", 136 | "type": "Location", 137 | "uuid": "efe46385-b057-40c3-8b67-f5a5278e0710", 138 | "durability": "Durable" 139 | }, 140 | "contact_type": "Home", 141 | "type": "Address", 142 | "legal_entities_at": None, 143 | "city": "Seattle", 144 | "postal_code": "98119", 145 | "zip4": "3045", 146 | "state_code": "WA", 147 | "country_code": "US", 148 | "address": "402 W Howe St, Seattle WA 98119-3045", 149 | "house": "402", 150 | "street_name": "Howe", 151 | "street_type": "St", 152 | "apt_type": None, 153 | "is_receiving_mail": True, 154 | "not_receiving_mail_reason": None, 155 | "usage": "Residential", 156 | "delivery_point": "SingleUnit", 157 | "box_type": None, 158 | "address_type": "Street", 159 | "lat_long": { 160 | "latitude": 47.636105, 161 | "longitude": -122.362549, 162 | "accuracy": "RoofTop" 163 | }, 164 | "is_deliverable": True, 165 | "contained_by_locations": None 166 | } 167 | ], 168 | "phones": [], 169 | "best_name": "Andrea Horns" 170 | }, 171 | { 172 | "id": { 173 | "key": "Business.d2a27cbc-4760-49f5-99f3-65cac7911716.Durable", 174 | "url": "https://proapi.whitepages.com/2.1/entity" 175 | "/Business.d2a27cbc-4760-49f5-99f3-65cac7911716.Durable.json?api_key=KEYVAL", 176 | "type": "Business", 177 | "uuid": "d2a27cbc-4760-49f5-99f3-65cac7911716", 178 | "durability": "Durable" 179 | }, 180 | "valid_for": None, 181 | "name": "Andrea Horns Photography", 182 | "locations": [ 183 | { 184 | "id": { 185 | "key": "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable", 186 | "url": "https://proapi.whitepages.com/2.1/entity/" 187 | "Location.efe46385-b057-40c3-8b67-f5a5278e0710.Durable.json?" 188 | "api_key=KEYVAL", 189 | "type": "Location", 190 | "uuid": "efe46385-b057-40c3-8b67-f5a5278e0710", 191 | "durability": "Durable" 192 | }, 193 | "contact_type": "Business", 194 | "type": "Address", 195 | "legal_entities_at": None, 196 | "city": "Seattle", 197 | "postal_code": "98119", 198 | "zip4": "3045", 199 | "state_code": "WA", 200 | "country_code": "US", 201 | "address": "402 W Howe St, Seattle WA 98119-3045", 202 | "house": "402", 203 | "street_name": "Howe", 204 | "street_type": "St", 205 | "apt_type": None, 206 | "is_receiving_mail": True, 207 | "not_receiving_mail_reason": None, 208 | "usage": "Residential", 209 | "delivery_point": "SingleUnit", 210 | "box_type": None, 211 | "address_type": "Street", 212 | "lat_long": { 213 | "latitude": 47.636105, 214 | "longitude": -122.362549, 215 | "accuracy": "RoofTop" 216 | }, 217 | "is_deliverable": True, 218 | "contained_by_locations": None 219 | } 220 | ], 221 | "phones": [ 222 | { 223 | "id": { 224 | "key": "Phone.c81d6fef-a2df-4b08-cfe3-bc7128b6f5f1.Durable", 225 | "url": "https://proapi.whitepages.com/2.1/entity/" 226 | "Phone.c81d6fef-a2df-4b08-cfe3-bc7128b6f5f1.Durable.json?api_key=KEYVAL", 227 | "type": "Phone", 228 | "uuid": "c81d6fef-a2df-4b08-cfe3-bc7128b6f5f1", 229 | "durability": "Durable" 230 | }, 231 | "contact_type": "Business", 232 | "line_type": "Landline", 233 | "belongs_to": None, 234 | "associated_locations": None, 235 | "is_valid": None, 236 | "phone_number": "2063131662", 237 | "country_calling_code": "1", 238 | "extension": None, 239 | "carrier": None, 240 | "do_not_call": None, 241 | "reputation": None, 242 | "is_prepaid": None, 243 | "best_location": None 244 | } 245 | ] 246 | } 247 | ], 248 | "city": "Seattle", 249 | "postal_code": "98119", 250 | "zip4": "2043", 251 | "state_code": "WA", 252 | "country_code": "US", 253 | "address": "413 W Howe St, Seattle WA 98119-2043", 254 | "house": "413", 255 | "street_name": "Howe", 256 | "street_type": "St", 257 | "apt_type": None, 258 | "is_receiving_mail": True, 259 | "not_receiving_mail_reason": None, 260 | "usage": "Residential", 261 | "delivery_point": "SingleUnit", 262 | "box_type": None, 263 | "address_type": "Street", 264 | "lat_long": { 265 | "latitude": 47.636105, 266 | "longitude": -122.362549, 267 | "accuracy": "RoofTop" 268 | }, 269 | "is_deliverable": True 270 | } 271 | ], 272 | "messages": [] 273 | } 274 | 275 | def test_location(self): 276 | location_test = [WhitePagesLocation(location) for location in self['results']] 277 | self.assertEqual(location_test[0].city, 'Seattle') 278 | self.assertEqual(location_test[0].is_deliverable, True) 279 | -------------------------------------------------------------------------------- /whitepages/test/testphone.py: -------------------------------------------------------------------------------- 1 | from unittest2 import TestCase 2 | 3 | from whitepages.phone import WhitePagesPhoneNumber 4 | 5 | 6 | class TestWhitePagesPhoneNumber(TestCase): 7 | def setUp(self): 8 | self.basic_input = { 9 | "results": [ 10 | { 11 | "id": { 12 | "key": "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable", 13 | "url": "https://proapi.whitepages.com/2.1/entity/" 14 | "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable.json?api_key=LEYVAL", 15 | "type": "Phone", 16 | "uuid": "4d796fef-a2df-4b08-cfe3-bc7128b6f6bb", 17 | "durability": "Durable" 18 | }, 19 | "line_type": "Landline", 20 | "belongs_to": [ 21 | { 22 | "id": { 23 | "key": "Business.ed5796c8-4e86-480a-b520-7a9f47f03a19.Durable", 24 | "url": "https://proapi.whitepages.com/2.1/entity/" 25 | "Business.ed5796c8-4e86-480a-b520-7a9f47f03a19.Durable.json?api_key=LEYVAL", 26 | "type": "Business", 27 | "uuid": "ed5796c8-4e86-480a-b520-7a9f47f03a19", 28 | "durability": "Durable" 29 | }, 30 | "valid_for": None, 31 | "name": "Whitepages", 32 | "locations": [ 33 | { 34 | "id": { 35 | "key": "Location.b4bad7f6-4095-4fbf-a997-130984ed94ad.Durable", 36 | "url": "https://proapi.whitepages.com/2.1/entity/" 37 | "Location.b4bad7f6-4095-4fbf-a997-130984ed94ad.Durable.json?api_key=LEYVAL", 38 | "type": "Location", 39 | "uuid": "b4bad7f6-4095-4fbf-a997-130984ed94ad", 40 | "durability": "Durable" 41 | }, 42 | "contact_type": "Business", 43 | "type": "Address", 44 | "legal_entities_at": None, 45 | "city": "Palo Alto", 46 | "postal_code": "94306", 47 | "zip4": "2203", 48 | "state_code": "CA", 49 | "country_code": "US", 50 | "address": "411 Acacia Ave, Palo Alto, CA 94306-2203", 51 | "house": "411", 52 | "street_name": "Acacia", 53 | "street_type": "Ave", 54 | "apt_type": None, 55 | "is_receiving_mail": True, 56 | "not_receiving_mail_reason": None, 57 | "usage": None, 58 | "delivery_point": None, 59 | "box_type": None, 60 | "address_type": None, 61 | "lat_long": { 62 | "latitude": 37.4225997924805, 63 | "longitude": -122.138076782227, 64 | "accuracy": "RoofTop" 65 | }, 66 | "is_deliverable": True, 67 | "contained_by_locations": None 68 | } 69 | ], 70 | "phones": [ 71 | { 72 | "id": { 73 | "key": "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable", 74 | "url": "https://proapi.whitepages.com/2.1/entity/" 75 | "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable.json?api_key=LEYVAL", 76 | "type": "Phone", 77 | "uuid": "4d796fef-a2df-4b08-cfe3-bc7128b6f6bb", 78 | "durability": "Durable" 79 | }, 80 | "contact_type": "Business", 81 | "line_type": "Landline", 82 | "belongs_to": None, 83 | "associated_locations": None, 84 | "is_valid": True, 85 | "phone_number": "2069735100", 86 | "country_calling_code": "1", 87 | "extension": None, 88 | "carrier": "tw telecom", 89 | "do_not_call": False, 90 | "reputation": { 91 | "spam_score": 6 92 | }, 93 | "is_prepaid": False, 94 | "best_location": None 95 | } 96 | ] 97 | }, 98 | { 99 | "id": { 100 | "key": "Business.dfd13b90-b786-4f94-bfd3-b65d5a5cb088.Durable", 101 | "url": "https://proapi.whitepages.com/2.1/entity/" 102 | "Business.dfd13b90-b786-4f94-bfd3-b65d5a5cb088.Durable.json?api_key=LEYVAL", 103 | "type": "Business", 104 | "uuid": "dfd13b90-b786-4f94-bfd3-b65d5a5cb088", 105 | "durability": "Durable" 106 | }, 107 | "valid_for": None, 108 | "name": "Whitepages", 109 | "locations": [ 110 | { 111 | "id": { 112 | "key": "Location.a3c1ed9b-a709-4b58-a3bf-eb29727f6740.Ephemeral", 113 | "url": None, 114 | "type": "Location", 115 | "uuid": "a3c1ed9b-a709-4b58-a3bf-eb29727f6740", 116 | "durability": "Ephemeral" 117 | }, 118 | "contact_type": None, 119 | "type": "Address", 120 | "legal_entities_at": None, 121 | "city": "New York", 122 | "postal_code": "10018", 123 | "zip4": None, 124 | "state_code": "NY", 125 | "country_code": None, 126 | "address": None, 127 | "house": None, 128 | "street_name": None, 129 | "street_type": None, 130 | "apt_type": None, 131 | "is_receiving_mail": None, 132 | "not_receiving_mail_reason": None, 133 | "usage": None, 134 | "delivery_point": None, 135 | "box_type": None, 136 | "address_type": None, 137 | "lat_long": { 138 | "latitude": 40.753017, 139 | "longitude": -73.986237, 140 | "accuracy": None 141 | }, 142 | "is_deliverable": None, 143 | "contained_by_locations": None 144 | } 145 | ], 146 | "phones": [ 147 | { 148 | "id": { 149 | "key": "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable", 150 | "url": "https://proapi.whitepages.com/2.1/entity/Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable.json?api_key=LEYVAL", 151 | "type": "Phone", 152 | "uuid": "4d796fef-a2df-4b08-cfe3-bc7128b6f6bb", 153 | "durability": "Durable" 154 | }, 155 | "contact_type": "Business", 156 | "line_type": "Landline", 157 | "belongs_to": None, 158 | "associated_locations": None, 159 | "is_valid": True, 160 | "phone_number": "2069735100", 161 | "country_calling_code": "1", 162 | "extension": None, 163 | "carrier": "tw telecom", 164 | "do_not_call": False, 165 | "reputation": { 166 | "spam_score": 6 167 | }, 168 | "is_prepaid": False, 169 | "best_location": None 170 | } 171 | ] 172 | }, 173 | { 174 | "id": { 175 | "key": "Business.545ac847-02be-4f1c-8139-9e7b97b18003.Durable", 176 | "url": "https://proapi.whitepages.com/2.1/entity/Business.545ac847-02be-4f1c-8139-9e7b97b18003.Durable.json?api_key=LEYVAL", 177 | "type": "Business", 178 | "uuid": "545ac847-02be-4f1c-8139-9e7b97b18003", 179 | "durability": "Durable" 180 | }, 181 | "valid_for": None, 182 | "name": "Whitepages", 183 | "locations": [ 184 | { 185 | "id": { 186 | "key": "Location.f680d715-f932-4e68-9e64-9871113a6b81.Durable", 187 | "url": "https://proapi.whitepages.com/2.1/entity/" 188 | "Location.f680d715-f932-4e68-9e64-9871113a6b81.Durable.json?api_key=LEYVAL", 189 | "type": "Location", 190 | "uuid": "f680d715-f932-4e68-9e64-9871113a6b81", 191 | "durability": "Durable" 192 | }, 193 | "contact_type": "Business", 194 | "type": "Address", 195 | "legal_entities_at": None, 196 | "city": "Seattle", 197 | "postal_code": "98101", 198 | "zip4": "2603", 199 | "state_code": "WA", 200 | "country_code": "US", 201 | "address": "1301 5th Ave, Seattle, WA 98101-2603", 202 | "house": "1301", 203 | "street_name": "5th", 204 | "street_type": "Ave", 205 | "apt_type": None, 206 | "is_receiving_mail": None, 207 | "not_receiving_mail_reason": None, 208 | "usage": None, 209 | "delivery_point": None, 210 | "box_type": None, 211 | "address_type": None, 212 | "lat_long": { 213 | "latitude": 47.608624, 214 | "longitude": -122.334442, 215 | "accuracy": "RoofTop" 216 | }, 217 | "is_deliverable": False, 218 | "contained_by_locations": None 219 | } 220 | ], 221 | "phones": [ 222 | { 223 | "id": { 224 | "key": "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable", 225 | "url": "https://proapi.whitepages.com/2.1/entity/" 226 | "Phone.4d796fef-a2df-4b08-cfe3-bc7128b6f6bb.Durable.json?api_key=LEYVAL", 227 | "type": "Phone", 228 | "uuid": "4d796fef-a2df-4b08-cfe3-bc7128b6f6bb", 229 | "durability": "Durable" 230 | }, 231 | "contact_type": "Business", 232 | "line_type": "Landline", 233 | "belongs_to": None, 234 | "associated_locations": None, 235 | "is_valid": True, 236 | "phone_number": "2069735100", 237 | "country_calling_code": "1", 238 | "extension": None, 239 | "carrier": "tw telecom", 240 | "do_not_call": False, 241 | "reputation": { 242 | "spam_score": 6 243 | }, 244 | "is_prepaid": False, 245 | "best_location": None 246 | }, 247 | { 248 | "id": { 249 | "key": "Phone.345f6fef-a2e1-4b08-cfe3-bc7128b7ba13.Durable", 250 | "url": "https://proapi.whitepages.com/2.1/entity/" 251 | "Phone.345f6fef-a2e1-4b08-cfe3-bc7128b7ba13.Durable.json?api_key=LEYVAL", 252 | "type": "Phone", 253 | "uuid": "345f6fef-a2e1-4b08-cfe3-bc7128b7ba13", 254 | "durability": "Durable" 255 | }, 256 | "contact_type": "Business", 257 | "line_type": "Landline", 258 | "belongs_to": None, 259 | "associated_locations": None, 260 | "is_valid": None, 261 | "phone_number": "8003361327", 262 | "country_calling_code": "1", 263 | "extension": None, 264 | "carrier": None, 265 | "do_not_call": None, 266 | "reputation": None, 267 | "is_prepaid": None, 268 | "best_location": None 269 | }, 270 | { 271 | "id": { 272 | "key": "Phone.345f6fef-a2e1-4b08-cfe3-bc7128b7ba13.Durable", 273 | "url": "https://proapi.whitepages.com/2.1/entity/" 274 | "Phone.345f6fef-a2e1-4b08-cfe3-bc7128b7ba13.Durable.json?api_key=LEYVAL", 275 | "type": "Phone", 276 | "uuid": "345f6fef-a2e1-4b08-cfe3-bc7128b7ba13", 277 | "durability": "Durable" 278 | }, 279 | "contact_type": "Business", 280 | "line_type": "Landline", 281 | "belongs_to": None, 282 | "associated_locations": None, 283 | "is_valid": None, 284 | "phone_number": "8003361327", 285 | "country_calling_code": "1", 286 | "extension": None, 287 | "carrier": None, 288 | "do_not_call": None, 289 | "reputation": None, 290 | "is_prepaid": None, 291 | "best_location": None 292 | } 293 | ] 294 | } 295 | ], 296 | "associated_locations": [ 297 | { 298 | "id": { 299 | "key": "Location.31d25199-e4db-4b0b-a4e1-c463702f3eb6.Durable", 300 | "url": "https://proapi.whitepages.com/2.1/entity/" 301 | "Location.31d25199-e4db-4b0b-a4e1-c463702f3eb6.Durable.json?api_key=LEYVAL", 302 | "type": "Location", 303 | "uuid": "31d25199-e4db-4b0b-a4e1-c463702f3eb6", 304 | "durability": "Durable" 305 | }, 306 | "contact_type": None, 307 | "type": "CityPostalCode", 308 | "legal_entities_at": None, 309 | "city": "Seattle", 310 | "postal_code": "98115", 311 | "zip4": None, 312 | "state_code": "WA", 313 | "country_code": "US", 314 | "address": "Seattle WA 98115", 315 | "house": None, 316 | "street_name": None, 317 | "street_type": None, 318 | "apt_type": None, 319 | "is_receiving_mail": None, 320 | "not_receiving_mail_reason": None, 321 | "usage": None, 322 | "delivery_point": None, 323 | "box_type": None, 324 | "address_type": None, 325 | "lat_long": { 326 | "latitude": 47.6851, 327 | "longitude": -122.2926, 328 | "accuracy": "PostalCode" 329 | }, 330 | "is_deliverable": None 331 | } 332 | ], 333 | "is_valid": True, 334 | "phone_number": "2069735100", 335 | "country_calling_code": "1", 336 | "extension": None, 337 | "carrier": "tw telecom", 338 | "do_not_call": False, 339 | "reputation": { 340 | "spam_score": 6 341 | }, 342 | "is_prepaid": False, 343 | "best_location": { 344 | "id": { 345 | "key": "Location.31d25199-e4db-4b0b-a4e1-c463702f3eb6.Durable", 346 | "url": "https://proapi.whitepages.com/2.1/entity/" 347 | "Location.31d25199-e4db-4b0b-a4e1-c463702f3eb6.Durable.json?api_key=LEYVAL", 348 | "type": "Location", 349 | "uuid": "31d25199-e4db-4b0b-a4e1-c463702f3eb6", 350 | "durability": "Durable" 351 | }, 352 | "type": "CityPostalCode", 353 | "legal_entities_at": None, 354 | "city": "Seattle", 355 | "postal_code": "98115", 356 | "zip4": None, 357 | "state_code": "WA", 358 | "country_code": "US", 359 | "address": "Seattle WA 98115", 360 | "house": None, 361 | "street_name": None, 362 | "street_type": None, 363 | "apt_type": None, 364 | "is_receiving_mail": None, 365 | "not_receiving_mail_reason": None, 366 | "usage": None, 367 | "delivery_point": None, 368 | "box_type": None, 369 | "address_type": None, 370 | "lat_long": { 371 | "latitude": 47.6851, 372 | "longitude": -122.2926, 373 | "accuracy": "PostalCode" 374 | }, 375 | "is_deliverable": None 376 | } 377 | } 378 | ], 379 | "messages": [] 380 | } 381 | 382 | def test_phone(self): 383 | phone_number = [WhitePagesPhoneNumber(phone) for phone in self['results']] 384 | self.assertEqual(phone_number[0].carrier, 'tw telecom') 385 | self.assertEqual(phone_number[0].do_not_call, False) 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /whitepages/test/testbusiness.py: -------------------------------------------------------------------------------- 1 | from unittest2 import TestCase 2 | 3 | from whitepages.business import WhitePagesBusiness 4 | 5 | 6 | class TestWhitePagesBusiness(TestCase): 7 | def setUp(self): 8 | self.basic_input = { 9 | "results": [ 10 | { 11 | "id": { 12 | "key": "Business.b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c.Durable", 13 | "url": "https://proapi.whitepages.com/2.1/entity/" 14 | "Business.b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c.Durable.json?api_key=KEYVAL", 15 | "type": "Business", 16 | "uuid": "b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c", 17 | "durability": "Durable" 18 | }, 19 | "name": "Michaels Toyota", 20 | "locations": [ 21 | { 22 | "id": { 23 | "key": "Location.4a5e6fd5-f3fc-47de-bf04-0226ae14f721.Ephemeral", 24 | "url": None, 25 | "type": "Location", 26 | "uuid": "4a5e6fd5-f3fc-47de-bf04-0226ae14f721", 27 | "durability": "Ephemeral" 28 | }, 29 | "contact_type": None, 30 | "type": "Address", 31 | "legal_entities_at": [ 32 | { 33 | "id": { 34 | "key": "Business.b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c.Durable", 35 | "url": "https://proapi.whitepages.com/2.1/entity/" 36 | "Business.b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c.Durable.json?" 37 | "api_key=KEYVAL", 38 | "type": "Business", 39 | "uuid": "b5b36dfd-dfb3-4700-9cdc-fc736fa7b43c", 40 | "durability": "Durable" 41 | }, 42 | "valid_for": None, 43 | "name": "Michaels Toyota", 44 | "locations": None, 45 | "phones": [ 46 | { 47 | "id": { 48 | "key": "Phone.261b6fef-a2df-4b08-cfe3-bc7128b6f5d5.Durable", 49 | "url": "https://proapi.whitepages.com/2.1/entity/" 50 | "Phone.261b6fef-a2df-4b08-cfe3-bc7128b6f5d5.Durable.json?" 51 | "api_key=KEYVAL", 52 | "type": "Phone", 53 | "uuid": "261b6fef-a2df-4b08-cfe3-bc7128b6f5d5", 54 | "durability": "Durable" 55 | }, 56 | "contact_type": "Business" 57 | } 58 | ] 59 | } 60 | ], 61 | "city": "Seattle", 62 | "postal_code": "98125", 63 | "zip4": None, 64 | "state_code": "WA", 65 | "country_code": None, 66 | "address": None, 67 | "house": None, 68 | "street_name": None, 69 | "street_type": None, 70 | "apt_type": None, 71 | "is_receiving_mail": None, 72 | "not_receiving_mail_reason": None, 73 | "usage": None, 74 | "delivery_point": None, 75 | "box_type": None, 76 | "address_type": None, 77 | "lat_long": { 78 | "latitude": 47.714686676788, 79 | "longitude": -122.307876687081, 80 | "accuracy": None 81 | }, 82 | "is_deliverable": None 83 | } 84 | ], 85 | "phones": [ 86 | { 87 | "id": { 88 | "key": "Phone.261b6fef-a2df-4b08-cfe3-bc7128b6f5d5.Durable", 89 | "url": "https://proapi.whitepages.com/2.1/entity/" 90 | "Phone.261b6fef-a2df-4b08-cfe3-bc7128b6f5d5.Durable.json?api_key=KEYVAL", 91 | "type": "Phone", 92 | "uuid": "261b6fef-a2df-4b08-cfe3-bc7128b6f5d5", 93 | "durability": "Durable" 94 | }, 95 | "contact_type": "Business", 96 | "line_type": "Landline", 97 | "belongs_to": None, 98 | "associated_locations": None, 99 | "is_valid": None, 100 | "phone_number": "2062193421", 101 | "country_calling_code": "1", 102 | "extension": None, 103 | "carrier": None, 104 | "do_not_call": None, 105 | "reputation": None, 106 | "is_prepaid": None, 107 | "best_location": None 108 | } 109 | ] 110 | }, 111 | { 112 | "id": { 113 | "key": "Business.2655de5d-72d0-424b-bdb6-5d9753dba0f2.Durable", 114 | "url": "https://proapi.whitepages.com/2.1/entity/" 115 | "Business.2655de5d-72d0-424b-bdb6-5d9753dba0f2.Durable.json?api_key=KEYVAL", 116 | "type": "Business", 117 | "uuid": "2655de5d-72d0-424b-bdb6-5d9753dba0f2", 118 | "durability": "Durable" 119 | }, 120 | "name": "Toyota Of Lake City", 121 | "locations": [ 122 | { 123 | "id": { 124 | "key": "Location.2d7b7a78-9031-4a65-8d34-097d8129fc9b.Durable", 125 | "url": "https://proapi.whitepages.com/2.1/entity/" 126 | "Location.2d7b7a78-9031-4a65-8d34-097d8129fc9b.Durable.json?api_key=KEYVAL", 127 | "type": "Location", 128 | "uuid": "2d7b7a78-9031-4a65-8d34-097d8129fc9b", 129 | "durability": "Durable" 130 | }, 131 | "contact_type": "Business", 132 | "type": "Address", 133 | "legal_entities_at": None, 134 | "city": "Seattle", 135 | "postal_code": "98125", 136 | "zip4": "4430", 137 | "state_code": "WA", 138 | "country_code": "US", 139 | "address": "13355 Lake City Way NE, Seattle, WA 98125-4430", 140 | "house": "13355", 141 | "street_name": "Lake City", 142 | "street_type": "Way", 143 | "apt_type": None, 144 | "is_receiving_mail": True, 145 | "not_receiving_mail_reason": None, 146 | "usage": "Business", 147 | "delivery_point": "SingleUnit", 148 | "box_type": None, 149 | "address_type": "Street", 150 | "lat_long": { 151 | "latitude": 47.726143, 152 | "longitude": -122.293465, 153 | "accuracy": "RoofTop" 154 | }, 155 | "is_deliverable": True 156 | } 157 | ], 158 | "phones": [ 159 | { 160 | "id": { 161 | "key": "Phone.f1f16fef-a2e2-4b08-cfe3-bc7128b4238d.Durable", 162 | "url": "https://proapi.whitepages.com/2.1/entity/" 163 | "Phone.f1f16fef-a2e2-4b08-cfe3-bc7128b4238d.Durable.json?api_key=KEYVAL", 164 | "type": "Phone", 165 | "uuid": "f1f16fef-a2e2-4b08-cfe3-bc7128b4238d", 166 | "durability": "Durable" 167 | }, 168 | "contact_type": "Business", 169 | "line_type": "Landline", 170 | "belongs_to": None, 171 | "associated_locations": None, 172 | "is_valid": None, 173 | "phone_number": "8888187128", 174 | "country_calling_code": "1", 175 | "extension": None, 176 | "carrier": None, 177 | "do_not_call": None, 178 | "reputation": None, 179 | "is_prepaid": None, 180 | "best_location": None 181 | }, 182 | { 183 | "id": { 184 | "key": "Phone.fff96fef-a2df-4b08-cfe3-bc7128b6f601.Durable", 185 | "url": "https://proapi.whitepages.com/2.1/entity/" 186 | "Phone.fff96fef-a2df-4b08-cfe3-bc7128b6f601.Durable.json?api_key=KEYVAL", 187 | "type": "Phone", 188 | "uuid": "fff96fef-a2df-4b08-cfe3-bc7128b6f601", 189 | "durability": "Durable" 190 | }, 191 | "contact_type": "Business", 192 | "line_type": "Landline", 193 | "belongs_to": None, 194 | "associated_locations": None, 195 | "is_valid": None, 196 | "phone_number": "2063663100", 197 | "country_calling_code": "1", 198 | "extension": None, 199 | "carrier": None, 200 | "do_not_call": None, 201 | "reputation": None, 202 | "is_prepaid": None, 203 | "best_location": None 204 | } 205 | ] 206 | }, 207 | { 208 | "id": { 209 | "key": "Business.137927e8-ac94-4450-8fe3-ae2bd6afefa3.Durable", 210 | "url": "https://proapi.whitepages.com/2.1/entity/" 211 | "Business.137927e8-ac94-4450-8fe3-ae2bd6afefa3.Durable.json?api_key=KEYVAL", 212 | "type": "Business", 213 | "uuid": "137927e8-ac94-4450-8fe3-ae2bd6afefa3", 214 | "durability": "Durable" 215 | }, 216 | "name": "Linda Tenney Toyota", 217 | "locations": [ 218 | { 219 | "id": { 220 | "key": "Location.2d7b7a78-9031-4a65-8d34-097d8129fc9b.Durable", 221 | "url": "https://proapi.whitepages.com/2.1/entity/" 222 | "Location.2d7b7a78-9031-4a65-8d34-097d8129fc9b.Durable.json?api_key=KEYVAL", 223 | "type": "Location", 224 | "uuid": "2d7b7a78-9031-4a65-8d34-097d8129fc9b", 225 | "durability": "Durable" 226 | }, 227 | "contact_type": "Business", 228 | "type": "Address", 229 | "legal_entities_at": None, 230 | "city": "Seattle", 231 | "postal_code": "98125", 232 | "zip4": "4430", 233 | "state_code": "WA", 234 | "country_code": "US", 235 | "address": "13355 Lake City Way NE, Seattle, WA 98125-4430", 236 | "house": "13355", 237 | "street_name": "Lake City", 238 | "street_type": "Way", 239 | "apt_type": None, 240 | "is_receiving_mail": True, 241 | "not_receiving_mail_reason": None, 242 | "usage": "Business", 243 | "delivery_point": "SingleUnit", 244 | "box_type": None, 245 | "address_type": "Street", 246 | "lat_long": { 247 | "latitude": 47.726143, 248 | "longitude": -122.293465, 249 | "accuracy": "RoofTop" 250 | }, 251 | "is_deliverable": True 252 | } 253 | ], 254 | "phones": [ 255 | { 256 | "id": { 257 | "key": "Phone.36816fef-a2df-4b08-cfe3-bc7128b6f602.Durable", 258 | "url": "https://proapi.whitepages.com/2.1/entity/" 259 | "Phone.36816fef-a2df-4b08-cfe3-bc7128b6f602.Durable.json?api_key=KEYVAL", 260 | "type": "Phone", 261 | "uuid": "36816fef-a2df-4b08-cfe3-bc7128b6f602", 262 | "durability": "Durable" 263 | }, 264 | "contact_type": "Business", 265 | "line_type": "Landline", 266 | "belongs_to": None, 267 | "associated_locations": None, 268 | "is_valid": None, 269 | "phone_number": "2063670080", 270 | "country_calling_code": "1", 271 | "extension": None, 272 | "carrier": None, 273 | "do_not_call": None, 274 | "reputation": None, 275 | "is_prepaid": None, 276 | "best_location": None 277 | } 278 | ] 279 | }, 280 | { 281 | "id": { 282 | "key": "Business.71072cf1-5345-46bb-a05b-e67a79f051ba.Durable", 283 | "url": "https://proapi.whitepages.com/2.1/entity/" 284 | "Business.71072cf1-5345-46bb-a05b-e67a79f051ba.Durable.json?api_key=KEYVAL", 285 | "type": "Business", 286 | "uuid": "71072cf1-5345-46bb-a05b-e67a79f051ba", 287 | "durability": "Durable" 288 | }, 289 | "name": "Toyota Of Lake City", 290 | "locations": [ 291 | { 292 | "id": { 293 | "key": "Location.4586c16a-711b-4f6d-af78-879aafcaa2a4.Ephemeral", 294 | "url": None, 295 | "type": "Location", 296 | "uuid": "4586c16a-711b-4f6d-af78-879aafcaa2a4", 297 | "durability": "Ephemeral" 298 | }, 299 | "contact_type": None, 300 | "type": "Address", 301 | "legal_entities_at": [ 302 | { 303 | "id": { 304 | "key": "Business.71072cf1-5345-46bb-a05b-e67a79f051ba.Durable", 305 | "url": "https://proapi.whitepages.com/2.1/entity/" 306 | "Business.71072cf1-5345-46bb-a05b-e67a79f051ba.Durable.json?" 307 | "api_key=KEYVAL", 308 | "type": "Business", 309 | "uuid": "71072cf1-5345-46bb-a05b-e67a79f051ba", 310 | "durability": "Durable" 311 | }, 312 | "valid_for": None, 313 | "name": "Toyota Of Lake City", 314 | "locations": None, 315 | "phones": [ 316 | { 317 | "id": { 318 | "key": "Phone.009f6fef-a2df-4b08-cfe3-bc7128b6f602.Durable", 319 | "url": "https://proapi.whitepages.com/2.1/entity/" 320 | "Phone.009f6fef-a2df-4b08-cfe3-bc7128b6f602.Durable.json?" 321 | "api_key=KEYVAL", 322 | "type": "Phone", 323 | "uuid": "009f6fef-a2df-4b08-cfe3-bc7128b6f602", 324 | "durability": "Durable" 325 | }, 326 | "contact_type": "Business" 327 | } 328 | ] 329 | } 330 | ], 331 | "city": "Seattle", 332 | "postal_code": "98125", 333 | "zip4": None, 334 | "state_code": "WA", 335 | "country_code": None, 336 | "address": None, 337 | "house": None, 338 | "street_name": None, 339 | "street_type": None, 340 | "apt_type": None, 341 | "is_receiving_mail": None, 342 | "not_receiving_mail_reason": None, 343 | "usage": None, 344 | "delivery_point": None, 345 | "box_type": None, 346 | "address_type": None, 347 | "lat_long": { 348 | "latitude": 47.726768, 349 | "longitude": -122.292671, 350 | "accuracy": None 351 | }, 352 | "is_deliverable": None 353 | } 354 | ], 355 | "phones": [ 356 | { 357 | "id": { 358 | "key": "Phone.009f6fef-a2df-4b08-cfe3-bc7128b6f602.Durable", 359 | "url": "https://proapi.whitepages.com/2.1/entity/" 360 | "Phone.009f6fef-a2df-4b08-cfe3-bc7128b6f602.Durable.json?api_key=KEYVAL", 361 | "type": "Phone", 362 | "uuid": "009f6fef-a2df-4b08-cfe3-bc7128b6f602", 363 | "durability": "Durable" 364 | }, 365 | "contact_type": "Business", 366 | "line_type": "Landline", 367 | "belongs_to": None, 368 | "associated_locations": None, 369 | "is_valid": None, 370 | "phone_number": "2063663183", 371 | "country_calling_code": "1", 372 | "extension": None, 373 | "carrier": None, 374 | "do_not_call": None, 375 | "reputation": None, 376 | "is_prepaid": None, 377 | "best_location": None 378 | } 379 | ] 380 | }, 381 | { 382 | "id": { 383 | "key": "Business.75341f27-6ab9-49f9-a7ed-16c70e53758f.Durable", 384 | "url": "https://proapi.whitepages.com/2.1/entity/" 385 | "Business.75341f27-6ab9-49f9-a7ed-16c70e53758f.Durable.json?api_key=KEYVAL", 386 | "type": "Business", 387 | "uuid": "75341f27-6ab9-49f9-a7ed-16c70e53758f", 388 | "durability": "Durable" 389 | }, 390 | "name": "Toyota Of Lake City", 391 | "locations": [ 392 | { 393 | "id": { 394 | "key": "Location.8a6c3fee-d0b4-48dc-8575-05d7ec8d8de3.Ephemeral", 395 | "url": None, 396 | "type": "Location", 397 | "uuid": "8a6c3fee-d0b4-48dc-8575-05d7ec8d8de3", 398 | "durability": "Ephemeral" 399 | }, 400 | "contact_type": None, 401 | "type": "Address", 402 | "legal_entities_at": [ 403 | { 404 | "id": { 405 | "key": "Business.75341f27-6ab9-49f9-a7ed-16c70e53758f.Durable", 406 | "url": "https://proapi.whitepages.com/2.1/entity/" 407 | "Business.75341f27-6ab9-49f9-a7ed-16c70e53758f.Durable.json?" 408 | "api_key=KEYVAL", 409 | "type": "Business", 410 | "uuid": "75341f27-6ab9-49f9-a7ed-16c70e53758f", 411 | "durability": "Durable" 412 | }, 413 | "valid_for": None, 414 | "name": "Toyota Of Lake City", 415 | "locations": None, 416 | "phones": [ 417 | { 418 | "id": { 419 | "key": "Phone.6d056fef-a2df-4b08-cfe3-bc7128b6f601.Durable", 420 | "url": "https://proapi.whitepages.com/2.1/entity/" 421 | "Phone.6d056fef-a2df-4b08-cfe3-bc7128b6f601.Durable.json?" 422 | "api_key=KEYVAL", 423 | "type": "Phone", 424 | "uuid": "6d056fef-a2df-4b08-cfe3-bc7128b6f601", 425 | "durability": "Durable" 426 | }, 427 | "contact_type": "Business" 428 | } 429 | ] 430 | } 431 | ], 432 | "city": "Seattle", 433 | "postal_code": "98125", 434 | "zip4": None, 435 | "state_code": "WA", 436 | "country_code": None, 437 | "address": None, 438 | "house": None, 439 | "street_name": None, 440 | "street_type": None, 441 | "apt_type": None, 442 | "is_receiving_mail": None, 443 | "not_receiving_mail_reason": None, 444 | "usage": None, 445 | "delivery_point": None, 446 | "box_type": None, 447 | "address_type": None, 448 | "lat_long": { 449 | "latitude": 47.716999, 450 | "longitude": -122.297119, 451 | "accuracy": None 452 | }, 453 | "is_deliverable": None 454 | } 455 | ], 456 | "phones": [ 457 | { 458 | "id": { 459 | "key": "Phone.6d056fef-a2df-4b08-cfe3-bc7128b6f601.Durable", 460 | "url": "https://proapi.whitepages.com/2.1/entity/" 461 | "Phone.6d056fef-a2df-4b08-cfe3-bc7128b6f601.Durable.json?api_key=KEYVAL", 462 | "type": "Phone", 463 | "uuid": "6d056fef-a2df-4b08-cfe3-bc7128b6f601", 464 | "durability": "Durable" 465 | }, 466 | "contact_type": "Business", 467 | "line_type": "Landline", 468 | "belongs_to": None, 469 | "associated_locations": None, 470 | "is_valid": None, 471 | "phone_number": "2063644290", 472 | "country_calling_code": "1", 473 | "extension": None, 474 | "carrier": None, 475 | "do_not_call": None, 476 | "reputation": None, 477 | "is_prepaid": None, 478 | "best_location": None 479 | } 480 | ] 481 | }, 482 | { 483 | "id": { 484 | "key": "Business.17878b3e-70c5-4961-9ebd-aa00bc556030.Durable", 485 | "url": "https://proapi.whitepages.com/2.1/entity/" 486 | "Business.17878b3e-70c5-4961-9ebd-aa00bc556030.Durable.json?api_key=KEYVAL", 487 | "type": "Business", 488 | "uuid": "17878b3e-70c5-4961-9ebd-aa00bc556030", 489 | "durability": "Durable" 490 | }, 491 | "name": "Toyota/scion Of Seattle", 492 | "locations": [ 493 | { 494 | "id": { 495 | "key": "Location.f07f59cf-70ef-4e29-af05-004fc3bf8c66.Durable", 496 | "url": "https://proapi.whitepages.com/2.1/entity/" 497 | "Location.f07f59cf-70ef-4e29-af05-004fc3bf8c66.Durable.json?api_key=KEYVAL", 498 | "type": "Location", 499 | "uuid": "f07f59cf-70ef-4e29-af05-004fc3bf8c66", 500 | "durability": "Durable" 501 | }, 502 | "contact_type": "Business", 503 | "type": "Address", 504 | "legal_entities_at": None, 505 | "city": "Seattle", 506 | "postal_code": "98121", 507 | "zip4": "2607", 508 | "state_code": "WA", 509 | "country_code": "US", 510 | "address": "2121 8th Ave, Seattle, WA 98121-2607", 511 | "house": "2121", 512 | "street_name": "8th", 513 | "street_type": "Ave", 514 | "apt_type": None, 515 | "is_receiving_mail": True, 516 | "not_receiving_mail_reason": None, 517 | "usage": "Business", 518 | "delivery_point": "SingleUnit", 519 | "box_type": None, 520 | "address_type": "Street", 521 | "lat_long": { 522 | "latitude": 47.616833, 523 | "longitude": -122.339081, 524 | "accuracy": "RoofTop" 525 | }, 526 | "is_deliverable": True 527 | } 528 | ], 529 | "phones": [ 530 | { 531 | "id": { 532 | "key": "Phone.5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a.Durable", 533 | "url": "https://proapi.whitepages.com/2.1/entity/" 534 | "Phone.5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a.Durable.json?api_key=KEYVAL", 535 | "type": "Phone", 536 | "uuid": "5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a", 537 | "durability": "Durable" 538 | }, 539 | "contact_type": "Business", 540 | "line_type": "Landline", 541 | "belongs_to": None, 542 | "associated_locations": None, 543 | "is_valid": None, 544 | "phone_number": "8003595635", 545 | "country_calling_code": "1", 546 | "extension": None, 547 | "carrier": None, 548 | "do_not_call": None, 549 | "reputation": None, 550 | "is_prepaid": None, 551 | "best_location": None 552 | }, 553 | { 554 | "id": { 555 | "key": "Phone.eb596fef-a2df-4b08-cfe3-bc7128b6f606.Durable", 556 | "url": "https://proapi.whitepages.com/2.1/entity/" 557 | "Phone.eb596fef-a2df-4b08-cfe3-bc7128b6f606.Durable.json?api_key=KEYVAL", 558 | "type": "Phone", 559 | "uuid": "eb596fef-a2df-4b08-cfe3-bc7128b6f606", 560 | "durability": "Durable" 561 | }, 562 | "contact_type": "Business", 563 | "line_type": "Landline", 564 | "belongs_to": None, 565 | "associated_locations": None, 566 | "is_valid": None, 567 | "phone_number": "2063824300", 568 | "country_calling_code": "1", 569 | "extension": None, 570 | "carrier": None, 571 | "do_not_call": None, 572 | "reputation": None, 573 | "is_prepaid": None, 574 | "best_location": None 575 | }, 576 | { 577 | "id": { 578 | "key": "Phone.5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a.Durable", 579 | "url": "https://proapi.whitepages.com/2.1/entity/" 580 | "Phone.5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a.Durable.json?api_key=KEYVAL", 581 | "type": "Phone", 582 | "uuid": "5ae76fef-a2e1-4b08-cfe3-bc7128b7ba1a", 583 | "durability": "Durable" 584 | }, 585 | "contact_type": "Business", 586 | "line_type": "Landline", 587 | "belongs_to": None, 588 | "associated_locations": None, 589 | "is_valid": None, 590 | "phone_number": "8003595635", 591 | "country_calling_code": "1", 592 | "extension": None, 593 | "carrier": None, 594 | "do_not_call": None, 595 | "reputation": None, 596 | "is_prepaid": None, 597 | "best_location": None 598 | } 599 | ] 600 | } 601 | ], 602 | "messages": [] 603 | } 604 | 605 | def test_business(self): 606 | business_test = [WhitePagesBusiness(business) for business in self['results']] 607 | self.assertEqual(business_test[0].name, 'Michaels Toyota') 608 | self.assertEqual(len(business_test[0].locations), 1) --------------------------------------------------------------------------------