Compare commits
No commits in common. "990c6457fe8e1f416c82d6d7c94c49184ad9a03f" and "a7847185fd084126306e4eed4dc0fc13e87690ac" have entirely different histories.
990c6457fe
...
a7847185fd
|
|
@ -28,10 +28,6 @@ const setApiPricing = async (req, res) => {
|
||||||
|
|
||||||
let filter = { provider: normalizedProvider, product: normalizedProduct }
|
let filter = { provider: normalizedProvider, product: normalizedProduct }
|
||||||
|
|
||||||
if(format){
|
|
||||||
filter = {...filter, format}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type) {
|
if (type) {
|
||||||
filter = { ...filter, type }
|
filter = { ...filter, type }
|
||||||
}
|
}
|
||||||
|
|
@ -201,8 +197,7 @@ const registerUsage = async (req, res) => {
|
||||||
callerId,
|
callerId,
|
||||||
sessionId,
|
sessionId,
|
||||||
companyId,
|
companyId,
|
||||||
format,
|
format
|
||||||
usedTo
|
|
||||||
|
|
||||||
} = req.body
|
} = req.body
|
||||||
|
|
||||||
|
|
@ -218,7 +213,6 @@ const registerUsage = async (req, res) => {
|
||||||
const apiPricing = await API_Pricing.findOne({
|
const apiPricing = await API_Pricing.findOne({
|
||||||
provider: provider.trim().toLowerCase(),
|
provider: provider.trim().toLowerCase(),
|
||||||
product: product.trim().toLowerCase(),
|
product: product.trim().toLowerCase(),
|
||||||
format: format?.trim().toLowerCase()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (apiPricing) {
|
if (apiPricing) {
|
||||||
|
|
@ -236,8 +230,7 @@ const registerUsage = async (req, res) => {
|
||||||
billingUnit,
|
billingUnit,
|
||||||
companyId,
|
companyId,
|
||||||
total_cost: calculateApiUsage(price, billingUnit, usage),
|
total_cost: calculateApiUsage(price, billingUnit, usage),
|
||||||
format,
|
format
|
||||||
usedTo
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.status(StatusCodes.OK).json({ apiUsage })
|
return res.status(StatusCodes.OK).json({ apiUsage })
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
const mongoose = require("../db/connect");
|
const mongoose = require('../db/connect')
|
||||||
|
|
||||||
const { Schema } = mongoose;
|
const { Schema } = mongoose
|
||||||
|
|
||||||
const apiUsage = new Schema(
|
const apiUsage = new Schema({
|
||||||
{
|
|
||||||
companyId: {
|
companyId: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
@ -26,11 +25,11 @@ const apiUsage = new Schema(
|
||||||
},
|
},
|
||||||
usage: {
|
usage: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true
|
||||||
},
|
},
|
||||||
price: {
|
price: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true
|
||||||
},
|
},
|
||||||
billingBy: {
|
billingBy: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
@ -38,24 +37,15 @@ const apiUsage = new Schema(
|
||||||
},
|
},
|
||||||
billingUnit: {
|
billingUnit: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true
|
||||||
},
|
},
|
||||||
total_cost: {
|
total_cost: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true
|
||||||
},
|
}
|
||||||
format: {
|
|
||||||
type: String,
|
|
||||||
enum: ["text", "audio", "image", "video"],
|
|
||||||
},
|
|
||||||
usedTo: {
|
|
||||||
type: String,
|
|
||||||
enum: ["stt", "llm", "tts"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ timestamps: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
const API_Usage = mongoose.model("API_Usage", apiUsage);
|
}, { timestamps: true })
|
||||||
|
|
||||||
module.exports = API_Usage;
|
const API_Usage = mongoose.model('API_Usage', apiUsage)
|
||||||
|
|
||||||
|
module.exports = API_Usage
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue