shopify-admin-api
Version:
Shopify Admin API is a NodeJS library built to help developers easily authenticate and make calls against the Shopify API. It was inspired by and borrows heavily from ShopifySharp.
51 lines (50 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Transactions = void 0;
const infrastructure_1 = require("../infrastructure");
/**
* A service for manipulating an order's transactions.
*/
class Transactions extends infrastructure_1.BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "orders");
}
getPath(orderId, path) {
return this.joinUriPaths(`${orderId}/transactions`, path);
}
/**
* Creates a new transaction.
* @param orderId Id of the order that the transaction will belong to.
* @param transaction The transaction being created.
*/
create(orderId, transaction) {
return this.createRequest("POST", this.getPath(orderId, ".json"), "transaction", { transaction });
}
/**
* Gets an transaction with the given id.
* @param orderId Id of the order that the transaction belongs to.
* @param transactionId Id of the transaction being retrieved.
* @param options Options for filtering the result.
*/
get(orderId, transactionId, options) {
return this.createRequest("GET", this.getPath(orderId, `${transactionId}.json`), "transaction", options);
}
/**
* Lists up to 250 transactions for the given order.
* @param orderId Id of the order that the transactions belong to.
* @param options Options for filtering the results.
*/
list(orderId, options) {
return this.createRequest("GET", this.getPath(orderId, ".json"), "transactions", options);
}
/**
* Counts the transactions on the given order.
* @param orderId Id of the order that the transactions belong to.
* @param options Options for filtering the results.
*/
count(orderId) {
return this.createRequest("GET", this.getPath(orderId, "count.json"), "count");
}
}
exports.Transactions = Transactions;
exports.default = Transactions;