Example #1
0
File: poll.py Project: clugg/pspaw
def get(id):
    """
    Fetch an existing poll by querying the API with its ID.

    Args:
        id (int): ID of the poll.

    Returns:
        Poll: A new Poll instance with the poll's information.
    """

    return Poll(**request.get("http://strawpoll.me/api/v2/polls/{}".format(id)))
Example #2
0
File: poll.py Project: clugg/pspaw
    def refresh(self):
        """
        Fetch new data from the API and update the poll's results and total votes.

        Returns:
            None.
        """

        req = request.get("http://strawpoll.me/api/v2/polls/{}".format(self.id))
        options = req["options"] if "options" in req else []
        votes = req["votes"] if "votes" in req else []
        self._update_results(options, votes)