def updateChallenge(creds, challengeId, name="", summary="", description="", leader=""): """ Update the name, description, or leader of a challenge. User must be challenge leader. creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'} challengeId: The challenge _id. Type: UUID name (optional): The new full name of the challenge. Type: String summary (optional): The new challenge summary. Type: String description (optional): The new challenge description. Type: String leader (optional): The UUID of the new challenge leader. Type: String """ url = "https://habitica.com/api/v3/challenges/" + challengeId payload = {} if name != "": payload["name"] = name if summary != "": payload["summary"] = summary if description != "": payload["description"] = description if leader != "": payload["leader"] = leader return (putUrl(url, creds, payload))
def updateChallenge(self, name="", summary="", description="", leader=""): """ Update the name, description, or leader of a challenge. User must be challenge leader. name (optional): The new full name of the challenge. Type: String summary (optional): The new challenge summary. Type: String description (optional): The new challenge description. Type: String leader (optional): The UUID of the new challenge leader. Type: String """ url = "https://habitica.com/api/v3/challenges/" + self.id payload = {} if name != "": payload["name"] = name if summary != "": payload["summary"] = summary if description != "": payload["description"] = description if leader != "": payload["leader"] = leader return (putUrl(url, self.credentials, payload))
def updateUsername(self, username): """ Update the username of a local user username: The new username """ url = "https://habitica.com/api/v3/user/auth/update-username" payload = {"username": username} return(putUrl(url, self.credentials, payload))
def updateEmail(self, newEmail, password): """ Change the user email address newEmail: The new email address password: The user password """ url = "https://habitica.com/api/v3/user/auth/update-email" payload = {"newEmail": newEmail, "password": password} return(putUrl(url, self.credentials, payload))
def updateChecklist(creds, taskId, itemId, text): """ Task - Unassign a user from a task Unassigns a user to from a group task creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'} taskId: The task _id or alias itemId: The checklist item _id text: The text that will replace the current checkitem text. """ url = "https://habitica.com/api/v3/tasks/" + taskId + "/checklist/" + itemId payload = {"text": text} return (putUrl(url, creds, payload))
def updateChecklist(self, itemId, text): """ Task - Unassign a user from a task Unassigns a user to from a group task TODO: test itemId: The checklist item _id text: The text that will replace the current checkitem text. """ url = "https://habitica.com/api/v3/tasks/" + self.id + "/checklist/" + itemId payload = {"text": text} return (putUrl(url, self.credentials, payload))
def updateGroup(self, credentials): """ Group - Remove a member from a group Permission: GroupLeader, Admin TODO: There's something missing from the online documentation. I have a feeling like there should be a body parameter containing all the changes to make. Online documentation: https://habitica.com/apidoc/#api-Group-UpdateGroup credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'} groupId: The group _id ('party' for the user party and 'habitrpg' for tavern are accepted) """ url = 'https://habitica.com/api/v3/groups/' + self.groupId return (putUrl(url, credentials))
def updateUser(self, payload): """ Some of the user items can be updated, such as preferences, flags and stats. ^ Example payload: { "achievements.habitBirthdays": 2, "profile.name": "MadPink", "stats.hp": 53, "flags.warnedLowHealth": false, "preferences.allocationMode": "flat", "preferences.hair.bangs": 3 } """ url = "https://habitica.com/api/v3/user" return(putUrl(url, self.credentials, payload))
def updateTag(credentials, tagId, name): """Update a tag's name. Args: credentials (dict): Formatted dictionary of user id and api key. If a user object has already been created, use user.credentials. format: {'x-api-user': "******", 'x-api-key': "api_key_here"} tagId (str): The tag's ID. name (str): The new name of the tag. Returns: A JSON response object. Keys: userV, notifications, data, appVersion, success. """ url = "https://habitica.com/api/v3/tags/" + tagId payload = {"name": name} return(putUrl(url, credentials, payload))
def updateGroup(self, credentials): """Remove a member from a group Permission: GroupLeader, Admin Args: credentials (dict): Formatted dictionary of user id and api key. If a user object has already been created, use user.credentials. format: {'x-api-user': "******", 'x-api-key': "api_key_here"} Returns: A JSON response object. Keys: userV, notifications, data, appVersion, success. TODO: There's something missing from the online documentation. I have a feeling like there should be a body parameter containing all the changes to make. Online documentation: https://habitica.com/apidoc/#api-Group-UpdateGroup """ url = 'https://habitica.com/api/v3/groups/' + self.groupId return (putUrl(url, credentials))
def updateTask(creds, taskId, text=None, attribute=None, collapseChecklist=False, notes=None, date=None, priority=1, reminders=None, frequency="weekly", repeat=True, everyX=1, streak=0, startDate=None, up=True, down=True, value=0): """ Task - Update a task creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'} taskId: The task _id or alias text: String (optional). The text to be displayed for the task attribute (optional): String. User's attribute to use, options are: "str", "int", "per", "con" Allowed values: "str", "int", "per", "con" collapseChecklist (optional): Boolean. Determines if a checklist will be displayed Default value: false notes (optional): String. Extra notes date (optional): String. Due date to be shown in task list. Only valid for type "todo." priority (optional): Number. Difficulty, options are 0.1, 1, 1.5, 2; eqivalent of Trivial, Easy, Medium, Hard. Default value: 1 Allowed values: "0.1", "1", "1.5", "2" reminders (optional): String[]. Array of reminders, each an object that must include: a UUID, startDate and time. For example {"id":"ed427623-9a69-4aac-9852-13deb9c190c3","startDate":"1/16/17","time":"1/16/17" } frequency (optional): String. Value "weekly" enables "On days of the week", value "daily" enables "EveryX Days". Only valid for type "daily". Default value: weekly Allowed values: "weekly", "daily" repeat (optional): String. List of objects for days of the week, Days that are true will be repeated upon. Only valid for type "daily". Any days not specified will be marked as true. Days are: su, m, t, w, th, f, s. Value of frequency must be "weekly". For example, to skip repeats on Mon & Fri: "repeat":{"f":false,"m":false} Default value: true everyX (optional): Number. Value of frequency must be "daily", the number of days until this daily task is available again. Default value: 1 streak (optional): Number. Number of days that the task has consecutively been checked off. Only valid for type "daily" Default value: 0 startDate (optional): Date. Date when the task will first become available. Only valid for type "daily" up (optional): Boolean. Only valid for type "habit." If true, enables the "+" under "Directions/Action" for "Good habits." Default value: true down (optional): Boolean. Only valid for type "habit." If true, enables the "-" under "Directions/Action" for "Bad habits." Default value: true value (optional): Number. Only valid for type "reward." The cost in gold of the reward. Default value: 0 """ url = "https://habitica.com/api/v3/tasks/" + taskId payload = {} if text != None: payload["text"] = text if attribute != None: payload["attribute"] = attribute if collapseChecklist != False: payload["collapseChecklist"] = collapseChecklist if notes != None: payload["notes"] = notes if date != None: payload["date"] = date if priority != 1: payload["priority"] = priority if reminders != None: payload["reminders"] = reminders if frequency != "weekly": payload["frequency"] = frequency if repeat != True: payload["repeat"] = repeat if everyX != 1: payload["everyX"] = everyX if streak != 0: payload["streak"] = streak if startDate != None: payload["startDate"] = startDate if up != True: payload["up"] = up if down != True: payload["down"] = down if value != 0: payload["value"] = value return (putUrl(url, creds, payload))