Skip to content

Commit 93ec880

Browse files
committed
PEP8 formatting.
1 parent f2f8af0 commit 93ec880

File tree

4 files changed

+65
-35
lines changed

4 files changed

+65
-35
lines changed

intercom/intercom.py

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class ResourceNotFound(IntercomError):
4141

4242

4343
class ServerError(IntercomError):
44-
""" Raised when the API returns an error other than an auth or not found. """
44+
""" Raised when the API returns an error other than an auth or not found.
45+
"""
4546
pass
4647

4748

@@ -81,7 +82,8 @@ class Intercom(object):
8182
@classmethod
8283
@api_call
8384
def _call(cls, method, url, params=None):
84-
""" Construct an API request, send it to the API, and parse the response. """
85+
""" Construct an API request, send it to the API, and parse the
86+
response. """
8587

8688
req_params = {}
8789
headers = {
@@ -109,7 +111,8 @@ def _create_or_update_user(cls, method, **kwargs):
109111

110112
@classmethod
111113
def get_users(cls):
112-
""" Return a dict for the user represented by the specified email or user_id.
114+
""" Return a dict for the user represented by the specified email
115+
or user_id.
113116
114117
>>> result = Intercom.get_users()
115118
>>> type(result)
@@ -118,12 +121,13 @@ def get_users(cls):
118121
3
119122
120123
"""
121-
user_dict = Intercom._call('GET', '%susers' % (Intercom.api_endpoint))
124+
user_dict = Intercom._call('GET', Intercom.api_endpoint + 'users')
122125
return user_dict
123126

124127
@classmethod
125128
def get_user(cls, email=None, user_id=None):
126-
""" Return a dict for the user represented by the specified email or user_id.
129+
""" Return a dict for the user represented by the specified email
130+
or user_id.
127131
128132
>>> user = Intercom.get_user(user_id='123')
129133
>>> user['name']
@@ -132,7 +136,8 @@ def get_user(cls, email=None, user_id=None):
132136
"""
133137

134138
params = {'email': email, 'user_id': user_id}
135-
user_dict = Intercom._call('GET', '%susers' % (Intercom.api_endpoint), params=params)
139+
user_dict = Intercom._call(
140+
'GET', Intercom.api_endpoint + 'users', params=params)
136141
return user_dict
137142

138143
@classmethod
@@ -154,9 +159,10 @@ def create_user(
154159
155160
"""
156161
return Intercom._create_or_update_user(
157-
'POST', user_id=user_id, email=email,
158-
name=name, created_at=created_at, custom_data=custom_data,
159-
last_seen_ip=last_seen_ip, last_seen_user_agent=last_seen_user_agent)
162+
'POST', user_id=user_id, email=email, name=name,
163+
created_at=created_at, custom_data=custom_data,
164+
last_seen_ip=last_seen_ip,
165+
last_seen_user_agent=last_seen_user_agent)
160166

161167
@classmethod
162168
def update_user(
@@ -173,9 +179,10 @@ def update_user(
173179
174180
"""
175181
return Intercom._create_or_update_user(
176-
'PUT', user_id=user_id, email=email,
177-
name=name, created_at=created_at, custom_data=custom_data,
178-
last_seen_ip=last_seen_ip, last_seen_user_agent=last_seen_user_agent)
182+
'PUT', user_id=user_id, email=email, name=name,
183+
created_at=created_at, custom_data=custom_data,
184+
last_seen_ip=last_seen_ip,
185+
last_seen_user_agent=last_seen_user_agent)
179186

180187
@classmethod
181188
def delete_user(cls, user_id=None, email=None):
@@ -190,7 +197,8 @@ def delete_user(cls, user_id=None, email=None):
190197
'email': email,
191198
'user_id': user_id
192199
}
193-
user_dict = Intercom._call('DELETE', Intercom.api_endpoint + 'users', params)
200+
user_dict = Intercom._call(
201+
'DELETE', Intercom.api_endpoint + 'users', params)
194202
return user_dict
195203

