Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 9f7ed0d

Browse files
committed
Merge pull request #43 from BetterWorks/send-in-body
POST api payloads in the request body, not URL.
2 parents 8abb933 + 6684d2b commit 9f7ed0d

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

slacker/__init__.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_presence(self, user):
9797

9898
def set_presence(self, presence):
9999
assert presence in Presence.TYPES, 'Invalid presence type'
100-
return self.post('users.setPresence', params={'presence': presence})
100+
return self.post('users.setPresence', data={'presence': presence})
101101

102102
def get_user_id(self, user_name):
103103
members = self.list().body['members']
@@ -106,10 +106,10 @@ def get_user_id(self, user_name):
106106

107107
class Groups(BaseAPI):
108108
def create(self, name):
109-
return self.post('groups.create', params={'name': name})
109+
return self.post('groups.create', data={'name': name})
110110

111111
def create_child(self, channel):
112-
return self.post('groups.createChild', params={'channel': channel})
112+
return self.post('groups.createChild', data={'channel': channel})
113113

114114
def info(self, channel):
115115
return self.get('groups.info', params={'channel': channel})
@@ -131,46 +131,46 @@ def history(self, channel, latest=None, oldest=None, count=None,
131131

132132
def invite(self, channel, user):
133133
return self.post('groups.invite',
134-
params={'channel': channel, 'user': user})
134+
data={'channel': channel, 'user': user})
135135

136136
def kick(self, channel, user):
137137
return self.post('groups.kick',
138-
params={'channel': channel, 'user': user})
138+
data={'channel': channel, 'user': user})
139139

140140
def leave(self, channel):
141-
return self.post('groups.leave', params={'channel': channel})
141+
return self.post('groups.leave', data={'channel': channel})
142142

143143
def mark(self, channel, ts):
144-
return self.post('groups.mark', params={'channel': channel, 'ts': ts})
144+
return self.post('groups.mark', data={'channel': channel, 'ts': ts})
145145

146146
def rename(self, channel, name):
147147
return self.post('groups.rename',
148-
params={'channel': channel, 'name': name})
148+
data={'channel': channel, 'name': name})
149149

150150
def archive(self, channel):
151-
return self.post('groups.archive', params={'channel': channel})
151+
return self.post('groups.archive', data={'channel': channel})
152152

153153
def unarchive(self, channel):
154-
return self.post('groups.unarchive', params={'channel': channel})
154+
return self.post('groups.unarchive', data={'channel': channel})
155155

156156
def open(self, channel):
157-
return self.post('groups.open', params={'channel': channel})
157+
return self.post('groups.open', data={'channel': channel})
158158

159159
def close(self, channel):
160-
return self.post('groups.close', params={'channel': channel})
160+
return self.post('groups.close', data={'channel': channel})
161161

162162
def set_purpose(self, channel, purpose):
163163
return self.post('groups.setPurpose',
164-
params={'channel': channel, 'purpose': purpose})
164+
data={'channel': channel, 'purpose': purpose})
165165

166166
def set_topic(self, channel, topic):
167167
return self.post('groups.setTopic',
168-
params={'channel': channel, 'topic': topic})
168+
data={'channel': channel, 'topic': topic})
169169

170170

171171
class Channels(BaseAPI):
172172
def create(self, name):
173-
return self.post('channels.create', params={'name': name})
173+
return self.post('channels.create', data={'name': name})
174174

175175
def info(self, channel):
176176
return self.get('channels.info', params={'channel': channel})
@@ -192,39 +192,39 @@ def history(self, channel, latest=None, oldest=None, count=None,
192192

193193
def mark(self, channel, ts):
194194
return self.post('channels.mark',
195-
params={'channel': channel, 'ts': ts})
195+
data={'channel': channel, 'ts': ts})
196196

197197
def join(self, name):
198-
return self.post('channels.join', params={'name': name})
198+
return self.post('channels.join', data={'name': name})
199199

200200
def leave(self, channel):
201-
return self.post('channels.leave', params={'channel': channel})
201+
return self.post('channels.leave', data={'channel': channel})
202202

203203
def invite(self, channel, user):
204204
return self.post('channels.invite',
205-
params={'channel': channel, 'user': user})
205+
data={'channel': channel, 'user': user})
206206

207207
def kick(self, channel, user):
208208
return self.post('channels.kick',
209-
params={'channel': channel, 'user': user})
209+
data={'channel': channel, 'user': user})
210210

211211
def rename(self, channel, name):
212212
return self.post('channels.rename',
213-
params={'channel': channel, 'name': name})
213+
data={'channel': channel, 'name': name})
214214

