Giter Site home page Giter Site logo

python-intercom's Introduction

python-intercom

PyPI Version PyPI Downloads Travis CI Build Coverage Status

Not officially supported

Please note that this is NOT an official Intercom SDK. The third party that maintained it reached out to us to note that they were unable to host it any longer. As it was being used by some Intercom customers we offered to host it to allow the current Python community to continue to use it. However, it will not be maintained or updated by Intercom. It is a community maintained SDK. Please see here for the official list of Intercom SDKs

Python bindings for the Intercom API (https://developers.intercom.com/intercom-api-reference).

API Documentation.

Package Documentation.

Upgrading information

Version 3 of python-intercom is not backwards compatible with previous versions.

Version 3 moves away from a global setup approach to the use of an Intercom Client.

Installation

pip install python-intercom

Basic Usage

Configure your client

from intercom.client import Client
intercom = Client(personal_access_token='my_personal_access_token')

Note that certain resources will require an extended scope access token : Setting up Personal Access Tokens

Resources

Resources this API supports:

https://api.intercom.io/users
https://api.intercom.io/contacts
https://api.intercom.io/companies
https://api.intercom.io/counts
https://api.intercom.io/tags
https://api.intercom.io/notes
https://api.intercom.io/segments
https://api.intercom.io/events
https://api.intercom.io/conversations
https://api.intercom.io/messages
https://api.intercom.io/subscriptions
https://api.intercom.io/jobs
https://api.intercom.io/bulk

Examples

Users

# Find user by email
user = intercom.users.find(email="[email protected]")
# Find user by user_id
user = intercom.users.find(user_id="1")
# Find user by id
user = intercom.users.find(id="1")
# Create a user
user = intercom.users.create(email="[email protected]", name="Bob Smith")
# Delete a user
user = intercom.users.find(id="1")
deleted_user = intercom.users.delete(user)
# Update custom_attributes for a user
user.custom_attributes["average_monthly_spend"] = 1234.56
intercom.users.save(user)
# Perform incrementing
user.increment('karma')
intercom.users.save(user)
# Iterate over all users
for user in intercom.users.all():
    ...

Admins

# Iterate over all admins
for admin in intercom.admins.all():
    ...

Companies

# Add a user to one or more companies
user = intercom.users.find(email='[email protected]')
user.companies = [
    {'company_id': 6, 'name': 'Intercom'},
    {'company_id': 9, 'name': 'Test Company'}
]
intercom.users.save(user)
# You can also pass custom attributes within a company as you do this
user.companies = [
    {
        'id': 6,
        'name': 'Intercom',
        'custom_attributes': {
            'referral_source': 'Google'
        }
    }
]
intercom.users.save(user)
# Find a company by company_id
company = intercom.companies.find(company_id='44')
# Find a company by name
company = intercom.companies.find(name='Some company')
# Find a company by id
company = intercom.companies.find(id='41e66f0313708347cb0000d0')
# Update a company
company.name = 'Updated company name'
intercom.companies.save(company)
# Iterate over all companies
for company in intercom.companies.all():
    ...
# Get a list of users in a company
intercom.companies.users(company.id)

Tags

# Tag users
tag = intercom.tags.tag(name='blue', users=[{'email': '[email protected]'}])
# Untag users
intercom.tags.untag(name='blue', users=[{'user_id': '42ea2f1b93891f6a99000427'}])
# Iterate over all tags
for tag in intercom.tags.all():
    ...
# Tag companies
tag = intercom.tags.tag(name='blue', companies=[{'id': '42ea2f1b93891f6a99000427'}])

Segments

# Find a segment
segment = intercom.segments.find(id=segment_id)
# Iterate over all segments
for segment in intercom.segments.all():
    ...

Notes

# Find a note by id
note = intercom.notes.find(id=note)
# Create a note for a user
note = intercom.notes.create(
    body="<p>Text for the note</p>",
    email='[email protected]')
# Iterate over all notes for a user via their email address
for note in intercom.notes.find_all(email='[email protected]'):
    ...
# Iterate over all notes for a user via their user_id
for note in intercom.notes.find_all(user_id='123'):
    ...

Conversations

# FINDING CONVERSATIONS FOR AN ADMIN
# Iterate over all conversations (open and closed) assigned to an admin
for convo in intercom.conversations.find_all(type='admin', id='7'):
    ...
# Iterate over all open conversations assigned to an admin
for convo in intercom.conversations.find_all(type='admin', id=7, open=True):
    ...
# Iterate over closed conversations assigned to an admin
for convo intercom.conversations.find_all(type='admin', id=7, open=False):
    ...
# Iterate over closed conversations for assigned an admin, before a certain
# moment in time
for convo in intercom.conversations.find_all(
        type='admin', id= 7, open= False, before=1374844930):
    ...

# FINDING CONVERSATIONS FOR A USER
# Iterate over all conversations (read + unread, correct) with a user based on
# the users email
for convo in intercom.onversations.find_all(email='[email protected]',type='user'):
    ...
# Iterate over through all conversations (read + unread) with a user based on
# the users email
for convo in intercom.conversations.find_all(
        email='[email protected]', type='user', unread=False):
    ...
# Iterate over all unread conversations with a user based on the users email
for convo in intercom.conversations.find_all(
        email='[email protected]', type='user', unread=true):
    ...

# FINDING A SINGLE CONVERSATION
conversation = intercom.conversations.find(id='1')

# INTERACTING WITH THE PARTS OF A CONVERSATION
# Getting the subject of a part (only applies to email-based conversations)
conversation.rendered_message.subject
# Get the part_type of the first part
conversation.conversation_parts[0].part_type
# Get the body of the second part
conversation.conversation_parts[1].body

# REPLYING TO CONVERSATIONS
# User (identified by email) replies with a comment
intercom.conversations.reply(
    type='user', email='[email protected]',
    message_type='comment', body='foo')
# Admin (identified by email) replies with a comment
intercom.conversations.reply(
    type='admin', email='[email protected]',
    message_type='comment', body='bar')
# User (identified by email) replies with a comment and attachment
intercom.conversations.reply(id=conversation.id, type='user', email='[email protected]', message_type='comment', body='foo', attachment_urls=['http://www.example.com/attachment.jpg'])

# Open
intercom.conversations.open(id=conversation.id, admin_id='123')

# Close
intercom.conversations.close(id=conversation.id, admin_id='123')

# Assign
intercom.conversations.assign(id=conversation.id, admin_id='123', assignee_id='124')

# Reply and Open
intercom.conversations.reply(id=conversation.id, type='admin', admin_id='123', message_type='open', body='bar')

# Reply and Close
intercom.conversations.reply(id=conversation.id, type='admin', admin_id='123', message_type='close', body='bar')

# ASSIGNING CONVERSATIONS TO ADMINS
intercom.conversations.reply(id=conversation.id, type='admin', assignee_id=assignee_admin.id, admin_id=admin.id, message_type='assignment')

# MARKING A CONVERSATION AS READ
intercom.conversations.mark_read(conversation.id)

Full loading of an embedded entity

# Given a conversation with a partial user, load the full user. This can be
# done for any entity
intercom.users.load(conversation.user)

Sending messages

# InApp message from admin to user
intercom.messages.create(**{
    "message_type": "inapp",
    "body": "What's up :)",
    "from": {
        "type": "admin",
        "id": "1234"
    },
    "to": {
        "type": "user",
        "id": "5678"
    }
})

# Email message from admin to user
intercom.messages.create(**{
    "message_type": "email",
    "subject": "Hey there",
    "body": "What's up :)",
    "template": "plain", # or "personal",
    "from": {
        "type": "admin",
        "id": "1234"
    },
    "to": {
        "type": "user",
        "id": "536e564f316c83104c000020"
    }
})

# Message from a user
intercom.messages.create(**{
    "from": {
        "type": "user",
        "id": "536e564f316c83104c000020"
    },
    "body": "halp"
})

# Message from admin to contact
intercom.messages.create(**{
    'body': 'How can I help :)',
    'from': {
        'type': 'admin',
        'id': '1234'
    },
    'to': {
        'type': 'contact',
        'id': '536e5643as316c83104c400671'
    }
})

# Message from a contact
intercom.messages.create(**{
    'from' => {
        'type': 'contact',
        'id': '536e5643as316c83104c400671'
    },
    'body': 'halp'
})

Events

import time

intercom.events.create(
    event_name='invited-friend',
    created_at=int(time.mktime(time.localtime())),
    email=user.email,
    metadata={
        'invitee_email': '[email protected]',
        'invite_code': 'ADDAFRIEND',
        'found_date': 12909364407
    }
)

# Retrieve event list for user with id:'123abc'
intercom.events.find_all(type='user', "intercom_user_id"="123abc)

Metadata Objects support a few simple types that Intercom can present on your behalf

current_user = intercom.users.find(id="1")

intercom.events.create(
    event_name="placed-order",
    email=current_user.email,
    created_at=1403001013,
    metadata={
        'order_date': time.mktime(time.localtime()),
        'stripe_invoice': 'inv_3434343434',
        'order_number': {
            'value': '3434-3434',
            'url': 'https://example.org/orders/3434-3434'
        },
        'price': {
            'currency': 'usd',
            'amount': 2999
        }
    }
)

The metadata key values in the example are treated as follows-

  • order_date: a Date (key ends with '_date').
  • stripe_invoice: The identifier of the Stripe invoice (has a 'stripe_invoice' key)
  • order_number: a Rich Link (value contains 'url' and 'value' keys)
  • price: An Amount in US Dollars (value contains 'amount' and 'currency' keys)

Contacts

Contacts represent logged out users of your application.

# Create a contact
contact = intercom.leads.create(email="[email protected]")

# Update a contact
contact.custom_attributes['foo'] = 'bar'
intercom.leads.save(contact)

# Find contacts by email
contacts = intercom.leads.find_all(email="[email protected]")

# Merge a contact into a user
user = intercom.users.find(id="1")
intercom.leads.convert(contact, user)

# Delete a contact
intercom.leads.delete(contact)

Counts

# App-wide counts
intercom.counts.for_app()

# Users in segment counts
intercom.counts.for_type(type='user', count='segment')

Subscriptions

Subscribe to events in Intercom to receive webhooks.

# create a subscription
intercom.subscriptions.create(url='http://example.com', topics=['user.created'])

# fetch a subscription
intercom.subscriptions.find(id='nsub_123456789')

# list subscriptions
intercom.subscriptions.all():
    ...

Errors

You do not need to deal with the HTTP response from an API call directly. If there is an unsuccessful response then an error that is a subclass of intercom.Error will be raised. If desired, you can get at the http_code of an Error via it's http_code method.

The list of different error subclasses are listed below. As they all inherit off IntercomError you can choose to except IntercomError or the more specific error subclass:

AuthenticationError
ServerError
ServiceUnavailableError
ServiceConnectionError
ResourceNotFound
BadGatewayError
BadRequestError
RateLimitExceeded
MultipleMatchingUsersError
HttpError
UnexpectedError

Rate Limiting

Calling your clients rate_limit_details returns a dict that contains details about your app's current rate limit.

intercom.rate_limit_details
# {'limit': 180, 'remaining': 179, 'reset_at': datetime.datetime(2014, 10, 07, 14, 58)}

Running the Tests

Unit tests:

nosetests tests/unit

Integration tests:

INTERCOM_PERSONAL_ACCESS_TOKEN=xxx nosetests tests/integration

python-intercom's People

Contributors

apassant avatar asavoy avatar benjaminlo avatar bobjflong avatar cameronmaske avatar choran avatar dannyfallon avatar dmitry-mukhin avatar enrico-intercom avatar frankie567 avatar jkeyes avatar marselester avatar michael-k avatar nicpottier avatar oscarlsson avatar patrickod avatar piotrkilczuk avatar seanhealy33 avatar shevron avatar svisser avatar tanasegabriel avatar tilka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-intercom's Issues

Intercom may return 'None' for custom attributes

First of all, the new version 2.0 looks already really awesome and easy to use!

There is only one minor problem that I'm running into, which is:

c = Company(id=network.id)
c.custom_attributes.update(enabled_features='')
c.save()

Intercom will respond to this query with the new network data, but it has set enabled_features to None, which raises this exception:

Traceback (most recent call last):
  File "test.py", line 36, in <module>
    c.save()
  File "intercom/api_operations/save.py", line 51, in save
    return self.from_response(response)
  File "intercom/traits/api_resource.py", line 60, in from_response
    self.from_dict(response)
  File "intercom/traits/api_resource.py", line 67, in from_dict
    setattr(self, attribute, value)
  File "intercom/traits/api_resource.py", line 94, in __setattr__
    value_to_set = FlatStore(value)
  File "intercom/lib/flat_store.py", line 10, in __init__
    self.update(*args, **kwargs)
  File "intercom/lib/flat_store.py", line 30, in update
    self[key] = other[key]
  File "intercom/lib/flat_store.py", line 18, in __setitem__
    "custom data only allows string and real number values")
ValueError: custom data only allows string and real number values

test_72 breaks pip install in Python 3

Running setup.py install for python-intercom

  File ".venv/lib/python3.3/site-packages/tests/integration/issues/test_72.py", line 24
    print data
             ^
SyntaxError: invalid syntax

Pass page in User.all

Right now you can only get 500 users and there is no way to pass the page or per_page attribute

Documentation

Update the documentation to reflect the latest code.

Installer fails while looking for README

Hi there, after cloning the latest master and trying to do an install I get:

[shopventory@devel python-intercom (master)]$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 22, in
long_description=open('README').read(),
IOError: [Errno 2] No such file or directory: 'README'

Renaming the file or updating the code to look for README.rst fixes it.

NoneType returned on user email change

Hi @jkeyes thanks for the beta release!

Interesting edge-case but if I do this
user = User.create(email="[email protected]", user_id=1) print type(user)

I get <class 'intercom.user.User'> as expected.

However, if my user decides to ever change their email address for their account:
user = User.create(email="[email protected]", user_id=1) print type(user)

I get a <type 'NoneType'> response and can't continue to add custom_attributes etc or .save etc. On Intercom, i see that [email protected] either no longer exists and/or is overwritten as expected with [email protected] which is correct (all activity still remains so I am guessing the user object hasn't been changed).

