code: def construct_payload(self, registration_ids, data=None, collapse_key=None,
                            delay_while_idle=False, time_to_live=None, is_json=True, dry_run=False):
          
  
          if time_to_live:
              if not (0 <= time_to_live <= self.GCM_TTL):
                  raise GCMInvalidTtlException("Invalid time to live value")
  
          payload = {}
          if is_json:
              payload['registration_ids'] = registration_ids
              if data:
                  payload['data'] = data
          else:
              payload['registration_id'] = registration_ids
              if data:
                  for key, value in data.items():
                      payload['data.%s' % key] = value
  
          if delay_while_idle:
              payload['delay_while_idle'] = delay_while_idle
  
          if time_to_live:
              payload['time_to_live'] = time_to_live
  
          if collapse_key:
              payload['collapse_key'] = collapse_key
  
          if dry_run:
              payload['dry_run'] = True
  
          if is_json:
              payload = json.dumps(payload)
  
          return payload
docs: Construct the dictionary mapping of parameters.
          Encodes the dictionary into JSON if for json requests.
          Helps appending 'data.' prefix to the plaintext data: 'hello' => 'data.hello'
  
          :return constructed dict or JSON payload
          :raises GCMInvalidTtlException: if time_to_live is invalid