From e086dc19ed0675973c999ad0bdbebc5d5f858be3 Mon Sep 17 00:00:00 2001 From: Pavel-qr <77878955+Pavel-qr@users.noreply.github.com> Date: Fri, 28 Jan 2022 00:35:11 +0300 Subject: [PATCH] Update bitrix24.py edit prepare_params method --- bitrix24/bitrix24.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bitrix24/bitrix24.py b/bitrix24/bitrix24.py index 27031e3..24248db 100644 --- a/bitrix24/bitrix24.py +++ b/bitrix24/bitrix24.py @@ -47,23 +47,16 @@ def _prepare_domain(self, domain): def _prepare_params(self, params, prev=''): """Transforms list of params to a valid bitrix array.""" ret = '' + if (isinstance(params, list) or isinstance(params, tuple)) and len(params) > 0: + params = dict(enumerate(params)) if isinstance(params, dict): for key, value in params.items(): + if (isinstance(params, list) or isinstance(params, tuple)) and len(params) > 0: + params = dict(enumerate(params)) if isinstance(value, dict): if prev: key = "{0}[{1}]".format(prev, key) ret += self._prepare_params(value, key) - elif (isinstance(value, list) or isinstance(value, tuple)) and len(value) > 0: - for offset, val in enumerate(value): - if isinstance(val, dict): - ret += self._prepare_params( - val, "{0}[{1}][{2}]".format(prev, key, offset)) - else: - if prev: - ret += "{0}[{1}][{2}]={3}&".format( - prev, key, offset, val) - else: - ret += "{0}[{1}]={2}&".format(key, offset, val) else: if prev: ret += "{0}[{1}]={2}&".format(prev, key, value)