From af4bc521bcffe4cb32880cc8d527b2a4b13ff9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Mon, 27 Nov 2023 23:17:24 +0000 Subject: [PATCH 1/3] chore: default None types --- src/budy/models/order.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/budy/models/order.py b/src/budy/models/order.py index 8876759..d2f2d1a 100644 --- a/src/budy/models/order.py +++ b/src/budy/models/order.py @@ -1433,17 +1433,17 @@ def merger(first, second, separator = " | "): @appier.operation( name = "Import Seeplus", parameters = ( - ("Fulfilment", "fulfilment", str, "HQ"), - ("Delivery", "delivery", str, "HQ"), - ("Origin", "origin", str), + ("Fulfilment", "fulfilment", str, None), + ("Delivery", "delivery", str, None), + ("Origin", "origin", str, None), ("Strict", "strict", bool, True) ), level = 2 ) def import_seeplus_s( self, - fulfilment = "HQ", - delivery = "HQ", + fulfilment = None, + delivery = None, origin = None, strict = True ): From 1132b108e4964d1ea4a893631f9f9558b447141a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Tue, 28 Nov 2023 04:56:20 +0000 Subject: [PATCH 2/3] docs: small documentation change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28c061e..96ca46d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Code coverage of at least 75% of the code base should be considered a priority. | Name | Type | Description | | ------------------ | ----- | --------------------------------------------------------------------------------------------- | | **SEEPLUS_ORIGIN** | `str` | The origin token to be used in Seeplus integration (defaults to: `63971c5c62bd0a62b956b4f3`). | -| **SEEPLUS_KEY** | `str` | If provided offer a way to ensure shared key authentication to Webhooks. | +| **SEEPLUS_KEY** | `str` | If provided offers a way to ensure shared key authentication in Seeplus Webhook update calls. | ## License From d733c2c9480d170856fdc08fcb8c13c6be124749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Sat, 23 Dec 2023 16:30:12 +0000 Subject: [PATCH 3/3] chore: add support for automatic fill of Seeplus fulfillment and delivery data --- CHANGELOG.md | 2 +- README.md | 9 +++++---- src/budy/models/order.py | 43 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d1e4d5..b73de20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* +* Support for automatic fill of Seeplus fulfillment and delivery data ### Changed diff --git a/README.md b/README.md index 96ca46d..fdd9979 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,11 @@ Code coverage of at least 75% of the code base should be considered a priority. ### Seeplus -| Name | Type | Description | -| ------------------ | ----- | --------------------------------------------------------------------------------------------- | -| **SEEPLUS_ORIGIN** | `str` | The origin token to be used in Seeplus integration (defaults to: `63971c5c62bd0a62b956b4f3`). | -| **SEEPLUS_KEY** | `str` | If provided offers a way to ensure shared key authentication in Seeplus Webhook update calls. | +| Name | Type | Description | +| ------------------------- | ----- | --------------------------------------------------------------------------------------------- | +| **SEEPLUS_ORIGIN** | `str` | The origin token to be used in Seeplus integration (defaults to: `63971c5c62bd0a62b956b4f3`). | +| **SEEPLUS_KEY** | `str` | If provided offers a way to ensure shared key authentication in Seeplus Webhook update calls. | +| **SEEPLUS_FULFILMENT_ID** | `int` | The ID of the Store that will be used for the fulfilment of the orders. | ## License diff --git a/src/budy/models/order.py b/src/budy/models/order.py index d2f2d1a..e27120d 100644 --- a/src/budy/models/order.py +++ b/src/budy/models/order.py @@ -46,6 +46,7 @@ import appier import appier_extras +from . import store from . import bundle from . import product from . import country @@ -1433,9 +1434,9 @@ def merger(first, second, separator = " | "): @appier.operation( name = "Import Seeplus", parameters = ( - ("Fulfilment", "fulfilment", str, None), - ("Delivery", "delivery", str, None), - ("Origin", "origin", str, None), + ("Fulfilment", "fulfilment", str), + ("Delivery", "delivery", str), + ("Origin", "origin", str), ("Strict", "strict", bool, True) ), level = 2 @@ -1451,6 +1452,42 @@ def import_seeplus_s( # configuration, expected default behaviour origin = origin or appier.conf("SEEPLUS_ORIGIN", "63971c5c62bd0a62b956b4f3") + # in case there's no fulfilment defined then the default + # store is used to retrieve the fulfilment identifier + if not fulfilment: + fulfilment_id = appier.conf("SEEPLUS_FULFILMENT_ID", None, cast = int) + appier.verify( + not fulfilment_id == None, + message = "No default fulfilment is defined" + ) + fulfilment_store = store.Store.get(id = fulfilment_id) + fulfilment = fulfilment_store.meta.get("seeplus_id", None) + + # if no explicit delivery is defined then the store for the + # delivery is used to obtain the Seeplus identifier + if not delivery: + appier.verify( + self.store, + message = "No store defined for order" + ) + delivery = self.store.meta.get("seeplus_id", None) + + # ensures that the complete set of required parameters for the + # Seeplus import are defined and valid, otherwise an exception + # is raised indicating the problem + appier.verify( + fulfilment, + message = "No fulfilment is set for order" + ) + appier.verify( + delivery, + message = "No delivery is set for order" + ) + appier.verify( + origin, + message = "No origin is set for order" + ) + # obtains the reference to the Seeplus API instance and # validates that the order is ready to be imported api = self.owner.get_seeplus_api()