def get(info_type): """Return specific business info for businesses.""" if info_type == 'tax_ids': json_data = request.get_json() if not json_data or not json_data['identifiers']: return jsonify({'message': 'No input data provided' }), HTTPStatus.BAD_REQUEST # remove the BC prefix identifiers = [x[-7:] for x in json_data['identifiers']] try: con = DB.connection con.begin() cursor = con.cursor() bn_15s = Business._get_bn_15s( # pylint: disable = protected-access; internal call cursor=cursor, identifiers=identifiers) return jsonify(bn_15s), HTTPStatus.OK except Exception as err: # pylint: disable=broad-except; want to catch all errors current_app.logger.error(err.with_traceback(None)) return jsonify({'message': 'Something went wrong.' }), HTTPStatus.INTERNAL_SERVER_ERROR return jsonify({'message': f'{info_type} not implemented.' }), HTTPStatus.NOT_IMPLEMENTED
def get(info_type, legal_type=None, identifier=None): # pylint: disable = too-many-return-statements; """Return specific business info for businesses.""" try: con = DB.connection con.begin() cursor = con.cursor() if info_type == 'tax_ids': json_data = request.get_json() if not json_data or not json_data['identifiers']: return jsonify({'message': 'No input data provided' }), HTTPStatus.BAD_REQUEST # remove the BC prefix identifiers = [x[-7:] for x in json_data['identifiers']] bn_15s = Business._get_bn_15s( # pylint: disable = protected-access; internal call cursor=cursor, identifiers=identifiers) return jsonify(bn_15s), HTTPStatus.OK if info_type == 'resolutions': if not legal_type or legal_type not in [ x.value for x in Business.LearBusinessTypes ]: return jsonify({ 'message': 'Must provide a valid legal type.' }), HTTPStatus.BAD_REQUEST if not identifier: return jsonify({ 'message': f'Must provide a business identifier for {info_type}.' }), HTTPStatus.BAD_REQUEST # convert identifier if BC legal_type if legal_type in Business.CORP_TYPE_CONVERSION[ Business.LearBusinessTypes.BCOMP.value]: identifier = identifier[-7:] return jsonify({ 'resolutionDates': Business.get_resolutions(cursor=cursor, corp_num=identifier) }), HTTPStatus.OK return jsonify({'message': f'{info_type} not implemented.' }), HTTPStatus.NOT_IMPLEMENTED except Exception as err: # pylint: disable=broad-except; want to catch all errors current_app.logger.error(err.with_traceback(None)) return jsonify({'message': 'Something went wrong.' }), HTTPStatus.INTERNAL_SERVER_ERROR