Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes and additions #195

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion intercom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
16 changes: 14 additions & 2 deletions intercom/service/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
3 changes: 2 additions & 1 deletion intercom/service/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down