Some attributes not being saved for resources

I created a User like so:

    user = User(
        email="[email protected]", user_id="i-1224242",
        companies=[{'company_id': 6, 'name': 'Intercom'}])

and then called user.save(). The value for companies was not being sent in the request. If I created it as follows:

    user = User.create(
        email="[email protected]", user_id="i-1224242",
        companies=[{'company_id': 6, 'name': 'Intercom'}])

then it behaved as expected.

Support `self` document fields.

Intercom's docs state the following:

All objects in the API have an id field indicating their logical identifier. Some objects may optionally also have a self field that indicates a URL or canonical address for the object.

self A URL that addresses the object within the API. The self field will not be larger than 255 characters (in SQL it corresponds to a varchar(255)).

Both fields id and self hold special significance in Python.

The current version of python-intercom allows fields called id e.g. user.id. I could add similar support for self e.g. user.self but it feels wrong.

What are the alternatives?

  • rename to _id and _self โ€“ this doesn't sit well either as they are not intended to be private
  • remove __getattribute__ and __setattr__ support and just use __getitem__ i.e. instead of user.id we use user['id'] and user['self']. This is clean but will break whatever code is out there using .id.

Create a distribution

Update setup.py (and associated files) to create a source distribution to upload to pypi.

Exception in error handling

