Skip to content

Commit

Permalink
Merge pull request #36 from hivesolutions/joamag/import-seeplus
Browse files Browse the repository at this point in the history
Support for auto store selection in Seeplus
  • Loading branch information
joamag authored Dec 23, 2023
2 parents de3c17f + 53a4495 commit 7a6e249
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 offer a way to ensure shared key authentication to Webhooks. |
| 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

Expand Down
45 changes: 41 additions & 4 deletions src/budy/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import appier
import appier_extras

from . import store
from . import bundle
from . import product
from . import country
Expand Down Expand Up @@ -1433,24 +1434,60 @@ def merger(first, second, separator = " | "):
@appier.operation(
name = "Import Seeplus",
parameters = (
("Fulfilment", "fulfilment", str, "HQ"),
("Delivery", "delivery", str, "HQ"),
("Fulfilment", "fulfilment", str),
("Delivery", "delivery", str),
("Origin", "origin", str),
("Strict", "strict", bool, True)
),
level = 2
)
def import_seeplus_s(
self,
fulfilment = "HQ",
delivery = "HQ",
fulfilment = None,
delivery = None,
origin = None,
strict = True
):
# defaults the origin value to the one present in the global
# 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()
Expand Down

0 comments on commit 7a6e249

Please sign in to comment.