Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Feat: Add code to promotion filters (#902)
Browse files Browse the repository at this point in the history
* feat: search code is eq, for promotion codes

* Update promotions.d.ts

feat: code filter
  • Loading branch information
yasamanloghman authored Jan 9, 2024
1 parent 18ca2a2 commit b5e0d6e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@
"git add"
]
}
}
}
20 changes: 12 additions & 8 deletions src/endpoints/promotions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
9 changes: 6 additions & 3 deletions src/types/promotions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -277,13 +278,14 @@ export interface PromotionsEndpoint
Promotion,
PromotionBase,
Identifiable & Partial<PromotionBase>,
PromotionJobsFilter,
PromotionFilter,
never,
never
> {

endpoint: 'promotions'

Filter(filter: PromotionJobsFilter): PromotionsEndpoint
Filter(filter: PromotionFilter): PromotionsEndpoint

Attributes(): Promise<Attributes>

Expand All @@ -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[]
Expand Down

0 comments on commit b5e0d6e

Please sign in to comment.