Traceback (most recent call last): 
  File "/Users/zacwitte/Documents/workspace/handup/models/donor.py", line 279, in set_mixpanel
    icom_user = IntercomUser.create(**d)
  File "/usr/local/lib/python2.7/site-packages/intercom/api_operations/save.py", line 12, in create
    response = Intercom.post("/%s/" % (collection), **params)
  File "/usr/local/lib/python2.7/site-packages/intercom/__init__.py", line 171, in post
    return cls.request('POST', path, params)
  File "/usr/local/lib/python2.7/site-packages/intercom/__init__.py", line 163, in request
    method, cls.get_url(path), cls._auth, params)
  File "/usr/local/lib/python2.7/site-packages/intercom/request.py", line 40, in send_request_to_path
    return cls.parse_body(resp)
  File "/usr/local/lib/python2.7/site-packages/intercom/request.py", line 50, in parse_body
    cls.raise_application_errors_on_failure(body, resp.status_code)
  File "/usr/local/lib/python2.7/site-packages/intercom/request.py", line 102, in raise_application_errors_on_failure
    error_details, http_code)
  File "/usr/local/lib/python2.7/site-packages/intercom/request.py", line 113, in message_for_unexpected_error_with_type
    error_type = error_details['type']
KeyError: 'type'

no valid example provided

