Skip to content

Commit a4e2c79

Browse files
committed
update patch_item function to use Item instead of item_uuid
1 parent dcf8b21 commit a4e2c79

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dspace_rest_client/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ def update_item(self, item, embeds=None):
12861286

12871287
def patch_item(
12881288
self,
1289-
item_uuid,
1289+
item,
12901290
operation,
12911291
field,
12921292
value=None,
@@ -1306,8 +1306,8 @@ def patch_item(
13061306
@return: The API response or None in case of an error.
13071307
"""
13081308
try:
1309-
if not item_uuid:
1310-
logging.error("Item UUID is required")
1309+
if not isinstance(item, Item):
1310+
logging.error("Need a valid item")
13111311
return None
13121312

13131313
if not field or not value:
@@ -1330,7 +1330,7 @@ def patch_item(
13301330
return None
13311331

13321332
# Construct the item URI
1333-
item_uri = f"{self.API_ENDPOINT}/core/items/{item_uuid}"
1333+
item_uri = f"{self.API_ENDPOINT}/core/items/{item.uuid}"
13341334

13351335
path = f"/metadata/{field}/{place}"
13361336
patch_value = {
@@ -1349,12 +1349,12 @@ def patch_item(
13491349
)
13501350

13511351
if response.status_code in [200, 204]:
1352-
logging.info("Successfully patched item: %s", item_uuid)
1352+
logging.info("Successfully patched item: %s", item.uuid)
13531353
return response
13541354
else:
13551355
logging.error(
13561356
"Failed to patch item: %s (Status: %s, Response: %s)",
1357-
item_uuid,
1357+
item.uuid,
13581358
response.status_code,
13591359
response.text,
13601360
)

0 commit comments

Comments
 (0)