<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_hook(self, auth, repo_name, hook_id, update, organization=None):
 """ Updates hook with id ``hook_id`` according to ``update``. :param auth.Authentication auth: authentication object :param str repo_name: repo of the hook to update :param int hook_id: id of the hook to update :param GogsHookUpdate update: a ``GogsHookUpdate`` object describing the requested update :param str organization: name of associated organization, if applicable :return: the updated hook :rtype: GogsRepo.Hook :raises NetworkFailure: if there is an error communicating with the server :raises ApiFailure: if the request cannot be serviced """

        if organization is not None:
            path = "/repos/{o}/{r}/hooks/{i}".format(o=organization, r=repo_name, i=hook_id)
        else:
            path = "/repos/{r}/hooks/{i}".format(r=repo_name, i=hook_id)
        response = self._patch(path, auth=auth, data=update.as_dict())
        return GogsRepo.Hook.from_json(response.json())