might be an idea to provide a complete working example?

I'm sure it should be obvious, but I'm trying this:

import intercom
intercom.Intercom.app_id = "MYAPPID"
intercom.Intercom.app_api_key = "MYAPPKEY"
intercom.User.find(email="MYEMAIL")
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/intercom/user.py", line 69, in find
resp = Intercom.get_user(user_id=user_id, email=email)
File "/Library/Python/2.7/site-packages/intercom/intercom.py", line 173, in get_user
'GET', Intercom.api_endpoint + 'users', params=params)
File "/Library/Python/2.7/site-packages/intercom/intercom.py", line 66, in wrapper
raise_errors_on_failure(response)
File "/Library/Python/2.7/site-packages/intercom/intercom.py", line 78, in raise_errors_on_failure
raise AuthenticationError("Invalid API key/username provided.")
intercom.intercom.AuthenticationError: Invalid API key/username provided.

Support for all=true

Hey, love the package. Anyways, recently I had need to fetch correspondence for a user as well as auto emails sent to them and the MessageThread.find_all method was getting me all the manual messages sent, but not the auto emails. So I ended up contacting Intercom and they mentioned that they have an (undocumented) param

all=true

that can be sent for a list of all correspondence, including emails, with the user..any way to get that into the next release?

Edit: the request isn't actually working for me right now, if its starts working ill update this ticket.

