Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
WIKIPEDIA
/
nodejs
/
Notifications_Imali_API
/
src
/
models
:
Push.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
const Joi = require("joi"); const env = process.env; class Push { constructor(title,message){ // if(fire_token.length === 1) // this.to=fire_token[0];h // else // this.registration_ids=fire_token; this.notification=new NotificationConf(title,message); this.data=new PushData(message) } static validate(body){ return Joi.object({ to:Joi.array().required(), subject:Joi.string().required().max(30), message:Joi.string().required().max(500), }).validate(body); } } class NotificationConf{ constructor(subject,message){ this.icon = 'ic_i_mali_cover'; this.click_action ='com.imali.payapp.payment_NOTICIA'; this.color ='#ffffff'; this.title=subject; this.body=message; } } class PushData{ constructor(message){ this.sms = message; this.terminal ='firebase'; } } class PushConf{ constructor(){ this.responseType='json'; this.headers = { 'Authorization': `key=${env.PUSH_AUTHORIZATION_TOKEN}`, 'Content-Type': 'application/json', 'Accept':'application/json' } } } module.exports={Push,PushConf};