Skip to content

Commit 2fa39d7

Browse files
committed
Remove webhook_sync/webhook_update, enhance patch_item docs
1 parent fa6afb6 commit 2fa39d7

File tree

1 file changed

+12
-70
lines changed

1 file changed

+12
-70
lines changed

ShipthisAPI/shipthisapi.py

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,26 @@ def patch_item(
483483
) -> Dict[str, Any]:
484484
"""Patch specific fields of an item.
485485
486+
This is the recommended way to update document fields. It goes through
487+
full field validation, workflow triggers, audit logging, and business logic.
488+
486489
Args:
487-
collection_name: Name of the collection.
490+
collection_name: Name of the collection (e.g., "sea_shipment", "fcl_load").
488491
object_id: Document ID.
489-
update_fields: Fields to update.
492+
update_fields: Dictionary of field_id to value mappings.
490493
491494
Returns:
492495
Updated document data.
493496
494497
Raises:
495498
ShipthisAPIError: If the request fails.
499+
500+
Example:
501+
client.patch_item(
502+
"fcl_load",
503+
"68a4f906743189ad061429a7",
504+
update_fields={"container_no": "CONT123", "seal_no": "SEAL456"}
505+
)
496506
"""
497507
return self._make_request(
498508
"PATCH",
@@ -978,74 +988,6 @@ def upload_file(
978988
status_code=response.status_code,
979989
)
980990

981-
# ==================== Webhook Operations ====================
982-
983-
def webhook_sync(
984-
self,
985-
view_name: str,
986-
doc_id: str,
987-
fields: List[Dict[str, Any]],
988-
) -> Dict[str, Any]:
989-
"""Update document via webhook-sync (synchronous update).
990-
991-
Args:
992-
view_name: View/collection name (e.g., "sea_shipment", "fcl_load").
993-
doc_id: Document ID.
994-
fields: List of field dicts to update.
995-
996-
Returns:
997-
API response with success status and data.
998-
999-
Raises:
1000-
ShipthisAPIError: If the request fails.
1001-
1002-
Example:
1003-
client.webhook_sync(
1004-
"fcl_load",
1005-
"68a4f906743189ad061429a7",
1006-
fields=[{"container_no": "CONT123"}, {"seal_no": "SEAL456"}]
1007-
)
1008-
"""
1009-
payload = {"fields": fields}
1010-
return self._make_request(
1011-
"PUT",
1012-
f"webhook-sync/{self.organisation_id}/{view_name}/{doc_id}",
1013-
request_data=payload,
1014-
)
1015-
1016-
def webhook_update(
1017-
self,
1018-
view_name: str,
1019-
doc_id: str,
1020-
actions: List[Dict[str, Any]],
1021-
) -> Dict[str, Any]:
1022-
"""Update document via webhook (async update with actions).
1023-
1024-
Args:
1025-
view_name: View/collection name.
1026-
doc_id: Document ID.
1027-
actions: List of action dicts to execute.
1028-
1029-
Returns:
1030-
API response with success status and data.
1031-
1032-
Raises:
1033-
ShipthisAPIError: If the request fails.
1034-
1035-
Example:
1036-
client.webhook_update(
1037-
"sea_shipment",
1038-
"68a4f906743189ad061429a7",
1039-
actions=[{"action": "update_status", "value": "completed"}]
1040-
)
1041-
"""
1042-
payload = {"actions": actions}
1043-
return self._make_request(
1044-
"PUT",
1045-
f"webhook/{self.organisation_id}/{view_name}/{doc_id}",
1046-
request_data=payload,
1047-
)
1048-
1049991
# ==================== Reference Linked Fields ====================
1050992

1051993
def create_reference_linked_field(

0 commit comments

Comments
 (0)