def get_first_record( cls, download: bool=True ) -> NistBeaconValue: """ Get the first (oldest) record available. Since the first record IS a known value in the system we can load it from constants. :param download: 'True' will always reach out to NIST to get the first record. 'False' returns a local copy. :return: The first beacon value. 'None' otherwise. """ if download: return NistBeacon.get_record(cls._INIT_RECORD.timestamp) else: return NistBeaconValue.from_json(cls._INIT_RECORD.json)
def _query_nist(cls, url_data: str) -> NistBeaconValue: try: nist_response = requests.get( "{0}/{1}".format( cls._NIST_API_URL, url_data, ) ) if ( isinstance(nist_response, requests.Response) and nist_response.status_code is requests.codes.OK ): return NistBeaconValue.from_xml(nist_response.text) else: return None except RequestException: return None