"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteUserDefinedFields = exports.deleteByWhiteListedMetaSite = exports.listDataExtensionSchemas = exports.updateDataExtensionSchema = exports.createDataExtensionSchema = 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 _createDataExtensionSchemaRequest = {
    dataExtensionSchema: '_dataExtensionSchema',
};
var _createDataExtensionSchemaResponse = {
    dataExtensionSchema: '_dataExtensionSchema',
};
var _dataExtensionSchema = {
    updatedDate: 'google.protobuf.Timestamp',
    createdDate: 'google.protobuf.Timestamp',
};
var _deleteByWhiteListedMetaSiteRequest = {};
var _deleteByWhiteListedMetaSiteResponse = {};
var _deleteUserDefinedFieldsRequest = {};
var _deleteUserDefinedFieldsResponse = {
    dataExtensionSchema: '_dataExtensionSchema',
};
var _listDataExtensionSchemasRequest = {};
var _listDataExtensionSchemasResponse = {
    dataExtensionSchemas: '_dataExtensionSchema',
};
var _updateDataExtensionSchemaRequest = {
    dataExtensionSchema: '_dataExtensionSchema',
};
var _updateDataExtensionSchemaResponse = {
    dataExtensionSchema: '_dataExtensionSchema',
};
function resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl(opts) {
    var domainToMappings = {
        'manage._base_domain_': [
            {
                srcPath: '/schema-service',
                destPath: '',
            },
        ],
        _: [
            {
                srcPath: '/_api/schema-service',
                destPath: '',
            },
        ],
        'editor.wixapps.net': [
            {
                srcPath: '/_api/schema-service',
                destPath: '',
            },
        ],
        'www.wixapis.com': [
            {
                srcPath: '/schema-service',
                destPath: '',
            },
        ],
        '*.dev.wix-code.com': [
            {
                srcPath: '/schema-service',
                destPath: '',
            },
        ],
    };
    return (0, metro_runtime_2.resolveUrl)(Object.assign(opts, { domainToMappings: domainToMappings }));
}
/** Creates a user-defined data extension schema. */
function createDataExtensionSchema(payload) {
    var _a = (0, ambassador_1.serializer)(_createDataExtensionSchemaRequest, { _dataExtensionSchema: _dataExtensionSchema }), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_createDataExtensionSchemaResponse, {
        _dataExtensionSchema: _dataExtensionSchema,
    }).fromJSON;
    function __createDataExtensionSchema(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data_extensions.v1.data_extension_schema',
            method: 'POST',
            methodFqn: 'wix.infra.dataextensions.v1.DataExtensionSchemaService.CreateDataExtensionSchema',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl({
                protoPath: '/v1/schemas',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __createDataExtensionSchema.fromReq = fromReq;
    __createDataExtensionSchema.__isAmbassador = true;
    return __createDataExtensionSchema;
}
exports.createDataExtensionSchema = createDataExtensionSchema;
/** Updates a user-defined data extension schema, overriding the existing data. */
function updateDataExtensionSchema(payload) {
    var _a = (0, ambassador_1.serializer)(_updateDataExtensionSchemaRequest, { _dataExtensionSchema: _dataExtensionSchema }), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_updateDataExtensionSchemaResponse, {
        _dataExtensionSchema: _dataExtensionSchema,
    }).fromJSON;
    function __updateDataExtensionSchema(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data_extensions.v1.data_extension_schema',
            method: 'PUT',
            methodFqn: 'wix.infra.dataextensions.v1.DataExtensionSchemaService.UpdateDataExtensionSchema',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl({
                protoPath: '/v1/schemas',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __updateDataExtensionSchema.fromReq = fromReq;
    __updateDataExtensionSchema.__isAmbassador = true;
    return __updateDataExtensionSchema;
}
exports.updateDataExtensionSchema = updateDataExtensionSchema;
/** Retrieves a list of global and user-defined data extension schemas for a given FQDN. */
function listDataExtensionSchemas(payload) {
    var _a = (0, ambassador_1.serializer)(_listDataExtensionSchemasRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_listDataExtensionSchemasResponse, {
        _dataExtensionSchema: _dataExtensionSchema,
    }).fromJSON;
    function __listDataExtensionSchemas(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data_extensions.v1.data_extension_schema',
            method: 'GET',
            methodFqn: 'wix.infra.dataextensions.v1.DataExtensionSchemaService.ListDataExtensionSchemas',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl({
                protoPath: '/v1/schemas',
                data: serializedData,
                host: host,
            }),
            params: (0, metro_runtime_1.toURLSearchParams)(serializedData),
            transformResponse: fromRes,
        };
        return metadata;
    }
    __listDataExtensionSchemas.fromReq = fromReq;
    __listDataExtensionSchemas.__isAmbassador = true;
    return __listDataExtensionSchemas;
}
exports.listDataExtensionSchemas = listDataExtensionSchemas;
/** Deletes schemas of whitelisted metasite ids */
function deleteByWhiteListedMetaSite(payload) {
    var _a = (0, ambassador_1.serializer)(_deleteByWhiteListedMetaSiteRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_deleteByWhiteListedMetaSiteResponse, {}).fromJSON;
    function __deleteByWhiteListedMetaSite(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data_extensions.v1.data_extension_schema',
            method: 'POST',
            methodFqn: 'wix.infra.dataextensions.v1.DataExtensionSchemaService.DeleteByWhiteListedMetaSite',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl({
                protoPath: '/v1/schemas/delete-by-white-listed-meta-site',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __deleteByWhiteListedMetaSite.fromReq = fromReq;
    __deleteByWhiteListedMetaSite.__isAmbassador = true;
    return __deleteByWhiteListedMetaSite;
}
exports.deleteByWhiteListedMetaSite = deleteByWhiteListedMetaSite;
/** Deletes a user defined field from the specified data extension schema. */
function deleteUserDefinedFields(payload) {
    var _a = (0, ambassador_1.serializer)(_deleteUserDefinedFieldsRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
    var fromRes = (0, ambassador_1.serializer)(_deleteUserDefinedFieldsResponse, {
        _dataExtensionSchema: _dataExtensionSchema,
    }).fromJSON;
    function __deleteUserDefinedFields(_a) {
        var host = _a.host;
        var serializedData = toReq(payload);
        var metadata = {
            entityFqdn: 'wix.data_extensions.v1.data_extension_schema',
            method: 'POST',
            methodFqn: 'wix.infra.dataextensions.v1.DataExtensionSchemaService.DeleteUserDefinedFields',
            migrationOptions: {
                optInTransformResponse: true,
            },
            url: resolveWixInfraDataextensionsV1DataExtensionSchemaServiceUrl({
                protoPath: '/v1/schemas/delete-user-defined-fields',
                data: serializedData,
                host: host,
            }),
            data: serializedData,
            transformResponse: fromRes,
        };
        return metadata;
    }
    __deleteUserDefinedFields.fromReq = fromReq;
    __deleteUserDefinedFields.__isAmbassador = true;
    return __deleteUserDefinedFields;
}
exports.deleteUserDefinedFields = deleteUserDefinedFields;
//# sourceMappingURL=http.impl.js.map