"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const sdk_1 = require("../sdk");
const query_1 = require("../../tools/query");
var Products;
(function (Products) {
    function findByCategoryId(categoryId, options = {}) {
        const { page, perPage, sortPath, ascending } = query_1.getDefaults(options);
        return sdk_1.clientExecute({
            uri: sdk_1.getServices()
                .productProjectionsSearch.filter(`categories.id:subtree("${categoryId}")`)
                .page(page)
                .perPage(perPage)
                .sort(sortPath, ascending)
                .build(),
            method: sdk_1.methods.GET
        });
    }
    Products.findByCategoryId = findByCategoryId;
    function findBySearchQuery(q, language = 'en', options = {}) {
        const { page, perPage, sortPath, ascending } = query_1.getDefaults(options);
        return sdk_1.clientExecute({
            uri: sdk_1.getServices()
                .productProjectionsSearch.text(q, language)
                .fuzzy(true)
                .page(page)
                .perPage(perPage)
                .sort(sortPath, ascending)
                .build(),
            method: sdk_1.methods.GET
        });
    }
    Products.findBySearchQuery = findBySearchQuery;
    function findById(productId) {
        return sdk_1.clientExecute({
            uri: sdk_1.getServices()
                .productProjections.byId(productId)
                .build(),
            method: sdk_1.methods.GET
        });
    }
    Products.findById = findById;
})(Products = exports.Products || (exports.Products = {}));
//# sourceMappingURL=products.js.map