diff --git a/intercom/__init__.py b/intercom/__init__.py index 23824dc6..bbf6ce62 100644 --- a/intercom/__init__.py +++ b/intercom/__init__.py @@ -6,7 +6,7 @@ MultipleMatchingUsersError, RateLimitExceeded, ResourceNotFound, ServerError, ServiceUnavailableError, UnexpectedError, TokenUnauthorizedError) -__version__ = '3.1.0' +__version__ = '3.1.1' RELATED_DOCS_TEXT = "See https://github.com/jkeyes/python-intercom \ diff --git a/intercom/service/conversation.py b/intercom/service/conversation.py index 61f143a7..6cb06595 100644 --- a/intercom/service/conversation.py +++ b/intercom/service/conversation.py @@ -25,7 +25,7 @@ def collection_class(self): def resource_url(self, _id): """Return the URL for the specified resource in this collection.""" - return "/%s/%s/reply" % (self.collection, _id) + return "/%s/%s" % (self.collection, _id) def reply(self, **reply_data): """Reply to a message.""" @@ -55,9 +55,21 @@ def mark_read(self, _id): response = self.client.put(self.resource_url(_id), data) return self.collection_class().from_response(response) + def add_user(self, _id, user_id, admin_id): + """Add user to conversation""" + data = {"admin_id": admin_id, "customer": {"intercom_user_id": user_id}} + response = self.client.post(self.resource_url(_id) + "/customers", data) + self.collection_class().from_response(response) + + def remove_user(self, _id, user_id, admin_id): + """Remove user from a conversation""" + data = {"admin_id": admin_id} + response = self.client.delete(self.resource_url(_id) + "/customers/%s" % user_id, data) + self.collection_class().from_response(response) + def __reply(self, reply_data): """Send requests to the resource handler.""" _id = reply_data.pop('id') reply_data['conversation_id'] = _id - response = self.client.post(self.resource_url(_id), reply_data) + response = self.client.post(self.resource_url(_id) + "/reply", reply_data) return self.collection_class().from_response(response) diff --git a/intercom/service/tag.py b/intercom/service/tag.py index 1bf1a5ea..d5aea216 100644 --- a/intercom/service/tag.py +++ b/intercom/service/tag.py @@ -5,10 +5,11 @@ from intercom.api_operations.find import Find from intercom.api_operations.find_all import FindAll from intercom.api_operations.save import Save +from intercom.api_operations.delete import Delete from intercom.service.base_service import BaseService -class Tag(BaseService, All, Find, FindAll, Save): +class Tag(BaseService, All, Find, FindAll, Save, Delete): @property def collection_class(self): diff --git a/setup.py b/setup.py index 3b5bcde8..94b495c6 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ long_description = readme.read() setup( - name="python-intercom", + name="singular-python-intercom", version=__version__, description="Intercom API wrapper", long_description=long_description,