"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listOffersBulk = exports.resolveOffer = exports.listOffers = exports.getOffer = exports.debugOffer = void 0;
var metro_runtime_1 = require("@wix/metro-runtime");
var ambassador_1 = require("@wix/metro-runtime/ambassador");
var metro_runtime_2 = require("@wix/metro-runtime");
var _compoundCriteria = { children: '_targeting' };
var _debugOfferRequest = {};
var _debugOfferResponse = {
    offer: '_offer',
    targeting: '_targeting',
    releaseAudience: '_releaseAudience',
    targetingTree: '_targetingTree',
};
var _getOfferRequest = {};
var _getOfferResponse = { offer: '_offer' };
var _listOffersBulkRequest = {};
var _listOffersBulkResponse = { realEstates: 'Map#_listOffersResponse' };
var _listOffersRequest = {};
var _listOffersResponse = { offers: '_offer' };
var _offer = {
    startDate: 'google.protobuf.Timestamp',
    endDate: 'google.protobuf.Timestamp',
};
var _releaseAudience = {
    timeStart: 'google.protobuf.Timestamp',
    timeStop: 'google.protobuf.Timestamp',
};
var _resolveOfferRequest = {};
var _resolveOfferResponse = { offer: '_offer' };
var _targeting = { compound: '_compoundCriteria' };
var _targetingTree = { compoundCriteria: '_v1CompoundCriteria' };
var _v1CompoundCriteria = { children: '_targetingTree' };
function resolveWixDealerOffersServingApiV1DealerOffersServingUrl(opts) {
    var domainToMappings = {
        'support._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/answers-routing/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'scheduler._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'premium._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'events._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'editor._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'blocks._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'create.editorx': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'ecom._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'apps._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'bo._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'wixbo.ai': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'wix-bo.com': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'manage._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/_api/dealer-offers-serving-service/proxy',
                destPath: '',
            },
        ],
        'users._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'api._api_base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'www._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'dev._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        _: [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'platform.rise.ai': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'vibe._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
    };
    return (0, metro_runtime_2.resolveUrl)(Object.assign(opts, { domainToMappings: domainToMappings }));
}
function resolveWixDealerOffersServingApiV1DealerOffersDebugUrl(opts) {
    var domainToMappings = {
        'support._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/answers-routing/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'scheduler._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'premium._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'events._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'editor._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'blocks._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'create.editorx': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'ecom._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'apps._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'bo._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'wixbo.ai': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'wix-bo.com': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'manage._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/_api/dealer-offers-serving-service/proxy',
                destPath: '',
            },
        ],
        'users._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'api._api_base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'www._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'dev._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        _: [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
            {
                srcPath: '/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'platform.rise.ai': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
        'vibe._base_domain_': [
            {
                srcPath: '/_api/dealer-offers-serving-service',
                destPath: '',
            },
        ],
    };
    return (0, metro_runtime_2.resolveUrl)(Object.assign(opts, { domainToMappings: domainToMappings }));
}
/**
 * Debug offer in a given context.
 * Will return the offer and its audience result.
 * Only for permitted users.
 * Context is always explicit and can contains information such as userId, siteId, loggedInAccounnt etc.
 */
function debugOffer(payload) {
    var _a = (0, ambassador_1.serializer)(_debugOfferRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_debugOfferResponse, {
        _compoundCriteria: _compoundCriteria,
        _offer: _offer,
        _releaseAudience: _releaseAudience,
        _targeting: _targeting,
        _targetingTree: _targetingTree,
        _v1CompoundCriteria: _v1CompoundCriteria,
    }).fromJSON;
    function __debugOffer(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.dealer.v1.serving_offer',
            method: 'GET',
            methodFqn: 'wix.dealerOffersServing.api.v1.DealerOffersDebug.DebugOffer',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixDealerOffersServingApiV1DealerOffersDebugUrl({
                protoPath: '/v1/dealer/debug/offers/{offerId}',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData),
            transformResponse: fromRes,
            fallback: [
                {
                    method: 'POST',
                    url: resolveWixDealerOffersServingApiV1DealerOffersDebugUrl({
                        protoPath: '/v1/dealer/debug/offers/{offerId}/debug',
                        data: serializedData,
                        host: host,
                    }),
                    data: serializedData,
                },
            ],
        };
        return metadata;
    }
    __debugOffer.fromReq = fromReq;
    __debugOffer.__isAmbassador = true;
    return __debugOffer;
}
exports.debugOffer = debugOffer;
/** Get a single offer with creative. */
function getOffer(payload) {
    var _a = (0, ambassador_1.serializer)(_getOfferRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_getOfferResponse, { _offer: _offer }).fromJSON;
    function __getOffer(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.dealer.v1.serving_offer',
            method: 'GET',
            methodFqn: 'wix.dealerOffersServing.api.v1.DealerOffersDebug.GetOffer',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixDealerOffersServingApiV1DealerOffersDebugUrl({
                protoPath: '/v1/dealer/debug/offer/{offerId}',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData),
            transformResponse: fromRes,
        };
        return metadata;
    }
    __getOffer.fromReq = fromReq;
    __getOffer.__isAmbassador = true;
    return __getOffer;
}
exports.getOffer = getOffer;
/**
 * Get all offers the user or site are eligible for.
 * A realEstateId (placementId) defines the product location of the offers and is always required,
 * Context is taken implicitly from request with authorization header and wix session.
 */
