import { FetchHelper } from "../../../globals/FetchHelper";
export class MarketwebTableService {
    _endpoint;
    _language;
    fetchHelper = new FetchHelper('MarketTableService');
    _getUserShipmentsPath = `/get-user-shipments`;
    constructor(endpoint, language) {
        this._endpoint = this.formatEndpoint(endpoint);
        this._language = language;
    }
    async getUserShipments(contentId, skip, take, isChatEnabled) {
        let model = {
            skip: skip,
            take: take,
            isChatEnabled: isChatEnabled,
            language: this._language,
            contentId: contentId,
        };
        const fetchUrl = this._endpoint + this._getUserShipmentsPath;
        const data = (await this.fetchHelper.fetchJson(fetchUrl, this.getRequestInit(model), false));
        return JSON.parse(data.shipments);
    }
    formatEndpoint(endpoint) {
        var formattedEndpoint = endpoint.lastIndexOf('/') === endpoint.length - 1 ? endpoint.substring(0, endpoint.length - 1) : endpoint;
        return formattedEndpoint;
    }
    getRequestInit(model, method = 'POST', mode = 'cors', contentTypes = 'application/json') {
        return {
            mode: mode,
            method: method,
            headers: {
                'Content-Type': contentTypes
            },
            body: JSON.stringify(model)
        };
    }
}
//# sourceMappingURL=pn-marketweb-table.service.js.map
