Skip to content

Commit 78cacae

Browse files
committed
add strip function to remove property in option
1 parent 1a990da commit 78cacae

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

nasdaqdatalink/connection.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
AuthenticationError, ForbiddenError, InvalidRequestError,
1515
NotFoundError, ServiceUnavailableError)
1616

17+
KW_TO_REMOVE = [
18+
'session',
19+
'api_config'
20+
]
21+
1722

1823
class Connection:
1924
@classmethod
@@ -48,9 +53,7 @@ def execute_request(cls, http_verb, url, **options):
4853

4954
api_config = get_config_from_kwargs(options)
5055

51-
# clean the request payload
52-
options.get('params', {}).pop('session', None)
53-
options.get('params', {}).pop('api_config', None)
56+
cls.options_kw_strip(options)
5457
try:
5558
response = session.request(method=http_verb,
5659
url=url,
@@ -126,3 +129,8 @@ def handle_api_error(cls, resp):
126129
klass = d_klass.get(code_letter, DataLinkError)
127130

128131
raise klass(message, resp.status_code, resp.text, resp.headers, code)
132+
133+
@classmethod
134+
def options_kw_strip(self, options):
135+
for kw in KW_TO_REMOVE:
136+
options.get('params', {}).pop(kw, None)

0 commit comments

Comments
 (0)