from idcloud.enums.status import Status
from idcloud.resources.base import BaseResource
from idcloud.responses.scenario import Scenario


class VerifyAmlResource(BaseResource):
    NAME = 'Verify_AML'

    def initiate_aml_verification(
        self,
        first_name: str,
        surname: str,
        middle_name: str = None,
        birth_date: str = None,
        filter_region_keys: str = None,
        filter_region_keys_operator: str = None,
        filter_region: str = None,
        filter_region_operator: str = None,
        filter_pep: str = None,
        filter_pep_operator: str = None,
        filter_pep_exclude_adsr: str = None,
        filter_sic: str = None,
        filter_sic_operator: str = None,
        filter_sl: str = None,
        filter_sl_exclude_suspended: str = None,
        filter_sl_lrd_from: str = None,
        filter_sl_lrd_to: str = None,
        filter_ool: str = None,
        filter_ool_exclude_suspended: str = None,
        filter_ool_operator: str = None,
        filter_ool_lrd_from: str = None,
        filter_ool_lrd_to: str = None,
        filter_oel: str = None,
        filter_oel_extended_suspended: str = None,
        filter_oel_operator: str = None,
        filter_oel_lrd_from: str = None,
        filter_oel_lrd_to: str = None,
        filter_lrd_from: str = None,
        filter_lrd_to: str = None
    ) -> Scenario:
        person = self._fill_content(
            firstName=first_name,
            surname=surname,
            middleName=middle_name,
            birthDate=birth_date,
            filterRegionKeys=filter_region_keys,
            filterRegionKeysOperator=filter_region_keys_operator,
            filterRegion=filter_region,
            filterRegionOperator=filter_region_operator,
            filterPep=filter_pep,
            filterPepOperator=filter_pep_operator,
            filterPepExcludeAdsr=filter_pep_exclude_adsr,
            filterSic=filter_sic,
            filterSicOperator=filter_sic_operator,
            filterSl=filter_sl,
            filterSlExcludeSuspended=filter_sl_exclude_suspended,
            filterSlLrdFrom=filter_sl_lrd_from,
            filterSlLrdTo=filter_sl_lrd_to,
            filterOol=filter_ool,
            filterOolExcludeSuspended=filter_ool_exclude_suspended,
            filterOolOperator=filter_ool_operator,
            filterOolLrdFrom=filter_ool_lrd_from,
            filterOolLrdTo=filter_ool_lrd_to,
            filterOel=filter_oel,
            filterOelExcludeSuspended=filter_oel_extended_suspended,
            filterOelOperator=filter_oel_operator,
            filterOelLrdFrom=filter_oel_lrd_from,
            filterOelLrdTo=filter_oel_lrd_to,
            filterLrdFrom=filter_lrd_from,
            filterLrdTo=filter_lrd_to
        )

        payload = {
            'name': self.NAME,
            'input': {'person': person}
        }
        response_snapshot = self.requestor.request('POST', '/scs/v1/scenarios', payload=payload)

        return Scenario(
            id=response_snapshot.response_body.get('id'),
            name=response_snapshot.response_body.get('name'),
            status=Status(response_snapshot.response_body.get('status').lower()),
            steps=response_snapshot.response_body['state'].get('steps'),
            result=response_snapshot.response_body['state'].get('result'),
            raw_request={
                'body': response_snapshot.request_body,
                'headers': response_snapshot.request_headers
            },
            raw_response={
                'body': response_snapshot.response_body,
                'headers': response_snapshot.response_headers
            }
        )
