<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def context(self):
 """ Provides request context """

        type = "client_associate" if self.key is None else "client_update"
        data = {
            "type": type,
            "application_type": self.type,
        }

        # is this an update?
        if self.key:
            data["client_id"] = self.key
            data["client_secret"] = self.secret

        # Add optional params
        if self.name:
            data["application_name"] = self.name

        if self.logo:
            data["logo_url"] = self.logo

        if self.contacts:
            # space seporated list
            data["contacts"] = " ".join(self.contacts)

        if self.redirect:
            data["redirect_uri"] = " ".join(self.redirect)

        # Convert to JSON  and send
        return json.dumps(data)