async def METHOD_NAME(event_message: Dict[str, any]):
    """Process name events.
    1. Check if the NR already exists in entities table, if yes apply changes. If not create entity record.
    2. Check if new status is DRAFT, if yes call pay-api and get the account details for the payments against the NR.
    3. If an account is found, affiliate to that account.
    Args:
        event_message (object): cloud event message, sample below.
            {
                'specversion': '1.0.1',
                'type': 'bc.registry.names.events',
                'source': '/requests/6724165',
                'id': id,
                'time': '',
                'datacontenttype': 'application/json',
                'identifier': '781020202',
                'data': {
                    'request': {
                        'nrNum': 'NR 5659951',
                        'newState': 'APPROVED',
                        'previousState': 'DRAFT'
                    }
                }
            }
    """
    logger.debug('>>>>>>>process_name_events>>>>>')
    request_data = event_message.get('data').get('request') or event_message.get('data').get('name')
    nr_number = request_data['nrNum']
    nr_status = request_data['newState']
    nr_entity = EntityModel.find_by_business_identifier(nr_number)
    if nr_entity is None:
        logger.info("Entity doesn't exist, creating a new entity.")
        nr_entity = EntityModel(
            business_identifier=nr_number,
            corp_type_code=CorpType.NR.value
        )
    nr_entity.status = nr_status
    nr_entity.name = request_data.get('name', '')  # its not part of event now, this is to handle if they include it.
    nr_entity.last_modified_by = None  # TODO not present in event message.
    nr_entity.last_modified = parser.parse(event_message.get('time'))
    if nr_status == 'DRAFT' and not AffiliationModel.find_affiliations_by_business_identifier(nr_number):
        logger.info('Status is DRAFT, getting invoices for account')
        # Find account details for the NR.
        invoices = RestService.get(
            f'{APP_CONFIG.PAY_API_URL}/payment-requests?businessIdentifier={nr_number}',
            token=RestService.get_service_account_token()
        ).json()
        # Ideally there should be only one or two (priority fees) payment request for the NR.
        if invoices and invoices['invoices'] \
                and (auth_account_id := invoices['invoices'][0].get('paymentAccount').get('accountId')) \
                and str(auth_account_id).isnumeric():
            logger.info('Account ID received : %s', auth_account_id)
            # Auth account id can be service account value too, so doing a query lookup than find_by_id
            org: OrgModel = db.session.query(OrgModel).filter(OrgModel.id == auth_account_id).one_or_none()
            # If account is present and is not a gov account, then affiliate.
            if org and org.access_type != AccessType.GOVM.value:
                nr_entity.pass_code_claimed = True
                # Create an affiliation.
                logger.info('Creating affiliation between Entity : %s and Org : %s', nr_entity, org)
                affiliation: AffiliationModel = AffiliationModel(entity=nr_entity, org=org)
                affiliation.flush()
                activity: ActivityModel = ActivityModel(org_id=org.id, action=ActivityAction.CREATE_AFFILIATION.value,
                                                        item_name=nr_entity.business_identifier,
                                                        item_id=nr_entity.business_identifier,
                                                        item_type=None, item_value=None, actor_id=None
                                                        )
                activity.flush()
    nr_entity.save()
    logger.debug('<<<<<<<process_name_events<<<<<<<<<<')