from dataclasses import dataclass, asdict
from typing import List

from domainmaster.commands.base import BaseCommand
from domainmaster.errors import DomainmasterError


class ShowDomain(BaseCommand):
    COMMAND = 'show domain'

    @dataclass
    class Params:
        domain: str
        nsset: str
        keyset: str
        registrant: str
        admin: List[str]
        idacc: str
        iddealer: str
        contact: str
        password: str

    def execute(self, params: Params):
        payload = {
            'command': self.COMMAND,
            'params': asdict(params)
        }

        response = self.requestor.request(payload)

        if response['status'] != 'success':
            raise DomainmasterError(message=response['message'])

        return response
