Skip to content

Commit 61ea239

Browse files
committed
whitespace fuckshit
1 parent 347f869 commit 61ea239

File tree

1 file changed

+142
-140
lines changed

1 file changed

+142
-140
lines changed

nanpa/client.py

+142-140
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
# North American Numbering Plan Administration (NANPA) API Client - Developed by acidvegas in Python (https://git.acid.vegas/nanpa)
3+
# nanpa/client.py
34

45
import json
56
import logging
@@ -9,210 +10,211 @@
910

1011

1112
class NanpaAPI:
12-
def __init__(self):
13-
'''Initialize the NANPA API client.'''
13+
def __init__(self):
14+
'''Initialize the NANPA API client.'''
1415

15-
self.base_url = 'https://api.nanpa.com/reports/public'
16+
self.base_url = 'https://api.nanpa.com/reports/public'
1617

17-
def _make_request(self, endpoint: str, params: dict = None) -> dict:
18-
'''
19-
Make a request to the NANPA API.
20-
21-
:param endpoint: API endpoint to call
22-
:param params: Optional query parameters
23-
'''
2418

25-
url = f'{self.base_url}/{endpoint}'
26-
27-
if params:
28-
url += '?' + urllib.parse.urlencode(params)
29-
30-
try:
31-
with urllib.request.urlopen(url) as response:
32-
return json.loads(response.read().decode())
33-
except urllib.error.URLError as e:
34-
logging.error(f'Failed to make request to {url}: {e}')
35-
return None
19+
def _make_request(self, endpoint: str, params: dict = None) -> dict:
20+
'''
21+
Make a request to the NANPA API.
3622
23+
:param endpoint: API endpoint to call
24+
:param params: Optional query parameters
25+
'''
3726

38-
def get_9yy_codes(self) -> dict:
39-
'''Get 9YY specialty codes.'''
27+
url = f'{self.base_url}/{endpoint}'
4028

41-
return self._make_request('specialityResources/9yy/codes')
29+
if params:
30+
url += '?' + urllib.parse.urlencode(params)
4231

32+
try:
33+
with urllib.request.urlopen(url) as response:
34+
return json.loads(response.read().decode())
35+
except urllib.error.URLError as e:
36+
logging.error(f'Failed to make request to {url}: {e}')
37+
return None
4338

44-
def get_area_code_info(self, npa: str) -> dict:
45-
'''
46-
Get detailed information about a specific area code.
47-
48-
:param npa: Area code to lookup
49-
'''
5039

51-
params = {'npa': npa}
40+
def get_9yy_codes(self) -> dict:
41+
'''Get 9YY specialty codes.'''
5242

53-
return self._make_request('npa/areaCodeListing', params)
43+
return self._make_request('specialityResources/9yy/codes')
5444

5545

56-
def get_area_codes_by_state(self, state: str) -> dict:
57-
'''
58-
Get area codes for a specific state.
59-
60-
:param state: Two-letter state code
61-
'''
46+
def get_area_code_info(self, npa: str) -> dict:
47+
'''
48+
Get detailed information about a specific area code.
6249
63-
params = {'states': state, 'isExternal': 'false'}
50+
:param npa: Area code to lookup
51+
'''
6452

65-
return self._make_request('code/getNpasForStates', params)
53+
params = {'npa': npa}
6654

55+
return self._make_request('npa/areaCodeListing', params)
6756

68-
def get_co_code_forecast(self, state: str, npa: str) -> dict:
69-
'''
70-
Get CO code forecast information.
71-
72-
:param state: Two-letter state code
73-
:param npa: Area code
7457

75-
'''
58+
def get_area_codes_by_state(self, state: str) -> dict:
59+
'''
60+
Get area codes for a specific state.
7661
77-
params = {'state': state, 'npa': npa}
62+
:param state: Two-letter state code
63+
'''
7864

79-
return self._make_request('tbco/coCodeForecast', params)
65+
params = {'states': state, 'isExternal': 'false'}
8066

67+
return self._make_request('code/getNpasForStates', params)
8168

