import typing


def build_qs_dict(
    finam_id: str, market_id: str, date_from: str, date_to: str,
) -> typing.Dict[str, typing.Union[str, int]]:
    """Build a dict that can be used to generate query string to export api."""
    df, mf, yf = list(map(int, date_from.split('.')))
    dt, mt, yt = list(map(int, date_to.split('.')))

    return {
        'market': market_id,
        'em': finam_id,
        'mstime': 'on',
        'mstimever': '1',
        'MSOR': '1',
        'tmf': '1',
        'dtf': '1',
        'apply': '0',
        'df': df,
        'dt': dt,
        'yf': yf,
        'yt': yt,
        'mt': mt - 1,  # months starts from 0
        'mf': mf - 1,
        'p': '8',
        'f': 'report',
        'e': '.txt',
        'sep': '1',
        'sep2': '1',
        'datf': '5',  # report type
        'at': '0',  # no headers
    }