<commit_before>const Client = require('node-rest-client').Client;
const faker = require('faker');

//User & Patient data generated by faker
const firstName = faker.name.firstName().toLowerCase();
const lastName = faker.name.lastName().toLowerCase();
const phoneNumber = faker.phone.phoneNumberFormat().split('-').join('');
const email = firstName + "@<EMAIL>";
const password = "<PASSWORD>!";
const doctorEmail = "<EMAIL>";
const access = ["read","write","default"];

//URL's
const authUrl = "http://localhost:4000/api/v1/auth/login";
const patientsUrl = "http://localhost:5000/v1/patients";
const createUserUrl = "http://localhost:5000/v1/user";
const messagingUrl = "http://localhost:4001/api/v1/threads";
var authToken = '<KEY>';
const client = new Client();


const createUser = function(userArgs, callback) {
    client.post(createUserUrl, userArgs, function (data, response) {
        callback(data);
    });
};
const authenticateUser = function(authArgs, callback) {
    client.post(authUrl, authArgs, function (data, response) {
        callback(data.token);
    });

};
const createPatient = function(patientArgs, callback) {
    client.post(patientsUrl, patientArgs, function (data, response) {
        callback(data);
    });
};
const createThread = function(threadArgs, callback) {
    client.post(messagingUrl, threadArgs, function (data, response) {
        callback(data.message);
    });
};
const replyToThread = function(threadArgs, threadID, callback) {
    client.post(`${messagingUrl}/${threadID}/reply`, threadArgs, function (data, response) {
        callback(data.message);
    });
};
const getPatients = function(patientArgs, callback) {
    client.get(patientsUrl, patientArgs, function (data, response) {
        callback(data);
    });
};
const sharePatient = function(patientArgs, patientId, callback) {
    client.post(`${patientsUrl}/${patientId}/shares`, patientArgs, function (data, response) {
        callback(data);
    });
};
const createDoctor = function(doctorArgs, patientId, callback) {
    client.post(`${patientsUrl}/${patientId}/doctors`, doctorArgs, function (data, response) {
        callback(data);
    });
};


const userArgs = {
    headers: { "Content-Type": "application/json", "X-Client-Secret" : "testsecret" },
    data: {
        "email": email,
        "password": password,
        "first_name": firstName,
        "last_name": lastName,
        "phone": phoneNumber,
        "role": "user"
    }
};
const authArgs = {
    headers : {"Content-Type": "application/json", "X-Client-Secret" : "testsecret"},
    data: {
        "username":     email,
        "password":  password
    }
};


