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

Commit

Permalink
feat: Add optional header parameter to the addProduct function in car…
Browse files Browse the repository at this point in the history
…t module (#770)

* Add optional header parameter to the addProduct function in cart module

* Added the data type for additionalHeaders in cart module
  • Loading branch information
rishi-ayata authored Feb 21, 2023
1 parent 635dbb5 commit e92215d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/endpoints/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ class CartEndpoint extends BaseExtend {
return this.call
}

AddProduct(productId, quantity = 1, data = {}, isSku = false, token = null) {
AddProduct(
productId,
quantity = 1,
data = {},
isSku = false,
token = null,
additionalHeaders = {}
) {
const body = buildCartItemData(productId, quantity, 'cart_item', {}, isSku)

return this.request.send(
Expand All @@ -53,7 +60,11 @@ class CartEndpoint extends BaseExtend {
...body,
...data
},
token
token,
null,
true,
null,
additionalHeaders
)
}

Expand Down
12 changes: 10 additions & 2 deletions src/types/cart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ export interface CartIncluded {
items: CartItem[]
}

export interface CartAdditionalHeaders {
'EP-Context-Tag'?: string
'EP-Channel'?: string
'X-MOLTIN-CURRENCY'?: string
}

export interface CartEndpoint
extends CartQueryableResource<Cart, never, never> {
endpoint: 'carts'
Expand Down Expand Up @@ -200,7 +206,8 @@ export interface CartEndpoint
quantity?: number,
data?: any,
isSku?: boolean,
token?: string
token?: string,
additionalHeaders?: CartAdditionalHeaders
): Promise<CartItemsResponse>

/**
Expand Down Expand Up @@ -250,7 +257,8 @@ export interface CartEndpoint
AddProduct(
productId: string,
quantity?: number,
data?: any
data?: any,
additionalHeaders?: CartAdditionalHeaders
): Promise<CartItemsResponse>

RemoveAllItems(): Promise<CartItemsResponse>
Expand Down

0 comments on commit e92215d

Please sign in to comment.