from typing import Iterable
from typing import Mapping
from typing import List
from typing import Tuple


def _params_from_name_value_dicts(
    dicts: Iterable[Mapping[str, str]]
) -> List[Tuple[bytes, bytes]]:
    """
    Converts a HAR "params" element [0] into a list of tuples that can be used
    as value for requests' "params" keyword-argument.

    [0]: http://www.softwareishard.com/blog/har-12-spec/#params
    [1]: http://docs.python-requests.org/en/master/user/quickstart/
        #more-complicated-post-requests

    :raise KeyError: if one of the elements doesn't contain a "name" or "value" field.
    :raise UnicodeEncodeError: if an element's "name" or "value" string cannot
        be encoded in UTF-8.
    """
    return [(d["name"].encode(), d["value"].encode()) for d in dicts]