@shopletzy/shop-sdk
Advanced tools
Comparing version 0.1.28 to 0.1.29
import { ShopletzyClient } from "./index"; | ||
import { MakePaymentReq, Order, PaymentFailureReq, PaymentSuccessReq } from "./types/index"; | ||
import { MakePaymentReq, Order, PaymentFailureReq, PaymentSuccessReq, Promotion } from "./types/index"; | ||
export declare class OrderResource { | ||
@@ -8,2 +8,5 @@ client: ShopletzyClient; | ||
getOrderById(orderId: string): Promise<Order>; | ||
getPromotions(orderId: string): Promise<Promotion[]>; | ||
applyPromotion(orderId: string, promoCode: string): Promise<any>; | ||
removePromotion(orderId: string): Promise<any>; | ||
makePayment(orderId: string, makePaymentReq: MakePaymentReq): Promise<{ | ||
@@ -10,0 +13,0 @@ rzrOrderId: string; |
@@ -29,2 +29,33 @@ "use strict"; | ||
} | ||
getPromotions(orderId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const d = yield this.client.fetch(`/${this.client.storeName}/v1/orders/${orderId}/promotions`); | ||
return (yield d.json()).promotions; | ||
}); | ||
} | ||
applyPromotion(orderId, promoCode) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const d = yield this.client.fetch(`/${this.client.storeName}/v1/orders/${orderId}/applyPromotion`, { | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
promoCode | ||
}) | ||
}); | ||
return yield d.json(); | ||
}); | ||
} | ||
removePromotion(orderId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const d = yield this.client.fetch(`/${this.client.storeName}/v1/orders/${orderId}/removePromotion`, { | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
} | ||
}); | ||
return yield d.json(); | ||
}); | ||
} | ||
makePayment(orderId, makePaymentReq) { | ||
@@ -31,0 +62,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -490,2 +490,22 @@ export declare type ClientConfig = { | ||
}; | ||
export declare type PromotionType = "amount" | "percentage"; | ||
export declare type Discount = { | ||
amount: number; | ||
percentage: number; | ||
maxDiscountAmount: number; | ||
}; | ||
export declare type Promotion = { | ||
id: string; | ||
title: string; | ||
description: string; | ||
promotionType: PromotionType; | ||
code: string; | ||
discount: Discount; | ||
minOrderValue: number; | ||
available: number; | ||
claimed: number; | ||
validFrom: Date; | ||
validUpto: Date; | ||
eligible: boolean; | ||
}; | ||
export {}; |
{ | ||
"name": "@shopletzy/shop-sdk", | ||
"version": "0.1.28", | ||
"version": "0.1.29", | ||
"description": "Shop SDK for Shopletzy Storefront APIs", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47685
1278