total_1ère
This commit is contained in:
123
controllers/concert_annuel/weez_concertController.js
Normal file
123
controllers/concert_annuel/weez_concertController.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////
|
||||
// FICHIER DE TEST
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// LOGGING
|
||||
/////////////////////////////////////////////////
|
||||
const logger = require("../../public/js/app/logger_concert");
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// APPELS DES MODULES
|
||||
/////////////////////////////////////////////////
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
// CALCUL DE DATE
|
||||
const moment = require('moment');
|
||||
// ENVOIE MAIL GOOGLE MAIL
|
||||
const nodemailer = require('nodemailer');
|
||||
// CONNECTION BASE DE DONNÉES
|
||||
const mysql = require('mysql2');
|
||||
const mysql_promise = require('mysql2/promise');
|
||||
|
||||
// ADOBE PDF
|
||||
const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');
|
||||
// FETCH (utile pour nodejs version < 18)
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// APPELS DES FONCTIONS
|
||||
/////////////////////////////////////////////////
|
||||
const sleep = require("./../../modules/sleep");
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// FILE NAME
|
||||
////////////////////////////////////////////////////
|
||||
const filename = path.parse(__filename).base;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// CONNECTION DB
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// ENVOIE DES PARTICIPANTS A WEEZEVENT
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
const weez_envoie = async function(req, res) {
|
||||
logger.info("======================================", { label: filename });
|
||||
logger.info("======== FUNCTION weez_envoie ==========", { label: filename });
|
||||
logger.info("======================================", { label: filename });
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// CONNEXION WEEZEVENT
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
let participants = {
|
||||
"participants": [
|
||||
{
|
||||
"id_evenement": 1012995,
|
||||
"id_billet": 3742939,
|
||||
"email": "julie@parisweb.art",
|
||||
"nom": "nomjuju",
|
||||
"prenom": "prenomjuju",
|
||||
"notify": true
|
||||
}
|
||||
],
|
||||
"return_ticket_url": true
|
||||
};
|
||||
|
||||
|
||||
// envoyer participant
|
||||
//let TICKETING_API_BASE_URL = "https://api.weezevent.com/v3/participants?";
|
||||
//let url = TICKETING_API_BASE_URL;
|
||||
body = '&api_key=' + process.env.weezevent_API_KEY;
|
||||
body += '&access_token=' + process.env.weezevent_TOKEN;
|
||||
body += '&data=' + JSON.stringify(participants);
|
||||
//logger.info("url = " + url , { numsession: req.session.id, label: filename});
|
||||
let headers = {'content-type':'application/x-www-form-urlencoded;charset=utf-8'};
|
||||
//let premise_post_token = await fetch(url, {
|
||||
// method: 'POST',
|
||||
// headers: headers,
|
||||
// body: body
|
||||
//});
|
||||
//let response_post_token = await premise_post_token.json();
|
||||
//console.log("response_post_token = ", response_post_token);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//url = 'https://api.weezevent.com/events?api_key=' + process.env.weezevent_API_KEY + '&access_token=' + process.env.weezevent_TOKEN;
|
||||
url = 'https://api.weezevent.com/tickets?api_key=' + process.env.weezevent_API_KEY + '&access_token=' + process.env.weezevent_TOKEN + '&id_event[]=1043050';
|
||||
//url = 'https://api.weezevent.com/participant/list?api_key=' + process.env.weezevent_API_KEY + '&access_token=' + process.env.weezevent_TOKEN + '&id_event[]=1012995';
|
||||
//url = 'https://api.weezevent.com/participant/286254615/answers?api_key=' + process.env.weezevent_API_KEY + '&access_token=' + process.env.weezevent_TOKEN;
|
||||
console.log("url = ", url);
|
||||
let premise_post_ticket = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: headers
|
||||
});
|
||||
let response_post_ticket = await premise_post_ticket.json();
|
||||
console.log("response_post_ticket = ", response_post_ticket);
|
||||
//console.log("response_post_ticket = ", response_post_ticket.participants[10].owner);
|
||||
console.log("response_post_ticket = ", response_post_ticket.events[0].tickets);
|
||||
|
||||
|
||||
req.session.message2 = "on est dans fonction weez_envoie ";
|
||||
res.redirect('/concert/maj_googlesheet');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// EXPORT DES MODULES POUR QU'ILS PUISSENT LUS PAR LES AUTRES FICHIERS JS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
module.exports = {
|
||||
weez_envoie
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user