feat: add three new properties to model and update usage controller

main
adriano 2024-08-13 09:26:46 -03:00
parent 54a4f837ce
commit 99259b69a2
2 changed files with 21 additions and 1 deletions

View File

@ -99,11 +99,14 @@ const registerUsage = async (req, res) => {
const registerWhatsappUsage = async (req, res) => { const registerWhatsappUsage = async (req, res) => {
const { const {
companyId, companyId,
companyPhone,
clientPhone,
provider, provider,
product, product,
type, type,
msgId, msgId,
ticketId, ticketId,
ticketUrl,
billable, billable,
pricing_model, pricing_model,
} = req.body } = req.body
@ -116,7 +119,9 @@ const registerWhatsappUsage = async (req, res) => {
'msgId', 'msgId',
'ticketId', 'ticketId',
'billable', 'billable',
'pricing_model' 'pricing_model',
'companyPhone',
'clientPhone',
]) ])
const apiPricing = await API_Pricing.findOne({ const apiPricing = await API_Pricing.findOne({
@ -132,11 +137,14 @@ const registerWhatsappUsage = async (req, res) => {
const apiUsageWhatsapp = await API_Usage_Whatsapp.create({ const apiUsageWhatsapp = await API_Usage_Whatsapp.create({
companyId, companyId,
companyPhone,
clientPhone,
provider: provider.trim().toLowerCase(), provider: provider.trim().toLowerCase(),
product: product.trim().toLowerCase(), product: product.trim().toLowerCase(),
price, price,
msgId, msgId,
ticketId, ticketId,
ticketUrl,
billable, billable,
pricing_model, pricing_model,
type type

View File

@ -7,6 +7,14 @@ const apiUsageWhatsapp = new Schema({
type: String, type: String,
required: true, required: true,
}, },
companyPhone: {
type: String,
required: true,
},
clientPhone: {
type: String,
required: true,
},
msgId: { msgId: {
type: String, type: String,
required: true, required: true,
@ -15,6 +23,10 @@ const apiUsageWhatsapp = new Schema({
type: String, type: String,
required: true, required: true,
}, },
ticketUrl: {
type: String,
required: true,
},
provider: { provider: {
type: String, type: String,
required: true, required: true,