forked from intercom/python-intercom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload.py
More file actions
22 lines (16 loc) · 612 Bytes
/
Copy pathload.py
File metadata and controls
22 lines (16 loc) · 612 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
from intercom import HttpError
from intercom import utils
class Load(object):
def load(self):
from intercom import Intercom
cls = self.__class__
collection = utils.resource_class_to_collection_name(cls)
if hasattr(self, 'id'):
response = Intercom.get("/%s/%s" % (collection, self.id))
else:
raise Exception(
"Cannot load %s as it does not have a valid id." % (cls))
if response is None:
raise HttpError('Http Error - No response entity returned')
return cls(**response)