196204
@classmethod
@@ -243,11 +251,12 @@ def get_message_threads(cls, user_id=None, email=None, thread_id=None):
243251
(if it can find one), otherwise it returns all MessageThreads for the
244252
particular user.
245253
246-
>>> message_threads = Intercom.get_message_threads(email="somebody@example.com")
254+
>>> message_threads = Intercom.get_message_threads(
255+
... email="somebody@example.com")
247256
>>> type(message_threads)
248257
<type 'list'>
249-
>>> message_thread = Intercom.get_message_threads(email="somebody@example.com",
250-
... thread_id=5591)
258+
>>> message_thread = Intercom.get_message_threads(
259+
... email="somebody@example.com", thread_id=5591)
251260
>>> type(message_thread)
252261
<type 'dict'>
253262
@@ -258,14 +267,16 @@ def get_message_threads(cls, user_id=None, email=None, thread_id=None):
258267
'thread_id': thread_id
259268
}
260269
msg_dict = Intercom._call(
261-
'GET', Intercom.api_endpoint + 'users/message_threads', params=params)
270+
'GET', Intercom.api_endpoint + 'users/message_threads',
271+
params=params)
262272
return msg_dict
263273

264274
@classmethod
265275
def create_message_thread(cls, user_id=None, email=None, body=None):
266276
""" Create a MessageThread.
267277
268-
>>> message_thread = Intercom.create_message_thread(email="somebody@example.com",
278+
>>> message_thread = Intercom.create_message_thread(
279+
... email="somebody@example.com",
269280
... body="Uh, everything's under control. Situation normal.")
270281
>>> message_thread['thread_id']
271282
5591
@@ -281,16 +292,20 @@ def create_message_thread(cls, user_id=None, email=None, body=None):
281292
'body': body
282293
}
283294
user_dict = Intercom._call(
284-
'POST', Intercom.api_endpoint + 'users/message_threads', params=params)
295+
'POST', Intercom.api_endpoint + 'users/message_threads',
296+
params=params)
285297
return user_dict
286298

287299
@classmethod
288300
def reply_message_thread(
289-
cls, user_id=None, email=None, thread_id=None, body=None, read=None):
301+
cls, user_id=None, email=None, thread_id=None, body=None,
302+
read=None):
290303
""" Reply to the specific thread.
291304
292-
>>> message_thread = Intercom.reply_message_thread(email="somebody@example.com",
293-
... thread_id=5591, body="If you're not talking to me you must be talking to someone")
305+
>>> message_thread = Intercom.reply_message_thread(
306+
... email="somebody@example.com",
307+
... thread_id=5591,
308+
... body="If you're not talking to me you must be talking to someone")
294309
>>> len(message_thread)
295310
7
296311
>>> message_thread['thread_id']
@@ -307,5 +322,6 @@ def reply_message_thread(
307322
'read': read
308323
}
309324
user_dict = Intercom._call(
310-
'PUT', Intercom.api_endpoint + 'users/message_threads', params=params)
325+
'PUT', Intercom.api_endpoint + 'users/message_threads',
326+
params=params)
311327
return user_dict

