@commercelayer/sdk
Version:
Commerce Layer Javascript SDK
128 lines (126 loc) • 6.38 kB
JavaScript
import { ApiResource } from './chunk-XKERR6OR.js';
// src/resources/returns.ts
var Returns = class _Returns extends ApiResource {
static TYPE = "returns";
async create(resource, params, options) {
return this.resources.create({ ...resource, type: _Returns.TYPE }, params, options);
}
async update(resource, params, options) {
return this.resources.update({ ...resource, type: _Returns.TYPE }, params, options);
}
async delete(id, options) {
await this.resources.delete(typeof id === "string" ? { id, type: _Returns.TYPE } : id, options);
}
async order(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "orders" }, `returns/${_returnId}/order`, params, options);
}
async customer(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "customers" }, `returns/${_returnId}/customer`, params, options);
}
async stock_location(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "stock_locations" }, `returns/${_returnId}/stock_location`, params, options);
}
async origin_address(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "addresses" }, `returns/${_returnId}/origin_address`, params, options);
}
async destination_address(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "addresses" }, `returns/${_returnId}/destination_address`, params, options);
}
async reference_capture(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "captures" }, `returns/${_returnId}/reference_capture`, params, options);
}
async reference_refund(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "refunds" }, `returns/${_returnId}/reference_refund`, params, options);
}
async return_line_items(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "return_line_items" }, `returns/${_returnId}/return_line_items`, params, options);
}
async attachments(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "attachments" }, `returns/${_returnId}/attachments`, params, options);
}
async resource_errors(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "resource_errors" }, `returns/${_returnId}/resource_errors`, params, options);
}
async events(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "events" }, `returns/${_returnId}/events`, params, options);
}
async tags(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "tags" }, `returns/${_returnId}/tags`, params, options);
}
async versions(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "versions" }, `returns/${_returnId}/versions`, params, options);
}
async event_stores(returnId, params, options) {
const _returnId = returnId.id || returnId;
return this.resources.fetch({ type: "event_stores" }, `returns/${_returnId}/event_stores`, params, options);
}
async _request(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _request: true }, params, options);
}
async _approve(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _approve: true }, params, options);
}
async _cancel(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _cancel: true }, params, options);
}
async _ship(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _ship: true }, params, options);
}
async _reject(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _reject: true }, params, options);
}
async _receive(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _receive: true }, params, options);
}
async _restock(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _restock: true }, params, options);
}
async _archive(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _archive: true }, params, options);
}
async _unarchive(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _unarchive: true }, params, options);
}
async _refund(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _refund: true }, params, options);
}
async _refund_amount_cents(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.TYPE, _refund_amount_cents: triggerValue }, params, options);
}
async _add_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Returns.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: _Returns.TYPE, _remove_tags: triggerValue }, params, options);
}
isReturn(resource) {
return resource.type && resource.type === _Returns.TYPE;
}
relationship(id) {
return super.relationshipOneToOne(id);
}
relationshipToMany(...ids) {
return super.relationshipOneToMany(...ids);
}
type() {
return _Returns.TYPE;
}
};
var instance = new Returns();
var returns_default = instance;
export { returns_default };
//# sourceMappingURL=chunk-62EOOGD4.js.map
//# sourceMappingURL=chunk-62EOOGD4.js.map