def get_parent_from_sam(client, duns_list):
    """ Calls SAM API to retrieve parent DUNS data by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding parent DUNS data
    """
    duns_parent = [
        {
            'awardee_or_recipient_uniqu':
            suds_obj.entityIdentification.DUNS,
            'ultimate_parent_unique_ide':
            suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber,
            'ultimate_parent_legal_enti':
            (suds_obj.coreData.DUNSInformation.globalParentDUNS.
             legalBusinessName or '').upper()
        } for suds_obj in get_entities(client, duns_list)
        if suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber
        or suds_obj.coreData.DUNSInformation.globalParentDUNS.legalBusinessName
    ]

    return pd.DataFrame(duns_parent)
def get_location_business_from_sam(client, duns_list):
    """ Calls SAM API to retrieve DUNS location/business type data by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding locations/business types
    """
    duns_name = [{
        'awardee_or_recipient_uniqu': suds_obj.entityIdentification.DUNS,
        'address_line_1': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'addressLine1', None),
        'address_line_2': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'addressLine2', None),
        'city': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'city', None),
        'state': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'stateOrProvince', None),
        'zip': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'ZIPCode', None),
        'zip4': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'ZIPCodePlus4', None),
        'country_code': getattr(suds_obj.coreData.businessInformation.physicalAddress, 'country', None),
        'congressional_district': getattr(suds_obj.coreData.businessInformation.physicalAddress,
                                          'congressionalDistrict', None),
        'business_types_codes': [business_type.code for business_type
                                 in getattr(suds_obj.coreData.generalInformation.listOfBusinessTypes,
                                            'businessType', [])]
    }
        for suds_obj in get_entities(client, duns_list)
    ]

    return pd.DataFrame(duns_name)
def get_name_from_sams(client, duns_list):
    """Calls SAM API to retrieve DUNS name by DUNS number. Returns DUNS info as Data Frame"""
    duns_name = [{
        'awardee_or_recipient_uniqu':
        suds_obj.entityIdentification.DUNS,
        'legal_business_name': (suds_obj.entityIdentification.legalBusinessName
                                or '').upper()
    } for suds_obj in get_entities(client, duns_list)
                 if suds_obj.entityIdentification.legalBusinessName]

    return pd.DataFrame(duns_name)
def get_parent_from_sams(client, duns_list):
    """Calls SAM API to retrieve parent DUNS data by DUNS number. Returns DUNS info as Data Frame"""
    duns_parent = [
        {
            'awardee_or_recipient_uniqu':
            suds_obj.entityIdentification.DUNS,
            'ultimate_parent_unique_ide':
            suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber,
            'ultimate_parent_legal_enti':
            (suds_obj.coreData.DUNSInformation.globalParentDUNS.
             legalBusinessName or '').upper()
        } for suds_obj in get_entities(client, duns_list)
        if suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber
        or suds_obj.coreData.DUNSInformation.globalParentDUNS.legalBusinessName
    ]

    return pd.DataFrame(duns_parent)
def get_location_business_from_sam(client, duns_list):
    """ Calls SAM API to retrieve DUNS location/business type data by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding locations/business types
    """
    duns_name = [{
        'awardee_or_recipient_uniqu':
        suds_obj.entityIdentification.DUNS,
        'address_line_1':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'addressLine1', None),
        'address_line_2':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'addressLine2', None),
        'city':
        getattr(suds_obj.coreData.businessInformation.physicalAddress, 'city',
                None),
        'state':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'stateOrProvince', None),
        'zip':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'ZIPCode', None),
        'zip4':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'ZIPCodePlus4', None),
        'country_code':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'country', None),
        'congressional_district':
        getattr(suds_obj.coreData.businessInformation.physicalAddress,
                'congressionalDistrict', None),
        'business_types_codes': [
            business_type.code for business_type in getattr(
                suds_obj.coreData.generalInformation.listOfBusinessTypes,
                'businessType', [])
        ]
    } for suds_obj in get_entities(client, duns_list)]

    return pd.DataFrame(duns_name)
def get_name_from_sam(client, duns_list):
    """ Calls SAM API to retrieve DUNS name by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding names
    """
    duns_name = [{
        'awardee_or_recipient_uniqu':
        suds_obj.entityIdentification.DUNS,
        'legal_business_name': (suds_obj.entityIdentification.legalBusinessName
                                or '').upper()
    } for suds_obj in get_entities(client, duns_list)
                 if suds_obj.entityIdentification.legalBusinessName]

    return pd.DataFrame(duns_name)
def get_name_from_sam(client, duns_list):
    """ Calls SAM API to retrieve DUNS name by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding names
    """
    duns_name = [{
        'awardee_or_recipient_uniqu': suds_obj.entityIdentification.DUNS,
        'legal_business_name': (suds_obj.entityIdentification.legalBusinessName or '').upper()
    }
        for suds_obj in get_entities(client, duns_list)
        if suds_obj.entityIdentification.legalBusinessName
    ]

    return pd.DataFrame(duns_name)
def get_parent_from_sam(client, duns_list):
    """ Calls SAM API to retrieve parent DUNS data by DUNS number. Returns DUNS info as Data Frame

        Args:
            client: the SAM service client
            duns_list: list of DUNS to search

        Returns:
            dataframe representing the DUNS and corresponding parent DUNS data
    """
    duns_parent = [{
        'awardee_or_recipient_uniqu': suds_obj.entityIdentification.DUNS,
        'ultimate_parent_unique_ide': suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber,
        'ultimate_parent_legal_enti': (suds_obj.coreData.DUNSInformation.globalParentDUNS.legalBusinessName
                                       or '').upper()
    }
        for suds_obj in get_entities(client, duns_list)
        if suds_obj.coreData.DUNSInformation.globalParentDUNS.DUNSNumber
        or suds_obj.coreData.DUNSInformation.globalParentDUNS.legalBusinessName
    ]

    return pd.DataFrame(duns_parent)