@commercelayer/sdk
Version:
Commerce Layer Javascript SDK
79 lines (77 loc) • 3.78 kB
JavaScript
import { ApiResource } from './chunk-XKERR6OR.js';
// src/resources/gift_cards.ts
var GiftCards = class _GiftCards extends ApiResource {
static TYPE = "gift_cards";
async create(resource, params, options) {
return this.resources.create({ ...resource, type: _GiftCards.TYPE }, params, options);
}
async update(resource, params, options) {
return this.resources.update({ ...resource, type: _GiftCards.TYPE }, params, options);
}
async delete(id, options) {
await this.resources.delete(typeof id === "string" ? { id, type: _GiftCards.TYPE } : id, options);
}
async market(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "markets" }, `gift_cards/${_giftCardId}/market`, params, options);
}
async gift_card_recipient(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "gift_card_recipients" }, `gift_cards/${_giftCardId}/gift_card_recipient`, params, options);
}
async attachments(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "attachments" }, `gift_cards/${_giftCardId}/attachments`, params, options);
}
async events(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "events" }, `gift_cards/${_giftCardId}/events`, params, options);
}
async tags(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "tags" }, `gift_cards/${_giftCardId}/tags`, params, options);
}
async versions(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "versions" }, `gift_cards/${_giftCardId}/versions`, params, options);
}
async event_stores(giftCardId, params, options) {
const _giftCardId = giftCardId.id || giftCardId;
return this.resources.fetch({ type: "event_stores" }, `gift_cards/${_giftCardId}/event_stores`, params, options);
}
async _purchase(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _GiftCards.TYPE, _purchase: true }, params, options);
}
async _activate(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _GiftCards.TYPE, _activate: true }, params, options);
}
async _deactivate(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _GiftCards.TYPE, _deactivate: true }, params, options);
}
async _balance_change_cents(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _GiftCards.TYPE, _balance_change_cents: triggerValue }, params, options);
}
async _add_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _GiftCards.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: _GiftCards.TYPE, _remove_tags: triggerValue }, params, options);
}
isGiftCard(resource) {
return resource.type && resource.type === _GiftCards.TYPE;
}
relationship(id) {
return super.relationshipOneToOne(id);
}
relationshipToMany(...ids) {
return super.relationshipOneToMany(...ids);
}
type() {
return _GiftCards.TYPE;
}
};
var instance = new GiftCards();
var gift_cards_default = instance;
export { gift_cards_default };
//# sourceMappingURL=chunk-JWLNUOL5.js.map
//# sourceMappingURL=chunk-JWLNUOL5.js.map