From dedfaaf6f1fe957af9b9707be860f4048be3f755 Mon Sep 17 00:00:00 2001 From: Jacob Shilitz Date: Thu, 5 Sep 2024 14:15:04 -0400 Subject: [PATCH] Add carrier services metadata property for testing Introduced a new property `carrier_services_metadata` for retrieving carrier service information. This utility function makes a GET request to the carrier-services API and converts the response to a dictionary format for easier testing and validation. related: #675 --- .../eshipper/karrio/providers/eshipper/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/connectors/eshipper/karrio/providers/eshipper/utils.py b/modules/connectors/eshipper/karrio/providers/eshipper/utils.py index 0ac3c986b2..9a260817bb 100644 --- a/modules/connectors/eshipper/karrio/providers/eshipper/utils.py +++ b/modules/connectors/eshipper/karrio/providers/eshipper/utils.py @@ -38,6 +38,20 @@ def access_token(self): return new_auth["token"] + # for testing only + @property + def carrier_services_metadata(self): + result = lib.request( + url=f"{self.server_url}/api/carrier-services", + method="GET", + headers={ + "content-Type": "application/json", + "Authorization": f"Bearer {self.access_token}", + }, + ) + response = lib.to_dict(result) + return {**response} + def login(settings: Settings): """Sign in response