def _flatten_dict(d, prefix=[]):
    """
    Return a "flattened" dictionary suitable for passing to the JWP api. E.g.

    .. code::

        {
            'foo': 1,
            'bar': { 'buzz': 2 },
        }

    gets flattened to

    .. code::

        {
            'foo': 1,
            'bar.buzz': 2,
        }

    """
    rv = {}
    for k, v in d.items():
        if isinstance(v, dict):
            rv.update(_flatten_dict(v, prefix=prefix + [k]))
        else:
            rv['.'.join(prefix + [k])] = v
    return rv