Exemplo n.º 1
0
    def list(self, **kwargs):
        """
        List cards in the timeline
        ref: https://developers.google.com/glass/v1/reference/timeline/list
        """
        r = self.user.request("GET", "/mirror/v1/timeline", data=kwargs)
        cards = r.json()

        if (cards is None or not "items" in cards):
            raise exceptions.TimelineException(
                "Error listing cards in timeline ", cards)
        return cards["items"]
Exemplo n.º 2
0
    def get(self, cardid):
        """
        Get a card from the timeline
        ref: https://developers.google.com/glass/v1/reference/timeline/get
        """
        r = self.user.request("GET", "/mirror/v1/timeline/%s" % (cardid))
        card = r.json()

        if (card is None or not "id" in card):
            raise exceptions.TimelineException(
                "Error getting card from timeline ", card)
        return card
Exemplo n.º 3
0
    def patch(self, cardid, **kwargs):
        """
        Patch a card in the timeline
        ref: https://developers.google.com/glass/v1/reference/timeline/get
        """
        r = self.user.request("PATCH",
                              "/mirror/v1/timeline/%s" % (cardid),
                              data=json.dumps(kwargs))
        card = r.json()

        if (card is None or not "id" in card):
            raise exceptions.TimelineException(
                "Error patching card in timeline ", card)
        return card
Exemplo n.º 4
0
    def post(self, **kwargs):
        """
        Post a card to glass timeline
        ref: https://developers.google.com/glass/v1/reference/timeline/insert

        :param text: text content for the card
        :param html : html content for the card
        """
        r = self.user.request("POST",
                              "/mirror/v1/timeline",
                              data=json.dumps(kwargs))
        card = r.json()

        if (card is None or not "id" in card):
            raise exceptions.TimelineException(
                "Error posting card to timeline ", card)
        return card