From 80adce3ceeb0b0e364f5f0b2d28ca80f4dc34638 Mon Sep 17 00:00:00 2001 From: novokrest Date: Sun, 10 Jun 2018 10:29:04 +0300 Subject: [PATCH] flock: Change name of var `res` to `users` in `get_recipient_id` method. --- zulip_bots/zulip_bots/bots/flock/flock.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/flock/flock.py b/zulip_bots/zulip_bots/bots/flock/flock.py index a798738..5249c33 100644 --- a/zulip_bots/zulip_bots/bots/flock/flock.py +++ b/zulip_bots/zulip_bots/bots/flock/flock.py @@ -1,6 +1,6 @@ import logging import requests -from typing import Any, Dict, Tuple, Optional +from typing import Any, Dict, List, Tuple, Optional from requests.exceptions import ConnectionError USERS_LIST_URL = 'https://api.flock.co/v1/roster.listContacts' @@ -13,10 +13,10 @@ You can send messages to any Flock user associated with your account from Zulip. # Matches the recipient name provided by user with list of users in his contacts. # If matches, returns the matched User's ID -def find_recipient_id(res: str, recipient_name: str) -> str: - for obj in res: - if recipient_name == obj['firstName']: - return obj['id'] +def find_recipient_id(users: List[Any], recipient_name: str) -> str: + for user in users: + if recipient_name == user['firstName']: + return user['id'] # Make request to given flock URL and return a two-element tuple # whose left-hand value contains JSON body of response (or None if request failed) @@ -39,11 +39,11 @@ def get_recipient_id(recipient_name: str, config: Dict[str, str]) -> Tuple[Optio payload = { 'token': token } - res, error = make_flock_request(USERS_LIST_URL, payload) - if res is None: + users, error = make_flock_request(USERS_LIST_URL, payload) + if users is None: return (None, error) - recipient_id = find_recipient_id(res, recipient_name) + recipient_id = find_recipient_id(users, recipient_name) if recipient_id is None: error = "No user found. Make sure you typed it correctly." return (None, error)