82-
def get_current_pool_tracking(self, state: str, npa: str) -> dict:
83-
'''
84-
Get current pool tracking information.
85-
86-
:param state: Two-letter state code
87-
:param npa: Area code
88-
'''
8969

90-
params = {'state': state, 'npa': npa}
70+
def get_co_code_forecast(self, state: str, npa: str) -> dict:
71+
'''
72+
Get CO code forecast information.
9173
92-
return self._make_request('tbco/currentPoolTracking', params)
74+
:param state: Two-letter state code
75+
:param npa: Area code
9376
77+
'''
9478

95-
def get_lrn_forecast(self, state: str, npa: str) -> dict:
96-
'''
97-
Get LRN forecast information.
98-
99-
:param state: Two-letter state code
100-
:param npa: Area code
101-
'''
79+
params = {'state': state, 'npa': npa}
10280

103-
params = {'state': state, 'npa': npa}
81+
return self._make_request('tbco/coCodeForecast', params)
10482

105-
return self._make_request('tbco/lrnForecast', params)
10683

84+
def get_current_pool_tracking(self, state: str, npa: str) -> dict:
85+
'''
86+
Get current pool tracking information.
10787
108-
def get_pooling_forecast(self, state: str, npa: str) -> dict:
109-
'''
110-
Get pooling forecast information.
111-
112-
:param state: Two-letter state code
113-
:param npa: Area code
114-
'''
88+
:param state: Two-letter state code
89+
:param npa: Area code
90+
'''
11591

116-
params = {'state': state, 'npa': npa}
92+
params = {'state': state, 'npa': npa}
11793

118-
return self._make_request('tbco/poolingForecast', params)
94+
return self._make_request('tbco/currentPoolTracking', params)
11995

12096

121-
def get_pstn_activation(self, state: str) -> dict:
122-
'''
123-
Get PSTN activation information.
124-
125-
:param state: Two-letter state code
126-
'''
97+
def get_lrn_forecast(self, state: str, npa: str) -> dict:
98+
'''
99+
Get LRN forecast information.
127100
128-
params = {'state': state}
101+
:param state: Two-letter state code
102+
:param npa: Area code
103+
'''
129104

130-
return self._make_request('tbco/pstnActivation', params)
105+
params = {'state': state, 'npa': npa}
131106

107+
return self._make_request('tbco/lrnForecast', params)
132108

133-
def get_rate_center_changes(self, start_date: str, end_date: str) -> dict:
134-
'''
135-
Get rate center changes between two dates.
136-
137-
:param start_date: Start date in format YYYY-MM-DDT00:00:00.000-05:00
138-
:param end_date: End date in format YYYY-MM-DDT23:59:59.999-05:00
139-
'''
140109

141-
params = {'startDate': start_date, 'endDate': end_date}
110+
def get_pooling_forecast(self, state: str, npa: str) -> dict:
111+
'''
112+
Get pooling forecast information.
142113
143-
return self._make_request('npa/rateCenterChanges', params)
114+
:param state: Two-letter state code
115+
:param npa: Area code
116+
'''
144117

118+
params = {'state': state, 'npa': npa}
145119

146-
def get_rate_centers(self, state: str) -> dict:
147-
'''
148-
Get rate centers for a specific state.
149-
150-
:param state: Two-letter state code
151-
'''
120+
return self._make_request('tbco/poolingForecast', params)
152121

153-
params = {'state': state}
154122

155-
return self._make_request('npa/rateCenters', params)
123+
def get_pstn_activation(self, state: str) -> dict:
124+
'''
125+
Get PSTN activation information.
156126
127+
:param state: Two-letter state code
128+
'''
157129

158-
def get_specialty_codes_aging(self) -> dict:
159-
'''Get aging 5XX specialty codes.'''
130+
params = {'state': state}
160131

161-
return self._make_request('specialityResources/5xx/aging')
132+
return self._make_request('tbco/pstnActivation', params)
162133

163134

164-
def get_specialty_codes_assigned(self) -> dict:
165-
'''Get assigned 5XX specialty codes.'''
135+
def get_rate_center_changes(self, start_date: str, end_date: str) -> dict:
136+
'''
137+
Get rate center changes between two dates.
166138
167-
return self._make_request('specialityResources/5xx/assigned')
139+
:param start_date: Start date in format YYYY-MM-DDT00:00:00.000-05:00
140+
:param end_date: End date in format YYYY-MM-DDT23:59:59.999-05:00
141+
'''
168142