UnboundLocalError: local variable 'body' referenced before assignment

Getting the below error when trying:

from intercom import User as User
from intercom import Intercom

Intercom.app_id = 'xxx'
Intercom.app_api_key = 'xxx'

user = User.create(email='[email protected]')

Error:

~/.../app/lib/python2.7/site-packages/intercom/request.pyc in parse_body(cls, resp)
     46         except ValueError:
     47             cls.raise_errors_on_failure(resp)
---> 48         if body.get('type') == 'error.list':
     49             cls.raise_application_errors_on_failure(body, resp.status_code)
     50         return body

UnboundLocalError: local variable 'body' referenced before assignment

Error on install (apiv2)

Getting the following error on:
python setup.py install
and
pip install git+https://github.com/jkeyes/python-intercom.git@apiv2

Traceback (most recent call last): File "setup.py", line 13, in <module> with file(os.path.join('intercom', 'intercom.py')) as init: IOError: [Errno 2] No such file or directory: 'intercom/intercom.py'

Python 3

I attempted to install this with pip in Python 3.4.0 and got this error:

Running setup.py (path:/tmp/pip_build_root/python-intercom/setup.py) egg_info for package python-intercom
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/python-intercom/setup.py", line 13, in
with file(os.path.join('intercom', 'intercom.py')) as init:
NameError: name 'file' is not defined
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/python-intercom/setup.py", line 13, in
with file(os.path.join('intercom', 'intercom.py')) as init:
NameError: name 'file' is not defined

It looks like "file" is no longer a built-in. Any plans to support Python 3?

Can not inherit from resource classes

The current design deduces the API endpoints from the class name. If you want to inherit from a Resource class to give it more functionality, this screws up the API endpoint "computation". I think it would be nicer to specify the endpoint name directly as an attribute of the class instead of deriving it. In the spirit of The Zen of Python:

Explicit is better than implicit.

and

In the face of ambiguity, refuse the temptation to guess.

Have you thought about this? What do you think?

Getting ValueError while iterating over users with User.all()

While attempting to iterate over users with User.all() I'm getting a ValueError.

Even something as simple as this fails:

