def _partial_update(cls, entity, parameters=None, ids={}): # pragma: no cover
entity_id = getattr(entity, 'id', None)
if entity_id is not None:
ids['id'] = entity_id
if isinstance(entity, BaseAbstractEntity):
response = cls.REST_CLIENT.patch(
cls.get_base_uri(cls.endpoint_single(), **ids), json=entity.get_json_data(), headers=make_headers(),
params=parameters
)
else:
response = cls.REST_CLIENT.patch(
cls.get_base_uri(cls.endpoint_single(), **ids), data=json.dumps(entity), headers=make_headers(),
params=parameters
)
response = cls.REST_CLIENT.handle_response(response)
if cls.entity_class() is None or not issubclass(cls.entity_class(), BaseAbstractEntity):
return response # pragma: no cover
else:
return cls.entity_class().from_dict(response.json())
评论列表
文章目录