143+
params = {'startDate': start_date, 'endDate': end_date}
169144

170-
def get_specialty_codes_available(self, code_type: str = '5xx') -> dict:
171-
'''
172-
Get available specialty codes.
173-
174-
:param code_type: Code type ('5xx' or '9yy')
175-
'''
145+
return self._make_request('npa/rateCenterChanges', params)
176146

177-
return self._make_request(f'specialityResources/{code_type}/available')
178147

148+
def get_rate_centers(self, state: str) -> dict:
149+
'''
150+
Get rate centers for a specific state.
179151
180-
def get_states(self) -> dict:
181-
'''Get all NANPA states and territories.'''
152+
:param state: Two-letter state code
153+
'''
182154

183-
return self._make_request('nanpaStates')
155+
params = {'state': state}
184156

157+
return self._make_request('npa/rateCenters', params)
185158

186-
def get_thousands_blocks(self, state: str, npa: str, report_type: str = 'AS') -> dict:
187-
'''
188-
Get thousands blocks information.
189-
190-
:param state: Two-letter state code
191-
:param npa: Area code
192-
:param report_type: Report type (default: AS)
193-
'''
194159

195-
params = {'state': state, 'npa': npa, 'reportType': report_type}
160+
def get_specialty_codes_aging(self) -> dict:
161+
'''Get aging 5XX specialty codes.'''
196162

197-
return self._make_request('tbco/thousandsBlocks', params)
163+
return self._make_request('specialityResources/5xx/aging')
164+
165+
166+
def get_specialty_codes_assigned(self) -> dict:
167+
'''Get assigned 5XX specialty codes.'''
168+
169+
return self._make_request('specialityResources/5xx/assigned')
170+
171+
172+
def get_specialty_codes_available(self, code_type: str = '5xx') -> dict:
173+
'''
174+
Get available specialty codes.
175+
176+
:param code_type: Code type ('5xx' or '9yy')
177+
'''
178+
179+
return self._make_request(f'specialityResources/{code_type}/available')
180+
181+
182+
def get_states(self) -> dict:
183+
'''Get all NANPA states and territories.'''
184+
185+
return self._make_request('nanpaStates')
186+
187+
188+
def get_thousands_blocks(self, state: str, npa: str, report_type: str = 'AS') -> dict:
189+
'''
190+
Get thousands blocks information.
191+
192+
:param state: Two-letter state code
193+
:param npa: Area code
194+
:param report_type: Report type (default: AS)
195+
'''
196+
197+
params = {'state': state, 'npa': npa, 'reportType': report_type}
198+
199+
return self._make_request('tbco/thousandsBlocks', params)
198200

199201

200202

201203
def main():
202-
'''Example usage of the NANPA API client.'''
204+
'''Example usage of the NANPA API client.'''
205+
206+
client = NanpaAPI()
207+
208+
# Example API calls
209+
states = client.get_states()
210+
logging.info(f'States: {json.dumps(states, indent=2)}')
211+
212+
fl_codes = client.get_area_codes_by_state('FL')
213+
logging.info(f'Florida area codes: {json.dumps(fl_codes, indent=2)}')
203214

204-
client = NanpaAPI()
205-
206-
# Example API calls
207-
states = client.get_states()
208-
logging.info(f'States: {json.dumps(states, indent=2)}')
209-
210-
fl_codes = client.get_area_codes_by_state('FL')
211-
logging.info(f'Florida area codes: {json.dumps(fl_codes, indent=2)}')
212-
213-
area_info = client.get_area_code_info('301')
214-
logging.info(f'301 area code info: {json.dumps(area_info, indent=2)}')
215+
area_info = client.get_area_code_info('301')
216+
logging.info(f'301 area code info: {json.dumps(area_info, indent=2)}')
215217

216218

217219
if __name__ == '__main__':
218-
main()
220+
main()

0 commit comments

Comments
 (0)