Skip to content

Commit 9aadfdf

Browse files
committed
Code review changes for comments and reorganizing functions.
1 parent d629710 commit 9aadfdf

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

actions/files.upload.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ parameters:
1717
type: string
1818
content:
1919
required: false
20-
description: "File contents via a POST variable. If omitting this parameter, you must provide a `file`."
20+
description: "File contents via a POST variable. If omitting this parameter, you must provide either `file` or `content`."
2121
type: string
2222
file:
2323
required: false
24-
description: "File contents via `multipart/form-data`. If omitting this parameter, you must submit `content`."
24+
description: "File contents via `multipart/form-data`. If omitting this parameter, you must provide either `file` or `content`."
2525
type: string
2626
file_path:
2727
required: false
2828
default: ""
29-
description: "Path to the file on the local filesystem that will be opened, read and uploaded to Slack. If omitting this parameter, you must submit either `file` or `content`."
29+
description: "Path to the file on the local filesystem that will be opened, read and uploaded to Slack. If omitting this parameter, you must provide either `file` or `content`."
3030
type: string
3131
filename:
3232
required: false

actions/files_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def run(self, **kwargs):
2020
kwargs.pop('file', None)
2121
kwargs.pop('file_path')
2222

23-
self._do_request(kwargs, files)
23+
super(FilesUploadAction, self).run(files=files, **kwargs)

actions/run.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212

1313
class SlackAction(Action):
1414

15-
def run(self, **kwargs):
16-
return self._do_request(kwargs)
17-
18-
def _do_request(self, params, files=None):
15+
def run(self, files=None, **kwargs):
16+
params = kwargs
1917
if params.get('token', None) is None:
2018
params['token'] = self.config['action_token']
2119

@@ -67,12 +65,12 @@ def encode_dict(in_dict):
6765
# upload files. Instead we need requests to create a unique
6866
# Content-Type: multipart/formdata; boundary-----XYZ123
6967
# This Content-Type and boundary string is unique will be generated
70-
# automatically for us if we do no specify a Content-Type.
68+
# automatically for us if we do not specify a Content-Type.
7169
# If we specify headers here with a Content-Type then file uploads
7270
# will not work and return mysterious errors
7371
headers.pop('Content-Type', None)
7472

75-
# We're passing data as the params dict instead of
73+
# We're passing the params dict into the data parameter instead of
7674
# the URL encoded string 'data' from above, this is critical too
7775
# so that all of the additional parameters will be included as
7876
# multipart/formdata pieces. If you pass in the URL encoded data string

bin/generate_openapi.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,24 @@
2020
'files.upload': {
2121
'entry_point': 'files_upload.py',
2222
'parameters': {
23+
# overriding content and file to modify their descriptions
24+
'content': {
25+
'name': 'content',
26+
'type': 'string',
27+
'required': False,
28+
'description': 'File contents via a POST variable. If omitting this parameter, you must provide either `file` or `content`.', # noqa: E501
29+
},
30+
'file': {
31+
'name': 'file',
32+
'type': 'string',
33+
'required': False,
34+
'description': 'File contents via `multipart/form-data`. If omitting this parameter, you must provide either `file` or `content`.', # noqa: E501
35+
},
2336
'file_path': {
2437
'name': 'file_path',
2538
'type': 'string',
2639
'required': False,
27-
'description': 'Path to the file on the local filesystem that will be opened, read and uploaded to Slack. If omitting this parameter, you must submit either `file` or `content`.', # noqa: E501
40+
'description': 'Path to the file on the local filesystem that will be opened, read and uploaded to Slack. If omitting this parameter, you must provide either `file` or `content`.', # noqa: E501
2841
}
2942
}
3043
}

0 commit comments

Comments
 (0)