def reply(self, **reply_data):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     url = "/%s/%s/reply" % (collection, self.id)
     reply_data['conversation_id'] = self.id
     response = Intercom.post(url, **reply_data)
     return self.from_response(response)
Exemple #2
0
 def reply(self, **reply_data):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     url = "/%s/%s/reply" % (collection, self.id)
     reply_data['conversation_id'] = self.id
     response = Intercom.post(url, **reply_data)
     return self.from_response(response)
    def create(cls, **params):
        from intercom import Intercom

        collection = utils.resource_class_to_collection_name(cls)
        response = Intercom.post("/%s/" % (collection), **params)
        if response:  # may be empty if we received a 202
            return cls(**response)
Exemple #4
0
 def save(self):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     params = self.attributes
     if self.id_present and not self.posted_updates:
         # update
         response = Intercom.put('/%s/%s' % (collection, self.id), **params)
     else:
         # create
         params.update(self.identity_hash)
         response = Intercom.post('/%s' % (collection), **params)
     if response:
         return self.from_response(response)
Exemple #5
0
 def save(self):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     params = self.attributes
     if self.id_present and not self.posted_updates:
         # update
         response = Intercom.put('/%s/%s' % (collection, self.id), **params)
     else:
         # create
         params.update(self.identity_hash)
         response = Intercom.post('/%s' % (collection), **params)
     if response:
         return self.from_response(response)
Exemple #6
0
    def _tag_collection(cls, collection_name, name, objects, untag=False):
        from intercom import Intercom
        collection = utils.resource_class_to_collection_name(cls)
        object_ids = []
        for obj in objects:
            if not hasattr(obj, 'keys'):
                obj = {'id': obj}
            if untag:
                obj['untag'] = True
            object_ids.append(obj)

        params = {
            'name': name,
            collection_name: object_ids,
        }
        response = Intercom.post("/%s" % (collection), **params)
        return cls(**response)
Exemple #7
0
    def _tag_collection(
            cls, collection_name, name, objects, untag=False):
        from intercom import Intercom
        collection = utils.resource_class_to_collection_name(cls)
        object_ids = []
        for obj in objects:
            if not hasattr(obj, 'keys'):
                obj = {'id': obj}
            if untag:
                obj['untag'] = True
            object_ids.append(obj)

        params = {
            'name': name,
            collection_name: object_ids,
        }
        response = Intercom.post("/%s" % (collection), **params)
        return cls(**response)
Exemple #8
0
 def create(cls, **params):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(cls)
     response = Intercom.post("/%s/" % (collection), **params)
     if response:  # may be empty if we received a 202
         return cls(**response)