Skip to content

Commit

Permalink
feat(cart-discount): added setStores support (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom authored Oct 23, 2024
1 parent bd17654 commit c970b6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-candles-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@labdigital/commercetools-mock": minor
---

Added cart discount set stores support
12 changes: 12 additions & 0 deletions src/repositories/cart-discount/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
CartDiscountSetCustomTypeAction,
CartDiscountSetDescriptionAction,
CartDiscountSetKeyAction,
CartDiscountSetStoresAction,
CartDiscountSetValidFromAction,
CartDiscountSetValidFromAndUntilAction,
CartDiscountSetValidUntilAction,
Expand All @@ -18,6 +19,7 @@ import type { UpdateHandlerInterface } from "../abstract";
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";

import { CommercetoolsError } from "~src/exceptions";
import { getStoreKeyReference } from "~src/repositories/helpers";

export class CartDiscountUpdateHandler
extends AbstractUpdateHandler
Expand Down Expand Up @@ -118,6 +120,16 @@ export class CartDiscountUpdateHandler
resource.key = key;
}

setStores(
context: RepositoryContext,
resource: Writable<CartDiscount>,
{ stores }: CartDiscountSetStoresAction,
) {
resource.stores = stores?.map((s) =>
getStoreKeyReference(s, context.projectKey, this._storage),
);
}

setValidFrom(
context: RepositoryContext,
resource: Writable<CartDiscount>,
Expand Down

0 comments on commit c970b6e

Please sign in to comment.