215215
def archive(self, channel):
216-
return self.post('channels.archive', params={'channel': channel})
216+
return self.post('channels.archive', data={'channel': channel})
217217

218218
def unarchive(self, channel):
219-
return self.post('channels.unarchive', params={'channel': channel})
219+
return self.post('channels.unarchive', data={'channel': channel})
220220

221221
def set_purpose(self, channel, purpose):
222222
return self.post('channels.setPurpose',
223-
params={'channel': channel, 'purpose': purpose})
223+
data={'channel': channel, 'purpose': purpose})
224224

225225
def set_topic(self, channel, topic):
226226
return self.post('channels.setTopic',
227-
params={'channel': channel, 'topic': topic})
227+
data={'channel': channel, 'topic': topic})
228228

229229
def get_channel_id(self, channel_name):
230230
channels = self.list().body['channels']
@@ -242,7 +242,7 @@ def post_message(self, channel, text, username=None, as_user=None, parse=None,
242242
attachments = json.dumps(attachments)
243243

244244
return self.post('chat.postMessage',
245-
params={
245+
data={
246246
'channel': channel,
247247
'text': text,
248248
'username': username,
@@ -258,10 +258,10 @@ def post_message(self, channel, text, username=None, as_user=None, parse=None,
258258

259259
def update(self, channel, ts, text):
260260
self.post('chat.update',
261-
params={'channel': channel, 'ts': ts, 'text': text})
261+
data={'channel': channel, 'ts': ts, 'text': text})
262262

263263
def delete(self, channel, ts):
264-
self.post('chat.delete', params={'channel': channel, 'ts': ts})
264+
self.post('chat.delete', data={'channel': channel, 'ts': ts})
265265

266266

267267
class IM(BaseAPI):
@@ -280,13 +280,13 @@ def history(self, channel, latest=None, oldest=None, count=None,
280280
})
281281

282282
def mark(self, channel, ts):
283-
return self.post('im.mark', params={'channel': channel, 'ts': ts})
283+
return self.post('im.mark', data={'channel': channel, 'ts': ts})
284284

285285
def open(self, user):
286-
return self.post('im.open', params={'user': user})
286+
return self.post('im.open', data={'user': user})
287287

288288
def close(self, channel):
289-
return self.post('im.close', params={'channel': channel})
289+
return self.post('im.close', data={'channel': channel})
290290

291291

292292
class Search(BaseAPI):
@@ -351,7 +351,7 @@ def upload(self, file_, content=None, filetype=None, filename=None,
351351
channels = ','.join(channels)
352352

353353
return self.post('files.upload',
354-
params={
354+
data={
355355
'content': content,
356356
'filetype': filetype,
357357
'filename': filename,
@@ -362,7 +362,7 @@ def upload(self, file_, content=None, filetype=None, filename=None,
362362
files={'file': f})
363363

364364
def delete(self, file_):
365-
return self.post('files.delete', params={'file': file_})
365+
return self.post('files.delete', data={'file': file_})
366366

367367

368368
class Stars(BaseAPI):
@@ -383,7 +383,7 @@ class Presence(BaseAPI):
383383

384384
def set(self, presence):
385385
assert presence in Presence.TYPES, 'Invalid presence type'
386-
return self.post('presence.set', params={'presence': presence})
386+
return self.post('presence.set', data={'presence': presence})
387387

388388

389389
class RTM(BaseAPI):
@@ -408,7 +408,7 @@ def add(self, name, file_=None, file_comment=None, channel=None,
408408
assert (file_ or file_comment) or (channel and timestamp)
409409

410410
return self.post('reactions.add',
411-
params={
411+
data={
412412
'name': name,
413413
'file': file_,
414414
'file_comment': file_comment,
@@ -443,7 +443,7 @@ def remove(self, name, file_=None, file_comment=None, channel=None,
443443
assert (file_ or file_comment) or (channel and timestamp)
444444

445445
return self.post('reactions.remove',
446-
params={
446+
data={
447447
'name': name,
448448
'file': file_,
449449
'file_comment': file_comment,
@@ -455,7 +455,7 @@ def remove(self, name, file_=None, file_comment=None, channel=None,
455455
class OAuth(BaseAPI):
456456
def access(self, client_id, client_secret, code, redirect_uri=None):
457457
return self.post('oauth.access',
458-
params={
458+
data={
459459
'client_id': client_id,
460460
'client_secret': client_secret,
461461
'code': code,

0 commit comments

Comments
 (0)