"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeODataError = exports.serializeMainError = exports.serializeInnerError = exports.serializeErrorDetails = exports.deserializeIntoODataError = exports.deserializeIntoMainError = exports.deserializeIntoInnerError = exports.deserializeIntoErrorDetails = exports.createODataErrorFromDiscriminatorValue = exports.createMainErrorFromDiscriminatorValue = exports.createInnerErrorFromDiscriminatorValue = exports.createErrorDetailsFromDiscriminatorValue = void 0;
/**
 * Creates a new instance of the appropriate class based on discriminator value
 * @param parseNode The parse node to use to read the discriminator value and create the object
 * @returns a ErrorDetails
 */
function createErrorDetailsFromDiscriminatorValue(parseNode) {
    return deserializeIntoErrorDetails;
}
exports.createErrorDetailsFromDiscriminatorValue = createErrorDetailsFromDiscriminatorValue;
/**
 * Creates a new instance of the appropriate class based on discriminator value
 * @param parseNode The parse node to use to read the discriminator value and create the object
 * @returns a InnerError
 */
function createInnerErrorFromDiscriminatorValue(parseNode) {
    return deserializeIntoInnerError;
}
exports.createInnerErrorFromDiscriminatorValue = createInnerErrorFromDiscriminatorValue;
/**
 * Creates a new instance of the appropriate class based on discriminator value
 * @param parseNode The parse node to use to read the discriminator value and create the object
 * @returns a MainError
 */
function createMainErrorFromDiscriminatorValue(parseNode) {
    return deserializeIntoMainError;
}
exports.createMainErrorFromDiscriminatorValue = createMainErrorFromDiscriminatorValue;
/**
 * Creates a new instance of the appropriate class based on discriminator value
 * @param parseNode The parse node to use to read the discriminator value and create the object
 * @returns a ODataError
 */
function createODataErrorFromDiscriminatorValue(parseNode) {
    return deserializeIntoODataError;
}
exports.createODataErrorFromDiscriminatorValue = createODataErrorFromDiscriminatorValue;
/**
 * The deserialization information for the current model
 * @returns a Record<string, (node: ParseNode) => void>
 */
function deserializeIntoErrorDetails(errorDetails = {}) {
    return {
        "backingStoreEnabled": n => { errorDetails.backingStoreEnabled = true; },
        "code": n => { errorDetails.code = n.getStringValue(); },
        "message": n => { errorDetails.message = n.getStringValue(); },
        "target": n => { errorDetails.target = n.getStringValue(); },
    };
}
exports.deserializeIntoErrorDetails = deserializeIntoErrorDetails;
/**
 * The deserialization information for the current model
 * @returns a Record<string, (node: ParseNode) => void>
 */
function deserializeIntoInnerError(innerError = {}) {
    return {
        "backingStoreEnabled": n => { innerError.backingStoreEnabled = true; },
        "client-request-id": n => { innerError.clientRequestId = n.getStringValue(); },
        "date": n => { innerError.date = n.getDateValue(); },
        "@odata.type": n => { innerError.odataType = n.getStringValue(); },
        "request-id": n => { innerError.requestId = n.getStringValue(); },
    };
}
exports.deserializeIntoInnerError = deserializeIntoInnerError;
/**
 * The deserialization information for the current model
 * @returns a Record<string, (node: ParseNode) => void>
 */
function deserializeIntoMainError(mainError = {}) {
    return {
        "backingStoreEnabled": n => { mainError.backingStoreEnabled = true; },
        "code": n => { mainError.code = n.getStringValue(); },
        "details": n => { mainError.details = n.getCollectionOfObjectValues(createErrorDetailsFromDiscriminatorValue); },
        "innerError": n => { mainError.innerError = n.getObjectValue(createInnerErrorFromDiscriminatorValue); },
        "message": n => { mainError.message = n.getStringValue(); },
        "target": n => { mainError.target = n.getStringValue(); },
    };
}
exports.deserializeIntoMainError = deserializeIntoMainError;
/**
 * The deserialization information for the current model
 * @returns a Record<string, (node: ParseNode) => void>
 */
function deserializeIntoODataError(oDataError = {}) {
    return {
        "backingStoreEnabled": n => { oDataError.backingStoreEnabled = true; },
        "error": n => { var _a, _b; oDataError.errorEscaped = n.getObjectValue(createMainErrorFromDiscriminatorValue); oDataError.message = (_b = (_a = oDataError.errorEscaped) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : ""; },
    };
}
exports.deserializeIntoODataError = deserializeIntoODataError;
/**
 * Serializes information the current object
 * @param writer Serialization writer to use to serialize this model
 */
function serializeErrorDetails(writer, errorDetails = {}) {
    writer.writeStringValue("code", errorDetails.code);
    writer.writeStringValue("message", errorDetails.message);
    writer.writeStringValue("target", errorDetails.target);
    writer.writeAdditionalData(errorDetails.additionalData);
}
exports.serializeErrorDetails = serializeErrorDetails;
/**
 * Serializes information the current object
 * @param writer Serialization writer to use to serialize this model
 */
function serializeInnerError(writer, innerError = {}) {
    writer.writeStringValue("client-request-id", innerError.clientRequestId);
    writer.writeDateValue("date", innerError.date);
    writer.writeStringValue("@odata.type", innerError.odataType);
    writer.writeStringValue("request-id", innerError.requestId);
    writer.writeAdditionalData(innerError.additionalData);
}
exports.serializeInnerError = serializeInnerError;
/**
 * Serializes information the current object
 * @param writer Serialization writer to use to serialize this model
 */
function serializeMainError(writer, mainError = {}) {
    writer.writeStringValue("code", mainError.code);
    writer.writeCollectionOfObjectValues("details", mainError.details, serializeErrorDetails);
    writer.writeObjectValue("innerError", mainError.innerError, serializeInnerError);
    writer.writeStringValue("message", mainError.message);
    writer.writeStringValue("target", mainError.target);
    writer.writeAdditionalData(mainError.additionalData);
}
exports.serializeMainError = serializeMainError;
/**
 * Serializes information the current object
 * @param writer Serialization writer to use to serialize this model
 */
function serializeODataError(writer, oDataError = {}) {
    writer.writeObjectValue("error", oDataError.errorEscaped, serializeMainError);
    writer.writeAdditionalData(oDataError.additionalData);
}
exports.serializeODataError = serializeODataError;
/* tslint:enable */
/* eslint-enable */
