def get_docket(document, category,):
"""
Fetch a specific docket by id
:param str document: A JSON object containing a document records returned by the regulations.gov API
:param str category: Category of docket. One of the keys to REGULATION_CATEGORIES stored in constants.py
:return: A string containing the JSON returned by the regulations.gov API. None if received a 'status' field (which
indicates some kind of error)
"""
if 'docketId' not in document:
return None
search_parameters = {'api_key': REG_API_KEY, 'docketId': document['docketId']}
fetched_docket = requests.get('https://api.data.gov/regulations/v3/docket', params=search_parameters)
if fetched_docket.status_code != 200:
return None
# Add category field and whether open for comment
docket_obj = fetched_docket.json()
docket_obj['categoryId'] = category
docket_obj['category'] = constants.REGULATION_CATEGORIES[category]
docket_obj['openForComment'] = document.get('openForComment')
# Define date information for sorting
docket_obj = add_sort_date(docket_obj, document.get('commentDueDate'))
return docket_obj
评论列表
文章目录