Skip to content

Commit 3cb7a17

Browse files
committed
Adding support for self fields. (intercom#33)
1 parent 859d517 commit 3cb7a17

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

intercom/traits/api_resource.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ def to_datetime_value(value):
3232

3333
class Resource(object):
3434

35-
def __init__(self, **params):
36-
self.from_dict(params)
35+
def __init__(_self, **params):
36+
_self.from_dict(params)
37+
self = _self
3738

38-
if hasattr(self, 'flat_store_attributes'):
39+
if hasattr(_self, 'flat_store_attributes'):
3940
for attr in self.flat_store_attributes:
4041
if not hasattr(self, attr):
4142
setattr(self, attr, FlatStore())

tests/unit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def page_of_users(include_next_link=False):
250250
"service_type": "web",
251251
"app_id": "3qmk5gyg",
252252
"url": "http://example.com",
253-
"_self": "https://api.intercom.io/subscriptions/nsub_123456789",
253+
"self": "https://api.intercom.io/subscriptions/nsub_123456789",
254254
"topics": ["user.created", "conversation.user.replied", "conversation.admin.replied"],
255255
"active": True,
256256
"metadata": {},

tests/unit/subscription_spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def it_gets_a_subscription(self):
2626
subscription = Subscription.find(id="nsub_123456789")
2727
expect(subscription.topics[0]) == "user.created"
2828
expect(subscription.topics[1]) == "conversation.user.replied"
29+
expect(subscription.self) == \
30+
"https://api.intercom.io/subscriptions/nsub_123456789"
2931

3032
@httpretty.activate
3133
def it_creates_a_subscription(self):

0 commit comments

Comments
 (0)