@commercelayer/sdk
Version:
Commerce Layer Javascript SDK
73 lines (71 loc) • 3.68 kB
JavaScript
import { ApiResource } from './chunk-XKERR6OR.js';
// src/resources/flex_promotions.ts
var FlexPromotions = class _FlexPromotions extends ApiResource {
static TYPE = "flex_promotions";
async create(resource, params, options) {
return this.resources.create({ ...resource, type: _FlexPromotions.TYPE }, params, options);
}
async update(resource, params, options) {
return this.resources.update({ ...resource, type: _FlexPromotions.TYPE }, params, options);
}
async delete(id, options) {
await this.resources.delete(typeof id === "string" ? { id, type: _FlexPromotions.TYPE } : id, options);
}
async coupon_codes_promotion_rule(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "coupon_codes_promotion_rules" }, `flex_promotions/${_flexPromotionId}/coupon_codes_promotion_rule`, params, options);
}
async coupons(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "coupons" }, `flex_promotions/${_flexPromotionId}/coupons`, params, options);
}
async attachments(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "attachments" }, `flex_promotions/${_flexPromotionId}/attachments`, params, options);
}
async events(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "events" }, `flex_promotions/${_flexPromotionId}/events`, params, options);
}
async tags(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "tags" }, `flex_promotions/${_flexPromotionId}/tags`, params, options);
}
async versions(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "versions" }, `flex_promotions/${_flexPromotionId}/versions`, params, options);
}
async event_stores(flexPromotionId, params, options) {
const _flexPromotionId = flexPromotionId.id || flexPromotionId;
return this.resources.fetch({ type: "event_stores" }, `flex_promotions/${_flexPromotionId}/event_stores`, params, options);
}
async _disable(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _FlexPromotions.TYPE, _disable: true }, params, options);
}
async _enable(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _FlexPromotions.TYPE, _enable: true }, params, options);
}
async _add_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _FlexPromotions.TYPE, _add_tags: triggerValue }, params, options);
}
async _remove_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _FlexPromotions.TYPE, _remove_tags: triggerValue }, params, options);
}
isFlexPromotion(resource) {
return resource.type && resource.type === _FlexPromotions.TYPE;
}
relationship(id) {
return super.relationshipOneToOne(id);
}
relationshipToMany(...ids) {
return super.relationshipOneToMany(...ids);
}
type() {
return _FlexPromotions.TYPE;
}
};
var instance = new FlexPromotions();
var flex_promotions_default = instance;
export { flex_promotions_default };
//# sourceMappingURL=chunk-G2Y67WFX.js.map
//# sourceMappingURL=chunk-G2Y67WFX.js.map