예제 #1
0
파일: contacts.py 프로젝트: zqzas/glasshack
    def list(self, **kwargs):
        """
        List contacts
        ref: https://developers.google.com/glass/v1/reference/contacts/list
        """
        r = self.user.request("GET", "/mirror/v1/contacts", data=kwargs)
        contacts = r.json()

        if (contacts is None or not "items" in contacts):
            raise exceptions.ContactException("Error listing contacts ",
                                              contacts)
        return contacts["items"]
예제 #2
0
파일: contacts.py 프로젝트: zqzas/glasshack
    def get(self, contactid):
        """
        Get a contact
        ref: https://developers.google.com/glass/v1/reference/contacts/get
        """
        r = self.user.request("GET", "/mirror/v1/contacts/%s" % (contactid))
        contact = r.json()

        if (contact is None or not "id" in contact):
            raise exceptions.ContactException("Error getting contact ",
                                              contact)
        return contact
예제 #3
0
파일: contacts.py 프로젝트: zqzas/glasshack
    def insert(self, **kwargs):
        """
        Insert a new contact
        ref: https://developers.google.com/glass/v1/reference/contacts/insert
        """
        r = self.user.request("POST",
                              "/mirror/v1/contacts",
                              data=json.dumps(kwargs))
        contact = r.json()

        if (contact is None or not "id" in contact):
            raise exceptions.ContactException("Error inserting contact",
                                              contact)
        return contact
예제 #4
0
파일: contacts.py 프로젝트: zqzas/glasshack
    def patch(self, contactid, **kwargs):
        """
        Patch a contact
        ref: https://developers.google.com/glass/v1/reference/contacts/patch
        """
        r = self.user.request("PATCH",
                              "/mirror/v1/contacts/%s" % (contactid),
                              data=json.dumps(kwargs))
        contact = r.json()

        if (contact is None or not "id" in contact):
            raise exceptions.ContactException("Error patching contact ",
                                              contact)
        return contact