const seedMessages = function (patientArgs) {
    //data for a new user to be included in the message thread
    const firstName2 = faker.name.firstName();
    const lastName2 = faker.name.lastName();
    const phoneNumber2 = faker.phone.phoneNumberFormat().split('-').join('');
    const email2 = firstName2+"<EMAIL>";
    const password2 = "<PASSWORD>!";
    var authToken2 = '';
    var threadID = null;

    const newUserArgs = {
        headers: { "Content-Type": "application/json", "X-Client-Secret" : "testsecret" },
        data: {
            "email": email2,
            "password": <PASSWORD>,
            "first_name": firstName2,
            "last_name": lastName2,
            "phone": phoneNumber2,
            "role": "user"
        }
    };
    const authArgs = {
        headers : {"Content-Type": "application/json", "X-Client-Secret" : "testsecret"},
        data: {
            "username":     email2,
            "password":  <PASSWORD>
        }
    };
    const createThreadArgs = {
        headers: {"Content-Type": "application/json", "Authorization":"Bearer "+authToken},
        data: {
            "participants": [email, email2],
            "message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pellentesque velit quis urna finibus, at dapibus orci sagittis. Sed gravida, metus id elementum efficitur, urna enim mattis augue, nec ornare velit sem dapibus urna.",
            "topic": `${firstName2}'s log`,
        }
    };
    var respondToThreadArgs = {<commit_msg>add in notifications test<commit_after>const Client = require('node-rest-client').Client;
const faker = require('faker');

//Notification Service Admin User Credentials
const adminUsername = "oucuYaiN6pha3ahphiiT";
const adminPassword = <PASSWORD>";

//User & Patient data generated by faker
const firstName = faker.name.firstName().toLowerCase();
const lastName = faker.name.lastName().toLowerCase();
const phoneNumber = faker.phone.phoneNumberFormat().split('-').join('');
const email = firstName + "@amida.com";
const password = "<PASSWORD>!";
const doctorEmail = "<EMAIL>";
const access = ["read","write","default"];

//URL's
const authUrl = "http://localhost:4000/api/v1/auth/login";
const patientsUrl = "http://localhost:5000/v1/patients";
const createUserUrl = "http://localhost:5000/v1/user";
const messagingUrl = "http://localhost:4001/api/v1/threads";
const notificationsUrl = "http://localhost:4003/api//notifications/sendPushNotifications";
var authToken = '<KEY>';
const client = new Client();


const createUser = function(userArgs, callback) {
    client.post(createUserUrl, userArgs, function (data, response) {
        callback(data);
    });
};
const authenticateUser = function(authArgs, callback) {
    client.post(authUrl, authArgs, function (data, response) {
        callback(data.token);
    });

};
const createPatient = function(patientArgs, callback) {
    client.post(patientsUrl, patientArgs, function (data, response) {
        callback(data);
    });
};
const createThread = function(threadArgs, callback) {
    client.post(messagingUrl, threadArgs, function (data, response) {
        callback(data.message);
    });
};
const replyToThread = function(threadArgs, threadID, callback) {
    client.post(`${messagingUrl}/${threadID}/reply`, threadArgs, function (data, response) {
        callback(data.message);
    });
};
const getPatients = function(patientArgs, callback) {
    client.get(patientsUrl, patientArgs, function (data, response) {
        callback(data);
    });
};
const sharePatient = function(patientArgs, patientId, callback) {
    client.post(`${patientsUrl}/${patientId}/shares`, patientArgs, function (data, response) {
        callback(data);
    });
};
const createDoctor = function(doctorArgs, patientId, callback) {
    client.post(`${patientsUrl}/${patientId}/doctors`, doctorArgs, function (data, response) {
        callback(data);
    });
};
const notifyUser = function(notificationArgs, callback) {
    client.post(notificationsUrl, notificationArgs, function (data, response) {
        callback(data);
    });
};


const userArgs = {
    headers: { "Content-Type": "application/json", "X-Client-Secret" : "testsecret" },
    data: {
        "email": email,
        "password": password,
        "first_name": firstName,
        "last_name": lastName,
        "phone": phoneNumber,
        "role": "user"
    }
};
const authArgs = {
    headers : {"Content-Type": "application/json", "X-Client-Secret" : "testsecret"},
    data: {
        "username":     email,
        "password":  password
    }
};


const sendNotification = function () {
    const adminAuthArgs = {
        headers : {"Content-Type": "application/json", "X-Client-Secret" : "testsecret"},
        data: {
            "username": adminUsername,
            "password": <PASSWORD>
        }
    };
    
    authenticateUser(adminAuthArgs, function (response) {
        authToken = response;
        const notificationArgs = {
            headers : {"Content-Type": "application/json", "Authorization":"Bearer "+authToken},
            data: {
                "pushData": [{ 
                        "username": email,
                        "notificationType": "New Message",
                        "data": {
                            "title": `${email} sent you a message`,
                            "body": "Test message"
                        }
                    }]
            }
        };
        notifyUser(notificationArgs, function (data, response) {
            console.log("Notification data:", data);
        });
    });

}

const seedMessages = function (patientArgs) {
    //data for a new user to be included in the message thread
    const firstName2 = faker.name.firstName();
    const lastName2 = faker.name.lastName();
    const phoneNumber2 = faker.phone.phoneNumberFormat().split('-').join('');
    const email2 = <EMAIL>2+"<EMAIL>";
    const password2 = "<PASSWORD>!";
    var authToken2 = '';
    var threadID = null;
    sendNotification();

    const newUserArgs = {
        headers: { "Content-Type": "application/json", "X-Client-Secret" : "testsecret" },
        data: {
            "email": email2,
            "password": <PASSWORD>,
            "first_name": firstName2,
            "last_name": lastName2,
            "phone": phoneNumber2,
            "role": "user"
        }
    };
    const authArgs = {
        headers : {"Content-Type": "application/json", "X-Client-Secret" : "testsecret"},
        data: {
            "username":     email2,
            "password":  <PASSWORD>
        }
    };
    const createThreadArgs = {
        headers: {"Content-Type": "application/json", "Authorization":"Bearer "+authToken},
        data: {
            "participants": [email, email2],
            "message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pellentesque velit quis urna finibus, at dapibus orci sagittis. Sed gravida, metus id elementum efficitur, urna enim mattis augue, nec ornare velit sem dapibus urna.",
            "topic": `${firstName2}'s log`,
        }
    };
    var respondToThreadArgs = {
{'fraction_non_alphanumeric': 0.14755773554056817, 'fraction_numerical': 0.007561823012466789, 'mean_word_length': 2.9881825590872046, 'pattern_counts': {'":': 61, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3163664', 'n_tokens_mistral': 2892, 'n_tokens_neox': 2812, 'n_words': 655}