intercom/message_thread.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def find(cls, user_id=None, email=None, thread_id=None):
2828
Traceback (most recent call last):
2929
...
3030
ValueError: No thread_id specified
31-
>>> message_thread = MessageThread.find(email="somebody@example.com", thread_id=5591)
31+
>>> message_thread = MessageThread.find(email="somebody@example.com",
32+
... thread_id=5591)
3233
>>> len(message_thread.messages)
3334
3
3435
>>> message = message_thread.messages[0]
@@ -46,7 +47,8 @@ def find(cls, user_id=None, email=None, thread_id=None):
4647
def find_all(cls, user_id=None, email=None):
4748
""" Finds all Messages for a particular user.
4849
49-
>>> message_threads = MessageThread.find_all(email="somebody@example.com")
50+
>>> message_threads = MessageThread.find_all(
51+
... email="somebody@example.com")
5052
>>> len(message_threads)
5153
1
5254
@@ -73,13 +75,15 @@ def create(cls, user_id=None, email=None, body=None):
7375

7476
@classmethod
7577
def reply(
76-
cls, user_id=None, email=None, thread_id=None, body=None, read=None):
78+
cls, user_id=None, email=None, thread_id=None, body=None,
79+
read=None):
7780
""" Reply to an existing conversation.
7881
7982
>>> email = "somebody@example.com"
8083
>>> thread_id = 5591
8184
>>> body = "Are you talking to me?"
82-
>>> message_thread = MessageThread.reply(email=email, thread_id=thread_id, body=body)
85+
>>> message_thread = MessageThread.reply(email=email,
86+
... thread_id=thread_id, body=body)
8387
>>> len(message_thread.messages)
8488
2
8589
>>> message_thread.messages[0].html
@@ -141,7 +145,8 @@ def messages(self):
141145
class Message(dict):
142146
""" Object representing a Message in a MessageThread.
143147
144-
>>> message_thread = MessageThread.find(email="somebody@example.com", thread_id=5591)
148+
>>> message_thread = MessageThread.find(email="somebody@example.com",
149+
... thread_id=5591)
145150
>>> message = message_thread.messages[0]
146151
>>> type(message.author)
147152
<class 'intercom.message_thread.MessageAuthor'>
@@ -174,7 +179,8 @@ def created_at(self):
174179
class MessageAuthor(dict):
175180
""" Object represting the author of a Message.
176181
177-
>>> message_thread = MessageThread.find(email="somebody@example.com", thread_id=5591)
182+
>>> message_thread = MessageThread.find(email="somebody@example.com",
183+
... thread_id=5591)
178184
>>> author = message_thread.messages[0].author
179185
>>> author.admin
180186
False

intercom/note.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def save(self):
4747
u'<p>This is the text of my note.</p>'
4848
4949
"""
50-
resp = Intercom.create_note(user_id=self.user_id, email=self.email, body=self.body)
50+
resp = Intercom.create_note(
51+
user_id=self.user_id, email=self.email, body=self.body)
5152
self.update(resp)
5253

5354
@property
@@ -68,7 +69,8 @@ def html(self):
6869
@property
6970
@from_timestamp_property
7071
def created_at(self):
71-
""" Returns the datetime this note was created – set by an API response. """
72+
""" Returns the datetime this note was created – set by an
73+
API response. """
7274
return dict.get(self, 'created_at', None)
7375

7476
@property

intercom/user.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ def relationship_score(self):
199199

200200
@property
201201
def session_count(self):
202-
""" Returns how many sessions this User has used on your application. """
202+
""" Returns how many sessions this User has used on your
203+
application. """
203204
return dict.get(self, 'session_count', None)
204205

205206
@property
@@ -217,7 +218,8 @@ def created_at(self):
217218
@created_at.setter
218219
@to_timestamp_property
219220
def created_at(self, value):
220-
""" Sets the timestamp when this User started using your application. """
221+
""" Sets the timestamp when this User started using your
222+
application. """
221223
self['created_at'] = value
222224

223225
@property
@@ -319,8 +321,12 @@ class CustomData(dict):
319321

320322
def __setitem__(self, key, value):
321323
""" Limits the keys and values. """
322-
if not (isinstance(value, numbers.Real) or isinstance(value, basestring)):
323-
raise ValueError("custom data only allows string and real number values")
324+
if not (
325+
isinstance(value, numbers.Real) or
326+
isinstance(value, basestring)
327+
):
328+
raise ValueError(
329+
"custom data only allows string and real number values")
324330
if not isinstance(key, basestring):
325331
raise ValueError("custom data only allows string keys")
326332
super(CustomData, self).__setitem__(key, value)

0 commit comments

Comments
 (0)