"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageInput$outboundSchema = exports.Message$inboundSchema = exports.ErrorT$inboundSchema = exports.Price$inboundSchema = exports.MessageStatus$inboundSchema = exports.Direction$inboundSchema = exports.MessageType$outboundSchema = exports.MessageType$inboundSchema = exports.MessageStatus = exports.Direction = exports.MessageType = void 0;
exports.priceFromJSON = priceFromJSON;
exports.errorFromJSON = errorFromJSON;
exports.messageFromJSON = messageFromJSON;
exports.messageInputToJSON = messageInputToJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const currency_js_1 = require("./currency.js");
const passthroughbody_js_1 = require("./passthroughbody.js");
/**
 * Set to sms for SMS messages and mms for MMS messages.
 */
exports.MessageType = {
    Sms: "sms",
    Mms: "mms",
};
/**
 * The direction of the message.
 */
exports.Direction = {
    Inbound: "inbound",
    OutboundApi: "outbound-api",
    OutboundCall: "outbound-call",
    OutboundReply: "outbound-reply",
    Unknown: "unknown",
};
/**
 * Status of the delivery of the message.
 */
exports.MessageStatus = {
    Accepted: "accepted",
    Scheduled: "scheduled",
    Canceled: "canceled",
    Queued: "queued",
    Sending: "sending",
    Sent: "sent",
    Failed: "failed",
    Delivered: "delivered",
    Undelivered: "undelivered",
    Receiving: "receiving",
    Received: "received",
    Read: "read",
};
/** @internal */
exports.MessageType$inboundSchema = z
    .nativeEnum(exports.MessageType);
/** @internal */
exports.MessageType$outboundSchema = exports.MessageType$inboundSchema;
/** @internal */
exports.Direction$inboundSchema = z
    .nativeEnum(exports.Direction);
/** @internal */
exports.MessageStatus$inboundSchema = z.nativeEnum(exports.MessageStatus);
/** @internal */
exports.Price$inboundSchema = z
    .object({
    per_unit: z.string().optional(),
    total_amount: z.string().optional(),
    currency: z.nullable(currency_js_1.Currency$inboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "per_unit": "perUnit",
        "total_amount": "totalAmount",
    });
});
function priceFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Price$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Price' from JSON`);
}
/** @internal */
exports.ErrorT$inboundSchema = z
    .object({
    code: z.string().optional(),
    message: z.string().optional(),
});
function errorFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.ErrorT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ErrorT' from JSON`);
}
/** @internal */
exports.Message$inboundSchema = z.object({
    id: z.string().optional(),
    from: z.string(),
    to: z.string(),
    subject: z.string().optional(),
    body: z.string(),
    type: exports.MessageType$inboundSchema.optional(),
    number_of_units: z.number().int().optional(),
    number_of_media_files: z.number().int().optional(),
    direction: exports.Direction$inboundSchema.optional(),
    status: exports.MessageStatus$inboundSchema.optional(),
    scheduled_at: z.string().datetime({ offset: true }).transform(v => new Date(v)).optional(),
    sent_at: z.string().datetime({ offset: true }).transform(v => new Date(v))
        .optional(),
    webhook_url: z.string().optional(),
    reference: z.string().optional(),
    price: z.lazy(() => exports.Price$inboundSchema).optional(),
    error: z.lazy(() => exports.ErrorT$inboundSchema).optional(),
    messaging_service_id: z.string().optional(),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    updated_by: z.nullable(z.string()).optional(),
    created_by: z.nullable(z.string()).optional(),
    updated_at: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    created_at: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    pass_through: z.array(passthroughbody_js_1.PassThroughBody$inboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "number_of_units": "numberOfUnits",
        "number_of_media_files": "numberOfMediaFiles",
        "scheduled_at": "scheduledAt",
        "sent_at": "sentAt",
        "webhook_url": "webhookUrl",
        "messaging_service_id": "messagingServiceId",
        "custom_mappings": "customMappings",
        "updated_by": "updatedBy",
        "created_by": "createdBy",
        "updated_at": "updatedAt",
        "created_at": "createdAt",
        "pass_through": "passThrough",
    });
});
function messageFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Message$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Message' from JSON`);
}
/** @internal */
exports.MessageInput$outboundSchema = z.object({
    from: z.string(),
    to: z.string(),
    subject: z.string().optional(),
    body: z.string(),
    type: exports.MessageType$outboundSchema.optional(),
    scheduledAt: z.date().transform(v => v.toISOString()).optional(),
    webhookUrl: z.string().optional(),
    reference: z.string().optional(),
    messagingServiceId: z.string().optional(),
    passThrough: z.array(passthroughbody_js_1.PassThroughBody$outboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        scheduledAt: "scheduled_at",
        webhookUrl: "webhook_url",
        messagingServiceId: "messaging_service_id",
        passThrough: "pass_through",
    });
});
function messageInputToJSON(messageInput) {
    return JSON.stringify(exports.MessageInput$outboundSchema.parse(messageInput));
}
//# sourceMappingURL=message.js.map