Skip to content

Commit e5531f4

Browse files
committed
Merge pull request #1 from ronyperez/patch-1
Update user.py
2 parents 69c8989 + 1a6335c commit e5531f4

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

intercom/user.py

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ class User(UserId):
4646
""" Object representing http://docs.intercom.io/#UserData). """
4747

4848
attributes = (
49-
'user_id', 'email', 'name', 'created_at', 'custom_data',
50-
'last_seen_ip', 'last_seen_user_agent', 'companies',
51-
'last_impression_at', 'last_request_at', 'unsubscribed_from_emails')
49+
'user_id', 'email', 'name', 'signed_up_at', 'custom_attributes',
50+
'last_seen_ip', 'user_agent_data', 'companies', 'last_request_at', 'update_last_request_at', 'last_seen_user_agent', 'unsubscribed_from_emails')
5251

5352
@classmethod
5453
def find(cls, user_id=None, email=None):
@@ -195,6 +194,16 @@ def last_seen_user_agent(self, last_seen_user_agent):
195194
""" Sets the last seen User Agent. """
196195
self['last_seen_user_agent'] = last_seen_user_agent
197196

197+
@property
198+
def update_last_request_at(self):
199+
""" Returns the last seen User Agent. """
200+
return dict.get(self, 'update_last_request_at', None)
201+
202+
@update_last_request_at.setter
203+
def update_last_request_at(self, update_last_request_at):
204+
""" Sets the last seen User Agent. """
205+
self['update_last_request_at'] = update_last_request_at
206+
198207
@property
199208
@from_timestamp_property
200209
def last_request_at(self):
@@ -353,8 +362,8 @@ def companies(self, companies):
353362
raise ValueError("companies must be set as a list")
354363

355364
@property
356-
def custom_data(self):
357-
""" Returns a CustomData object for this User.
365+
def custom_attributes(self):
366+
""" Returns a CustomAttributes object for this User.
358367
359368
>>> users = User.all()
360369
>>> custom_data = users[0].custom_data
@@ -364,15 +373,15 @@ def custom_data(self):
364373
155.5
365374
366375
"""
367-
data = dict.get(self, 'custom_data', None)
368-
if not isinstance(data, CustomData):
369-
data = CustomData(data)
370-
dict.__setitem__(self, 'custom_data', data)
376+
data = dict.get(self, 'custom_attributes', None)
377+
if not isinstance(data, CustomAttributes):
378+
data = CustomAttributes(data)
379+
dict.__setitem__(self, 'custom_attributes', data)
371380
return data
372381

373-
@custom_data.setter
374-
def custom_data(self, custom_data):
375-
""" Sets the CustomData for this User.
382+
@custom_attributes.setter
383+
def custom_attributes(self, custom_attributes):
384+
""" Sets the CustomAttributes for this User.
376385
377386
>>> user = User(email="somebody@example.com")
378387
>>> user.custom_data = { 'max_monthly_spend': 200 }
@@ -383,17 +392,17 @@ def custom_data(self, custom_data):
383392
3
384393
385394
"""
386-
if not isinstance(custom_data, CustomData):
387-
custom_data = CustomData(custom_data)
388-
self['custom_data'] = custom_data
395+
if not isinstance(custom_attributes, CustomAttributes):
396+
custom_attributes = CustomAttributes(custom_attributes)
397+
self['custom_attributes'] = custom_attributes
389398

390399

391-
class CustomData(dict):
400+
class CustomAttributes(dict):
392401
""" A dict that limits keys to strings, and values to real numbers
393402
and strings.
394403
395-
>>> from intercom.user import CustomData
396-
>>> data = CustomData()
404+
>>> from intercom.user import CustomAttributes
405+
>>> data = CustomAttributes()
397406
>>> data['a_dict'] = {}
398407
Traceback (most recent call last):
399408
...
@@ -412,10 +421,10 @@ def __setitem__(self, key, value):
412421
isinstance(value, basestring)
413422
):
414423
raise ValueError(
415-
"custom data only allows string and real number values")
424+
"custom attributes only allows string and real number values")
416425
if not isinstance(key, basestring):
417-
raise ValueError("custom data only allows string keys")
418-
super(CustomData, self).__setitem__(key, value)
426+
raise ValueError("custom attributes only allows string keys")
427+
super(CustomAttributes, self).__setitem__(key, value)
419428

420429

421430
class SocialProfile(dict):

0 commit comments

Comments
 (0)