Returns a list of domains for the particular user as a list of objects
    offset by ``page`` length of ``page_size``

    list_type : ALL
        One of ``ALL``, ``EXPIRING``, ``EXPIRED``

    search_term
        Keyword to look for on the domain list

    page : 1
        Number of result page to return

    page_size : 20
        Number of domains to be listed per page (minimum: ``10``, maximum:
        ``100``)

    sort_by
        One of ``NAME``, ``NAME_DESC``, ``EXPIREDATE``, ``EXPIREDATE_DESC``,
        ``CREATEDATE``, or ``CREATEDATE_DESC``

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_domains.get_list

def get_list(list_type=None,
             search_term=None,
             page=None,
             page_size=None,
             sort_by=None):
    '''
    Returns a list of domains for the particular user as a list of objects
    offset by ``page`` length of ``page_size``

    list_type : ALL
        One of ``ALL``, ``EXPIRING``, ``EXPIRED``

    search_term
        Keyword to look for on the domain list

    page : 1
        Number of result page to return

    page_size : 20
        Number of domains to be listed per page (minimum: ``10``, maximum:
        ``100``)

    sort_by
        One of ``NAME``, ``NAME_DESC``, ``EXPIREDATE``, ``EXPIREDATE_DESC``,
        ``CREATEDATE``, or ``CREATEDATE_DESC``

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_domains.get_list
    '''
    opts = salt.utils.namecheap.get_opts('namecheap.domains.getList')

    if list_type is not None:
        if list_type not in ['ALL', 'EXPIRING', 'EXPIRED']:
            log.error('Invalid option for list_type')
            raise Exception('Invalid option for list_type')
        opts['ListType'] = list_type

    if search_term is not None:
        if len(search_term) > 70:
            log.warning('search_term trimmed to first 70 characters')
            search_term = search_term[0:70]
        opts['SearchTerm'] = search_term

    if page is not None:
        opts['Page'] = page

    if page_size is not None:
        if page_size > 100 or page_size < 10:
            log.error('Invalid option for page')
            raise Exception('Invalid option for page')
        opts['PageSize'] = page_size

    if sort_by is not None:
        if sort_by not in ['NAME', 'NAME_DESC', 'EXPIREDATE', 'EXPIREDATE_DESC', 'CREATEDATE', 'CREATEDATE_DESC']:
            log.error('Invalid option for sort_by')
            raise Exception('Invalid option for sort_by')
        opts['SortBy'] = sort_by

    response_xml = salt.utils.namecheap.get_request(opts)

    if response_xml is None:
        return []

    domainresult = response_xml.getElementsByTagName("DomainGetListResult")[0]

    domains = []
    for d in domainresult.getElementsByTagName("Domain"):
        domains.append(salt.utils.namecheap.atts_to_dict(d))

    return domains