'Construct the dictionary mapping of parameters.
Encodes the dictionary into JSON if for json requests.
:return constructed dict or JSON payload
:raises GCMInvalidTtlException: if time_to_live is invalid'

@staticmethod
def construct_payload(**kwargs):

    is_json = kwargs.pop('is_json', True)
    if is_json:
        if (('topic' not in kwargs) and ('registration_ids' not in kwargs)):
            raise GCMMissingRegistrationException('Missing    registration_ids    or    topic')
        elif (('topic' in kwargs) and ('registration_ids' in kwargs)):
            raise GCMInvalidInputException("Invalid    parameters!    Can't    have    both    'registration_ids'    and    'to'    as    input    parameters")
        if ('topic' in kwargs):
            kwargs['to'] = '/topics/{}'.format(kwargs.pop('topic'))
        elif ('registration_ids' not in kwargs):
            raise GCMMissingRegistrationException('Missing    registration_ids')
        payload = JsonPayload(**kwargs).body
    else:
        payload = PlaintextPayload(**kwargs).body
    return payload