for user in User.all():
    print(user)

Full Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/six.py", line 535, in next
    return type(self).__next__(self)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/collection_proxy.py", line 45, in __next__
    instance = self.collection_cls(**resource)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/traits/api_resource.py", line 41, in __init__
    _self.from_dict(params)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/traits/api_resource.py", line 67, in from_dict
    setattr(self, attribute, value)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/traits/api_resource.py", line 94, in __setattr__
    value_to_set = FlatStore(value)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/lib/flat_store.py", line 10, in __init__
    self.update(*args, **kwargs)
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/lib/flat_store.py", line 30, in update
    self[key] = other[key]
  File "/Users/jonathanwilliamson/Documents/Web/cgcookie/cgc-customer/venv/lib/python2.7/site-packages/intercom/lib/flat_store.py", line 18, in __setitem__
    "custom data only allows string and real number values")
ValueError: custom data only allows string and real number values

Note: iterating over companies in the same fashion works just fine. I'm using version 2.0beta of python-intercom as that's the latest one that seems to be available on PyPi.

High level support for `Company`

Intercom supports high level API to query company. Docs are available at http://doc.intercom.io/api/#companies.

Here is a python example for it, http://doc.intercom.io/api/#view-a-company.

In [43]: intercom.Intercom._call('GET', intercom.Intercom.api_endpoint + 'companies', params={'id': 1})
Out[43]:
{u'created_at': 1410530757,
 u'custom_data': {},
 u'id': u'1',
 u'monthly_spend': 18,
 u'name': u'\u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u06296',
 u'plan': u'4'}

Add a new Company class which can perform various operation. If ok, I can send pull request.

Delete a user

I can't seem to find a way to delete a user. If it is not possible, it would be useful to add that feature.

create_user missing last_request_at

The intercom.io API supports passing in a last_request_at parameter at user creation (or update) time. This is missing from the python client, which means you need to separately call Intercom.create_impression to correctly register a LAST_SEEN attribute.

It would be very useful to have this parameter supported in the python interface.

Support for companies.

I see the ruby lib has added support for user companies, well then so should we ๐Ÿ‘

support latest Intercom API

Hi there,

This doesn't seem to support the latest Intercom API, and instead uses the v1 API. Are there any plans to support the latest API?

http://doc.intercom.io/api/#intercom-api

Some documentation links from the old API docs do not work anymore, and new features are only available with the new API.

Thanks for writing these Python bindings!

ResourceNotFound error

Hi John,

thanks for putting together this library for our use.
Do you know what this error means? I try the same call from my console, and I don't get any error - so I'm not sure what's causing this.

File "/src/index.py", line 399, in send_event_to_intercom
impression = Event.create(event_name=event, user_id=customer_id, metadata=properties)
File "intercom/events.py", line 17, in create
resp = Intercom.create_event(event_name=event_name, user_id=user_id, email=email, metadata=metadata)
File "intercom/intercom.py", line 463, in create_event
'POST', Intercom.api_endpoint + 'events', params=params)
File "intercom/intercom.py", line 66, in wrapper
raise_errors_on_failure(response)
File "intercom/intercom.py", line 76, in raise_errors_on_failure
raise ResourceNotFound("Not found.")

Use mock.assert_called_once_with for unit tests

The current unit tests don't really test anything. I'm going to change it from HTTPretty tests to mock.assert_called_once_with tests. This is similar to the unit tests in intercom-ruby.

Track changed fields

Track the fields that have been changed on a Resource and only send those when save is called.

User missing attribute "unsubscribed_from_emails"

The user object is missing an attribute "unsubscribed_from_emails", which is part of the standard intercom api. Because of this, setting this attribute on the user, followed by calling user.save() does not update the flag on Intercom.

The following code should work:

user = User.find(email='[email protected]')
user['unsubscribed_from_emails'] = True
user.save()

However, since the unsubscribed_from_emails is not in the attribute list, it does not get sent as a part of the data.

Session count not incrementing

I am unable to increment the session count for a user. I have tried the following:

This one just doesn't do anything:

user.increment("sessions")

This creates a new attribute in Intercom called "session_count":

user.increment("session_count")

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.