def update_verification(self, verification_type, verification_details): if verification_type in ORG_TYPE_VERIFICATION_TYPE_MAPPING: if ORG_TYPE_VERIFICATION_TYPE_MAPPING[verification_type] == OrganizationType.INDIVIDUAL.value: owner_username = verification_details["username"] status = verification_details["status"] updated_by = verification_details["updated_by"] org_repo.update_all_individual_organization_for_user(owner_username, status, updated_by) elif ORG_TYPE_VERIFICATION_TYPE_MAPPING[verification_type] == OrganizationType.ORGANIZATION.value: status = verification_details["status"] org_uuid = verification_details["org_uuid"] updated_by = verification_details["updated_by"] comment = verification_details["comment"] if status in ORG_STATUS_LIST: org_repo.update_organization_status(org_uuid, status, updated_by) organization = org_repo.get_org_for_org_uuid(org_uuid) owner = org_repo.get_org_member(org_uuid=org_uuid, role=Role.OWNER.value) owner_username = owner[0].username self.send_mail_to_owner(owner_username, comment, organization.id, status) else: logger.error(f"Invalid status {status}") raise MethodNotImplemented() else: logger.error(f"Invalid organization type with verification type {verification_type}") raise MethodNotImplemented() else: logger.error(f"Invalid verification type {verification_type}") raise MethodNotImplemented() return {}
def callback(self, verification_details, verification_id=None, entity_id=None): logger.info(f"received callback for verification_id:{verification_id} with details {verification_details}") if entity_id is not None: verification = verification_repository.get_verification(entity_id=entity_id) elif verification_id is not None: verification = verification_repository.get_verification(verification_id=verification_id) else: raise BadRequestException() if verification is None: raise Exception(f"No verification found entity_id:{entity_id}, verification_id:{verification_id}") if verification.type == VerificationType.INDIVIDUAL.value: current_verification_repo = individual_repository elif verification.type == VerificationType.DUNS.value: current_verification_repo = duns_repository else: raise MethodNotImplemented() if verification.status != VerificationStatus.APPROVED.value: current_verification = current_verification_repo.get_verification(verification.id) if current_verification is None: raise Exception(f"Verification not found with {verification_id} {entity_id}") current_verification.update_callback(verification_details) comment_list = current_verification.comment_dict_list() verification.reject_reason = comment_list[0]["comment"] verification.status = current_verification.status verification_repository.update_verification(verification) current_verification_repo.update_verification(current_verification) self._ack_verification(verification) else: raise MethodNotImplemented() return {}
def initiate_verification(self, verification_details, username): verification_type = verification_details["type"] verification_id = uuid4().hex current_time = datetime.utcnow() logger.info(f"initiate verification for type: {verification_type}") if verification_type == VerificationType.INDIVIDUAL.value: entity_id = username verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.APPROVED.value, username, current_time, current_time) verification_repository.add_verification(verification) elif verification_type == VerificationType.DUNS.value: entity_id = verification_details["entity_id"] logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) self.initiate_duns_verification(verification) else: raise MethodNotImplemented() return {}
def _ack_verification(self, verification): verification_service = "VERIFICATION_SERVICE" verification_status = verification.status if verification_status in [ VerificationStatus.ERROR.value, VerificationStatus.FAILED.value ]: verification_status = VerificationStatus.REJECTED.value if verification.type == VerificationType.DUNS.value: payload = { "path": "/org/verification", "queryStringParameters": { "status": verification_status, "org_uuid": verification.entity_id, "verification_type": verification.type, "comment": verification.reject_reason, "updated_by": verification_service } } lambda_response = self.boto_utils.invoke_lambda( REGISTRY_ARN["ORG_VERIFICATION"], invocation_type="RequestResponse", payload=json.dumps(payload)) if lambda_response["statusCode"] != 201: raise Exception(f"Failed to acknowledge callback to registry") else: raise MethodNotImplemented()
def initiate_verification(self, verification_details, username): verification_type = verification_details["type"] verification_id = uuid4().hex current_time = datetime.utcnow() logger.info(f"initiate verification for type: {verification_type}") if verification_type == VerificationType.JUMIO.value: entity_id = username logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) if self.is_allowed_bypass_verification(entity_id): return self.initiate_snet_verification(verification) self.terminate_if_not_allowed_to_verify(entity_id, verification_type) return self.initiate_jumio_verification(username, verification) elif verification_type == VerificationType.DUNS.value: entity_id = verification_details["entity_id"] logger.info( f"initiate verification for type: {verification_type} entity_id: {entity_id}" ) verification = Verification(verification_id, verification_type, entity_id, VerificationStatus.PENDING.value, username, current_time, current_time) self.initiate_duns_verification(verification) return {} else: raise MethodNotImplemented()
def __init__(self, env_type): self.__env_type = env_type if env_type == EnvironmentType.MAIN.value: self.__network_id = NETWORK_ID self.__contract_path = REG_CNTRCT_PATH self.__executor_address = "" self.__contract_address_path = REG_ADDR_PATH self.__blockchain_util = BlockChainUtil( provider_type="HTTP_PROVIDER", provider=NETWORKS[self.__network_id]['http_provider']) else: raise MethodNotImplemented()
def save_organization_draft(self, payload): logger.info( f"edit organization for user: {self.username} org_uuid: {self.org_uuid}" ) updated_organization = OrganizationFactory.org_domain_entity_from_payload( payload) current_organization = org_repo.get_org_for_org_uuid(self.org_uuid) self._archive_current_organization(current_organization) if current_organization.is_minor(updated_organization): org_repo.update_organization(updated_organization, self.username, OrganizationStatus.DRAFT.value) else: raise MethodNotImplemented() return "OK"
def callback(self, verification_id, verification_details): logger.info( f"received callback for verification_id:{verification_id} with details {verification_details}" ) verification = verification_repository.get_verification( verification_id) if verification.type == VerificationType.JUMIO.value: jumio_verification = JumioService(jumio_repository).callback( verification_id, verification_details) if jumio_verification.verification_status in REJECTED_JUMIO_VERIFICATION: verification.status = VerificationStatus.REJECTED.value elif jumio_verification.verification_status in FAILED_JUMIO_VERIFICATION: verification.status = VerificationStatus.FAILED.value elif jumio_verification.verification_status in VERIFIED_JUMIO_VERIFICATION: verification.status = VerificationStatus.APPROVED.value else: raise MethodNotImplemented() verification.reject_reason = jumio_verification.construct_reject_reason( ) verification_repository.update_verification(verification) elif verification.type == VerificationType.DUNS.value: duns_verification = duns_repository.get_verification( verification_id) duns_verification.update_callback(verification_details) comment_list = duns_verification.comment_dict_list() verification.reject_reason = comment_list[0]["comment"] verification.status = duns_verification.status verification_repository.update_verification(verification) duns_repository.update_verification(duns_verification) else: raise MethodNotImplemented() self._ack_verification(verification) return {}
def slack_callback(self, entity_id, verification_details): verification = verification_repository.get_latest_verification_for_entity( entity_id) if verification.type == VerificationType.DUNS.value: duns_verification = duns_repository.get_verification( verification.id) duns_verification.update_callback(verification_details) comment_list = duns_verification.comment_dict_list() verification.reject_reason = comment_list[0]["comment"] verification.status = duns_verification.status verification_repository.update_verification(verification) duns_repository.update_verification(duns_verification) else: raise MethodNotImplemented() self._ack_verification(verification) return {}
def submit(self, verification_id, transaction_status): logger.info( f"submit from jumio for verification_id: {verification_id} " f"with transaction_status: {transaction_status}") verification = verification_repository.get_verification( verification_id) if verification.type == VerificationType.JUMIO.value: jumio_verification = JumioService(jumio_repository).submit( verification.id, transaction_status) if jumio_verification.transaction_status == JumioTransactionStatus.ERROR.value: verification.status = VerificationStatus.ERROR.value verification_repository.update_verification(verification) else: raise MethodNotImplemented() return DAPP_POST_JUMIO_URL