Skip to content

Commit

Permalink
add content type header to patch correct/update methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham4401 committed Jul 17, 2024
1 parent b8f85ba commit 93bea90
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions emanifest-py/src/emanifest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ class CorrectionVersionSearchParams(TypedDict, total=False):
versionNumber: str


class CorrectionRevert(TypedDict):
"""Information returned after successfully reverting a manifest under correction"""

currentVersionNumber: int
date: str
manifestTrackingNumber: str
operationStatus: str


class RcrainfoResponse(Generic[T]):
"""
RcrainfoResponse wraps around the requests library's Response object.
Expand Down Expand Up @@ -886,7 +895,7 @@ def correct_manifest(self, manifest_json: dict, zip_file: bytes = None) -> Rcrai
endpoint = f"{self.base_url}v1/emanifest/manifest/correct"
return self.__rcra_request("PUT", endpoint, multipart=multipart)

def revert_manifest(self, mtn: str) -> RcrainfoResponse:
def revert_manifest(self, mtn: str) -> RcrainfoResponse[CorrectionRevert]:
"""
Revert manifest in 'UnderCorrection' status to previous 'Corrected' or 'Signed' version
Expand All @@ -899,33 +908,37 @@ def revert_manifest(self, mtn: str) -> RcrainfoResponse:
endpoint = f"{self.base_url}v1/emanifest/manifest/revert/{mtn}"
return self.__rcra_request("GET", endpoint)

def patch_update_manifest(self, mtn: str, body: dict) -> RcrainfoResponse:
def patch_update_manifest(self, mtn: str, data: dict) -> RcrainfoResponse:
"""
Update a portion of a manifest via the patch process
Args:
mtn (str): Manifest tracking number
body (dict): Dictionary containing manifest portion details
data (dict): Partial manifest to be applied to the existing manifest
Returns:
dict: message of success or failure
"""
endpoint = f"{self.base_url}v1/emanifest/manifest/patch-update/{mtn}"
return self.__rcra_request("PATCH", endpoint, body)
return self.__rcra_request(
"PATCH", endpoint, headers={"Content-Type": "application/json-patch+json"}, **data
)

def patch_correct_manifest(self, mtn: str, body: dict) -> RcrainfoResponse:
def patch_correct_manifest(self, mtn: str, data: dict) -> RcrainfoResponse:
"""
Update a portion of a manifest via the patch process
Args:
mtn (str): Manifest tracking number
body (dict): Dictionary containing manifest portion details
data (dict): Partial manifest to be applied as a correction
Returns:
dict: message of success or failure
"""
endpoint = f"{self.base_url}v1/emanifest/manifest/patch-correct/{mtn}"
return self.__rcra_request("PATCH", endpoint, body)
return self.__rcra_request(
"PATCH", endpoint, headers={"Content-Type": "application/json-patch+json"}, **data
)

def update_manifest(self, manifest_json: dict, zip_file: bytes = None) -> RcrainfoResponse:
"""
Expand Down

0 comments on commit 93bea90

Please sign in to comment.