r"""Validate user credentials.

        Returns
        -------
        bool

        Examples
        --------
        Validate credentials.

        >>> from srpenergy.client import SrpEnergyClient
        >>>
        >>> accountid = 'your account id'
        >>> username = 'your username'
        >>> password = 'your password'
        >>> client = SrpEnergyClient(accountid, username, password)
        >>>
        >>> valid = client.validate()
        >>> print(valid)
        True

def validate(self):
        r"""Validate user credentials.

        Returns
        -------
        bool

        Examples
        --------
        Validate credentials.

        >>> from srpenergy.client import SrpEnergyClient
        >>>
        >>> accountid = 'your account id'
        >>> username = 'your username'
        >>> password = 'your password'
        >>> client = SrpEnergyClient(accountid, username, password)
        >>>
        >>> valid = client.validate()
        >>> print(valid)
        True

        """
        try:

            with requests.Session() as session:

                result = session.get('https://www.srpnet.com/')
                result = session.post(
                    'https://myaccount.srpnet.com/sso/login/loginuser',
                    data={'UserName': self.username, 'Password': self.password}
                    )
                result_string = result.content.decode("utf-8")
                soup = BeautifulSoup(result_string, "html.parser")
                account_select = soup.find(
                    'select', attrs={'name': 'accountNumber'}
                    )

                accounts = []
                for option in account_select.find_all('option'):
                    if option['value'] != 'newAccount':
                        accounts.append(option['value'])

                valid = len(accounts) > 0

                return valid

        except Exception:  # pylint: disable=W0703
            return False