function listOffers(payload) {
    var _a = (0, ambassador_1.serializer)(_listOffersRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_listOffersResponse, { _offer: _offer }).fromJSON;
    function __listOffers(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.dealer.v1.serving_offer',
            method: 'GET',
            methodFqn: 'wix.dealerOffersServing.api.v1.DealerOffersServing.ListOffers',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                protoPath: '/v1/dealer/serving/offers',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData, true),
            transformResponse: fromRes,
            fallback: [
                {
                    method: 'POST',
                    url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                        protoPath: '/v1/dealer/serving/offers/list',
                        data: serializedData,
                        host: host,
                    }),
                    data: serializedData,
                },
            ],
        };
        return metadata;
    }
    __listOffers.fromReq = fromReq;
    __listOffers.__isAmbassador = true;
    return __listOffers;
}
exports.listOffers = listOffers;
/**
 * Get a single offer if the user or site are eligible for.
 * Context is taken implicitly from request with authorization header and wix session.
 */
function resolveOffer(payload) {
    var _a = (0, ambassador_1.serializer)(_resolveOfferRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_resolveOfferResponse, { _offer: _offer }).fromJSON;
    function __resolveOffer(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.dealer.v1.serving_offer',
            method: 'GET',
            methodFqn: 'wix.dealerOffersServing.api.v1.DealerOffersServing.ResolveOffer',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                protoPath: '/v1/dealer/serving/offer/resolve',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData),
            transformResponse: fromRes,
            fallback: [
                {
                    method: 'POST',
                    url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                        protoPath: '/v1/dealer/serving/offer/resolve',
                        data: serializedData,
                        host: host,
                    }),
                    data: serializedData,
                },
            ],
        };
        return metadata;
    }
    __resolveOffer.fromReq = fromReq;
    __resolveOffer.__isAmbassador = true;
    return __resolveOffer;
}
exports.resolveOffer = resolveOffer;
/**
 * Get all offers the user or site are eligible for.
 * This is a bulk request for more then one realEstate (placement),
 * max limit of 30 offers is applied for each placement.
 * Context is taken implicitly from request with authorization header and wix session.
 */
function listOffersBulk(payload) {
    var _a = (0, ambassador_1.serializer)(_listOffersBulkRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_listOffersBulkResponse, {
        _listOffersResponse: _listOffersResponse,
        _offer: _offer,
    }).fromJSON;
    function __listOffersBulk(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.dealer.v1.serving_offer',
            method: 'GET',
            methodFqn: 'wix.dealerOffersServing.api.v1.DealerOffersServing.ListOffersBulk',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                protoPath: '/v1/dealer/serving/offers/bulk',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData),
            transformResponse: fromRes,
            fallback: [
                {
                    method: 'POST',
                    url: resolveWixDealerOffersServingApiV1DealerOffersServingUrl({
                        protoPath: '/v1/dealer/serving/offers/bulk',
                        data: serializedData,
                        host: host,
                    }),
                    data: serializedData,
                },
            ],
        };
        return metadata;
    }
    __listOffersBulk.fromReq = fromReq;
    __listOffersBulk.__isAmbassador = true;
    return __listOffersBulk;
}
exports.listOffersBulk = listOffersBulk;
//# sourceMappingURL=http.impl.js.map