bc-payments-sdk
Version:
BetterCommerce's Payments NodeJS SDK is a complete solution for storefront clients that integrate payments. `bc-payments-sdk` is a single point interface for storefront clients for interacting with payment gateways.
31 lines (30 loc) • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Order = void 0;
const api_1 = require("./api");
const BCEnvironment_1 = require("../../base/config/BCEnvironment");
const constants_1 = require("../../constants/constants");
const RequestMethod_1 = require("../../constants/enums/RequestMethod");
/**
* The {Order} class provides methods for interacting with the Order endpoint on the CommerceHub API.
*/
class Order {
/**
* Retrieves the details of an order using the specified data.
*
* This method makes an API call to fetch order information based on the provided
* data, headers, and cookies. It constructs a set of parameters including country,
* currency, and basket ID, which are used in the API request.
*
* @param data - The data required to identify the order.
* @param headers - The headers to include in the request.
* @param cookies - Cookies to use for setting additional headers like Currency, Language, etc.
* @returns A promise that resolves to the order details or an error object if the request fails.
*/
static async get(data, { headers, cookies }) {
const params = { country: (data === null || data === void 0 ? void 0 : data.countryCode) || BCEnvironment_1.BCEnvironment.getDefaultCountry(), currency: (data === null || data === void 0 ? void 0 : data.currencyCode) || BCEnvironment_1.BCEnvironment.getDefaultCurrency(), basketId: (data === null || data === void 0 ? void 0 : data.basketId) || constants_1.Defaults.Guid.Value, };
const orderResult = await api_1.Api.call(`api/v2/commerce/order/${data}`, RequestMethod_1.RequestMethod.GET, params, headers, cookies);
return orderResult;
}
}
exports.Order = Order;