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

View File

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