def _parse_query(self):
        target = self.reference.value

        if self.reference.kind.endswith('method'):
            schema = method_schema(*target)['definitions']['method_request']
        elif self.reference.kind in ['collection', 'application']:
            schema = target.schema
        else:
            schema = target.collection.schema

        self.formatter_kwargs = self.reference.kwargs

        if self.query_params:
            for k, v in self.query_params.items():
                v = v[0]  # no list valued arguments in api-args
                if v.startswith('"'):
                    v = v[1:-1]
                else:
                    try:
                        v = int(v)
                    except ValueError:
                        try:
                            v = float(v)
                        except ValueError:
                            pass
                self.api_arguments[k] = v

        if self.body:
            if isinstance(self.body, bytes):
                body_args = json.loads(self.body.decode('utf-8'))
            elif isinstance(self.body, str):
                body_args = json.loads(self.body)
            else:
                body_args = self.body

            if isinstance(body_args, list):
                self.objects.extend(body_args)
            else:
                if "__q" in body_args:
                    self.api_arguments.update(body_args['__q'])
                    self.request_method = body_args.get('__method', self.request_method).upper()
                    self.objects = body_args.get("__objs", [])
                else:
                    self.objects = [body_args]

        for object in self.objects:
            jsonschema.validate(object, schema)

        if self.files:
            self.objects[0].update(self.files)


        self.durability = self.api_arguments.get('durability', 'hard')
        self.return_changes = self.api_arguments.get('return_changes', 'false').lower() != 'false'
        self.dereference = self.api_arguments.get('dereference', 'false').lower() != 'false'
        self.delete_all = self.api_arguments.get('delete_all', 'false').lower() != 'false'
        self.conflict = self.api_arguments.get('conflict', {
            'POST': "error",
            'PUT': "replace",
            'PATCH': "replace"
        }.get(self.request_method, 'error'))
dataset/ETHPy150Open JeffHeard/sondra/sondra/api.py/APIRequest._parse_query/original