"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetadataMixin = void 0;
const base_core_sdk_1 = require("./../mixins/base-core-sdk");
const subgraph_1 = require("./subgraph");
class MetadataMixin extends base_core_sdk_1.BaseCoreSDK {
    /* -------------------------------------------------------------------------- */
    /*                          Metadata related methods                          */
    /* -------------------------------------------------------------------------- */
    /**
     * Stores supported offer metadata via the MetadataStorage instance which was passed in
     * at construction.
     * @param metadata - Offer metadata of type `BASE` or `PRODUCT_V1`.
     * @returns Metadata hash / identifier.
     */
    storeMetadata(metadata) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!this._metadataStorage) {
                throw new Error("No metadata storage set");
            }
            return this._metadataStorage.storeMetadata(metadata);
        });
    }
    /**
     * Returns supported offer metadata from passed in `MetadataStorage` instance.
     * @param metadataHashOrUri - Metadata hash or uri that can be handled by the
     * storage instance.
     * @returns Offer metadata.
     */
    getMetadata(metadataHashOrUri) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!this._metadataStorage) {
                throw new Error("No metadata storage set");
            }
            return this._metadataStorage.getMetadata(metadataHashOrUri);
        });
    }
    /**
     * Returns `BASE` type offer metadata entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns BaseMetadataEntities from subgraph.
     */
    getBaseMetadataEntities(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getBaseMetadataEntities)(this._subgraphUrl, queryVars);
        });
    }
    /**
     * Returns `PRODUCT_V1` type offer metadata entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns ProductV1MetadataEntities from subgraph.
     */
    getProductV1MetadataEntities(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getProductV1MetadataEntities)(this._subgraphUrl, queryVars);
        });
    }
    /**
     * Returns `BUNDLE` type offer metadata entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns BundleMetadataEntities from subgraph.
     */
    getBundleMetadataEntities(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getBundleMetadataEntities)(this._subgraphUrl, queryVars);
        });
    }
    getProductV1Products(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getProductV1Products)(this._subgraphUrl, queryVars);
        });
    }
    getProductWithVariants(sellerId, productUuid) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getProductWithVariants)(this._subgraphUrl, sellerId, productUuid);
        });
    }
    getProductWithVariantsFromOfferId(offerId) {
        return (0, subgraph_1.getProductWithVariantsFromOfferId)(this._subgraphUrl, offerId);
    }
    getAllProductsWithVariants(queryVars) {
        return (0, subgraph_1.getAllProductsWithVariants)(this._subgraphUrl, queryVars);
    }
    getAllProductsWithNotVoidedVariants(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getAllProductsWithNotVoidedVariants)(this._subgraphUrl, queryVars);
        });
    }
}
exports.MetadataMixin = MetadataMixin;
//# sourceMappingURL=mixin.js.map