From b5e0d6e9fe11932108c4e37c127f4de62f815edd Mon Sep 17 00:00:00 2001 From: yasamanloghman <130011231+yasamanloghman@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:52:33 -0500 Subject: [PATCH] Feat: Add code to promotion filters (#902) * feat: search code is eq, for promotion codes * Update promotions.d.ts feat: code filter --- package.json | 2 +- src/endpoints/promotions.js | 20 ++++++++++++-------- src/types/promotions.d.ts | 9 ++++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 518fafb7c..68a40ee57 100644 --- a/package.json +++ b/package.json @@ -114,4 +114,4 @@ "git add" ] } -} +} \ No newline at end of file diff --git a/src/endpoints/promotions.js b/src/endpoints/promotions.js index c20a59fac..86e379758 100644 --- a/src/endpoints/promotions.js +++ b/src/endpoints/promotions.js @@ -12,14 +12,18 @@ class PromotionsEndpoint extends CRUDExtend { return this.request.send(`${this.endpoint}/attributes`, 'GET') } - Codes(promotionId) { - const { limit, offset } = this - return this.request.send( - buildURL(`${this.endpoint}/${promotionId}/codes`, { - limit, - offset - }), - 'GET' + Codes(promotionId, token = null) { + const { limit, offset, filter } = this + return this.request.send( + buildURL(`${this.endpoint}/${promotionId}/codes`, { + limit, + offset, + filter + }), + 'GET', + undefined, + token, + this ) } diff --git a/src/types/promotions.d.ts b/src/types/promotions.d.ts index 9ab94fa7e..66721220e 100644 --- a/src/types/promotions.d.ts +++ b/src/types/promotions.d.ts @@ -237,10 +237,11 @@ export interface PromotionJob extends Identifiable { /** BE Doesnt support commented filter now, TO DO**/ -export interface PromotionJobsFilter { +export interface PromotionFilter { eq?: { job_type?: string status?: string + code?: string // name?: string // created_by?: string } @@ -277,13 +278,14 @@ export interface PromotionsEndpoint Promotion, PromotionBase, Identifiable & Partial, - PromotionJobsFilter, + PromotionFilter, never, never > { + endpoint: 'promotions' - Filter(filter: PromotionJobsFilter): PromotionsEndpoint + Filter(filter: PromotionFilter): PromotionsEndpoint Attributes(): Promise @@ -297,6 +299,7 @@ export interface PromotionsEndpoint /** * DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/carts-and-checkout/promotions/create-promotion-codes.html */ + AddCodes( promotionId: string, codes: PromotionCode[]