From 13595f724a9e6c73ca16b2e8cc57ea3f1c9a4be5 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 23 Mar 2020 19:26:24 -0700 Subject: [PATCH] Add argument params to _api_request for custom parameters. --- src/mega/mega.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mega/mega.py b/src/mega/mega.py index 7ddcdc4..479348b 100644 --- a/src/mega/mega.py +++ b/src/mega/mega.py @@ -46,12 +46,14 @@ class Mega: retry=retry_if_exception_type(RuntimeError), wait=wait_exponential(multiplier=2, min=2, max=60) ) - def _api_request(self, data): - params = {'id': self.sequence_num} + def _api_request(self, data, params={}): + req_params = {'id': self.sequence_num} self.sequence_num += 1 if self.sid: - params.update({'sid': self.sid}) + req_params.update({'sid': self.sid}) + + req_params.update(params) # ensure input data is a list if not isinstance(data, list): @@ -60,7 +62,7 @@ class Mega: url = f'{self.schema}://g.api.{self.domain}/cs' req = requests.post( url, - params=params, + params=req_params, data=json.dumps(data), timeout=self.timeout, )