Giter Club home page Giter Club logo

sendmailerts's Introduction

👨‍💻 Bernardo Rizzatti

Github Badge Linkedin Badge

    process.stdout.write('Welcome to my profile')

Languages and Tools:

  • Currently working as Back-End enginner.
  • Techs: Typescript, NodeJs, Go, NestJs, Docker, Kubernets, Elasticsearch, SQL, NOSQL, RabbitMQ.
  • Enthusiast: Clean Architecture.
:octocat:

sendmailerts's People

Watchers

 avatar

sendmailerts's Issues

sip-web

function loadScript(url) {
    return new Promise(function (resolve) {
      const script = document.createElement("script");
      script.type = "text/javascript";
  
      if (script.readyState) {
        // only required for IE <9
        script.onreadystatechange = function () {
          if (
            script.readyState === "loaded" ||
            script.readyState === "complete"
          ) {
            script.onreadystatechange = null;
            resolve();
          }
        };
      } else {
        //Others
        script.onload = function () {
          resolve();
        };
      }
  
      script.src = url;
      document.getElementsByTagName("head")[0].appendChild(script);
    });
  }
  
  var BCSIP;
  var stack;
  var activeCall;
  
  Promise.all([
    loadScript("https://app.brasilconnecting.com.br/bcsip/SIPml-api.js"),
    loadScript(
      `https://app.brasilconnecting.com.br/bcsip/lb_bcsip.php?id_cliente=${sipQueryParams.id_cliente}&peername=${sipQueryParams.peername}&token=ORMVM3HXSDD82NJD95F3`
    ),
  ]).then(function () {
     
  
    keyboardRenderizer();
  });
  
  function muteCall() {
    activeCall.mute();
     document.querySelector(".mutedCall").textContent  = 'Desmutar'
  }
  
  function unmuteCall() {
    activeCall.unmute();
    document.querySelector(".mutedCall").textContent  = 'Mutar'
  }
  
  function toggleMute() {
    activeCall.toggleMute().then((isMuted) => {
      if (isMuted) {
        updateInformationBadge("Chamada mutada");
      } else {
        updateInformationBadge("Chamada em progresso");
      }
    });
  }
  
  function holdCall() {
    activeCall.hold();
  }
  
  function resumeCall() {
    activeCall.resume();
  }
  
  function toggleHold() {
    activeCall.toggleHold().then((isHolded) => {
      if (isHolded) {
        updateInformationBadge("Chamada em espera");
      } else {
        updateInformationBadge("Chamada em progresso");
      }
    });
  }
  
  function hangupCall() {
    activeCall.hangup().then(() => {
     
  
      hangUpCalling()
  
      //chamada finalizada
    });
  }
  
  function makeAudioCall() {
    const phoneNumber = sipQueryParams.destination;
  
    checkPhoneNumber(phoneNumber);
  
    activeCall = BCSIP.createAudioCall(stack, phoneNumber);
  
    startEventSessionListeners();
  
    activeCall.call().then(() => {});
  }
  
  function checkPhoneNumber(phoneNumber) {
    if (!phoneNumber || !phoneNumber.length) {
      return alert("Número inválido!");
    }
  }
  
  function startEventSessionListeners() {
    stack.eventSession.on("connecting", () => {
      updateInformationBadge("Iniciando conexão...");
    });
  
    stack.eventSession.on("i_ao_request", () => {
      updateInformationBadge("Chamando...");
    });
  
    stack.eventSession.on("connected", () => {
      updateInformationBadge("Chamada em progresso");
    });
  
    stack.eventSession.on("m_local_hold_ok", () => {
      updateInformationBadge("Chamada em Espera...");
    });
  
    stack.eventSession.on("m_local_hold_nok", () => {
      updateInformationBadge("Chamada em Espera Falhou!");
  
      setTimeout(() => {
        updateInformationBadge("Chamada em progresso");
      }, 2000);
    });
  
    stack.eventSession.on("m_local_resume_ok", () => {
      updateInformationBadge("Chamada em progesso");
    });
  
    stack.eventSession.on("m_local_resume_nok", () => {
      updateInformationBadge("Retomada à chamada falhou!");
  
      setTimeout(() => {
        updateInformationBadge("Chamada em Espera...");
      }, 2000);
    });
  
    stack.eventSession.on("m_remote_hold", () => {
      updateInformationBadge("Chamada em Espera...");
    });
  
    stack.eventSession.on("m_remote_resume", () => {
      updateInformationBadge("Chamada em progesso");
    });
  
    stack.eventSession.on("o_ect_notify", () => {
      alert("Chamada Transferida");
    });
  
    stack.eventSession.on("terminated", () => {
      updateInformationBadge("Chamada Finalizada");
      
  
  
  
      setTimeout(() => {
        updateInformationBadge("Aguardando comando...");
      }, 2000);
    });
  }
  
  function startEventStackListeners() {
    stack.eventStack.on("m_permission_refused", () => {
      alert("Permissão de mídia negada!");
      updateInformationBadge("Aguardando comando...");
    });
  
    stack.eventStack.on("i_new_call", (receiveCallInterface) => {
      /**
            interface ReceiveCallInterface {
              callSession: any;
              callerName: string;
            }
        */
  
      updateInformationBadge(
        `Recebendo chamada de: ${receiveCallInterface.callerName}`
      );
  
      startEventSessionListeners();
  
      document.getElementById("acceptIncomingCallButton").onclick = () => {
        activeCall = stack.acceptIncomingCall();
  
        updateInformationBadge("Chamada em progresso");
      };
  
      document.getElementById("hangupIncomingCallButton").onclick = () => {
        stack.hangupIncomingCall();
  
        updateInformationBadge("Aguardando comando...");
      };
    });
  
    stack.eventSession.on("terminated", () => {
      hangUpCalling()
    });
  }
  
  function keyPadPress(key) {
    activeCall.keyPadPress(key);
  }
  
  function updateInformationBadge(text) {
    console.log(text);
  }
  
  /* SCOP FOR SIP BUTTON */
  /* init style */
  
  
  let style = document.createElement("style");
  style.innerHTML = `
  
  @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
  
  *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
  }
  
  
  .englobedElements{
      position: relative;
  }
  
  .tallkFunctions{
  
      position: fixed;
      bottom: 0;
      right: 0;
  
  
      margin: 0 20px 2px 0;
  }
  
  #tallkIcon {
      position: relative;
      display: flex;
  
      /*asdasdasdsad*/
  }
  #tallkIcon.disable{
      width: 100px;
      height: 100px;
      background-image: url("https://app.brasilconnecting.com.br/images/img/tallkIcon.svg");
      background-repeat: no-repeat;
  }
  
  
  #tallkIcon.active {
      width: 130px;
      height: 130px;
      margin: 0 -10px 10px 15px;
      background-image: url("https://app.brasilconnecting.com.br/images/img/closeTallkIcon.svg");
  }
  
  
  #tallkIcon .tolip{
  
      background-color: #30A8D8;
  
      
  
      
  
      
      position: absolute;
      right: 130px;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      width: 260px;
      height: 60px;
  
      border-radius: 10px;
  
      -webkit-transition: 0.5s ease-in-out;
    -moz-transition: 0.5s ease-in-out;
    -ms-transition: 0.5s ease-in-out;
    -o-transition: 0.5s ease-in-out;
    transition: 0.5s ease-in-out;
      
  }
  
  
  #tallkIcon .tolip .message{
      font-size: 90.75%;
      font-family: 'Roboto';
      color: white;
      padding: 15px;
  
      display: flex;
      flex-direction: column;
  }
  
  
  #tallkIcon .tallkButtons{
      position: relative;
  
      width: 100px;
      height: 250px;
  
      left: 13px;
      bottom: 240px;
  
      /* border: 1px solid red; */
      display: none;
      flex-direction: column;
      align-items: center;
      animation-name: mymove;
      transition: all 5s ;
  }
  
  .allBtns{
      width: 100%;
      height: 100%;
  
  
      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: center;
  }
  
  .whatsappBtn .WtzpIcon{    
      height: 120px;
      width: 120px;
      background-image: url("https://app.brasilconnecting.com.br/images/img/whats.svg");
  }
  
  .whatsappBtn .tooLip.Whatsapp{
      position: absolute;
  
      display: flex;
      justify-content: flex-start;
      align-items: center;
  
      right: 120px;
  
      width: 230px;
      height: 50px;
      background-color: #40AC3E;
      padding: 13px 20px 13px 13px;
  
      top: 35px;
  
      color: #FFFFFF;
      border-radius: 10px;
  
      font-family: 'Roboto', sans-serif;
      font-weight: 400;
  }
  
  .sipWebBtn .SipWebIcon{
      width: 120px;
      height: 120px;
      background-image: url("https://app.brasilconnecting.com.br/images/img/sipwebCall.svg");
  }
  
  .sipWebBtn .tooLip.sipWeb{
      position: absolute;
  
      display: flex;
      justify-content: flex-start;
      align-items: center;
  
      right: 120px;
  
      width: 230px;
      height: 50px;
      background-color: #0C3545;
      padding: 13px 20px 13px 13px;
  
  
      bottom: 45px;
      
  
      color: #FFFFFF;
      border-radius: 10px;
  
      font-family: 'Roboto', sans-serif;
      font-weight: 400;
  }
  
  /* MODAL*/
  
  .modal-whatsapp{
      position: absolute;
  
     width: 100%;
     height: 100vh;
     
  
     background-color: #3c3c3c;
     opacity: 0.6;
  
     display: none;
     align-items: center;
     justify-content: center;
  }
  
  .container-form{
      width: 40rem;
      height: 25rem;
  
      border-radius: 10px;
  
      background-color: #FFFFFF;
      display: flex;
      justify-content: center;
      flex-direction: column;
  }
  
  .container-form .headerContainer{
      width: 100%;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
  
      /* border: 1px solid red;   */
  }
  
  .container-form .headerContainer img {
      margin: 7px 7px 0 0 ;
  
      cursor: pointer;
  }
  
  
  
  .container-form  .containerForm{
      width: 100%;
      /* border: 1px solid blue; */
      height: 100%;
  
      display: flex;
      justify-content: center;
  }
  
  
  .formBtn {
      width: 80%;
      height: 80%;
  
      margin: 15px;
  
      display: flex;
      /* justify-content: center; */
      flex-direction: column;
  }
  
  .formBtn .whatsappMenssage{
      display: flex;
      height: 70%;
      /* border: 1px solid red; */
  
      align-items: center;
      justify-content: space-around;
      flex-direction: column;
  }
  .formBtn .whatsappMenssage .title-message{
      font-family: 'Roboto', sans-serif;
      font-weight: lighter;
      font-size: 1.4rem;
  }
  
  .formBtn .whatsappMenssage .sub-title{
      font-family: 'Roboto', sans-serif;
      font-weight: lighter;
      font-size: 0.8rem;
  }
  
  .formBtn .whatsappMenssage .icon img {
      cursor: pointer;
  }
  
  .formBtn .title{
      font-family: 'Roboto', sans-serif;
      font-weight: 400;
      font-size: 1.3rem;
  }
  
  .title i {
      color: #40AC3E;;
  }
  
  .formBtn .getDate {
      display: flex;
      flex-direction: column;
      align-items: center;
  
      width: 100%;
      height: 80%;
  
      margin-top: 30px;
  
      /* border: 1px solid red; */
  }
  
  .formBtn .getDate input{
      outline: none;
      
  
      border-color: #3c3c3c;
  
      border-radius: 3px;
      
      border-width: 1px;
  
      
      height: 25px;
  
      width: 50%;
  
      margin: 10px;
  
      padding: 5px;
  
      transition: opacity 0.5;
  }
  
  .formBtn .getDate input:hover{
      opacity: 0.7;
  }
  
  
  .formBtn .getDate button[type="submit"]{
  
      border-radius: 5px;
      border-width: 1px;
  
      width: 120px;    
      height: 40px;
  
      transition: opacity 0.5;
  
      cursor: pointer;
  
      color: #FFFFFF;
  
      background-color: #40AC3E;;
     
  }
  
  .formBtn .getDate button[type="submit"]:hover{
      opacity: 0.7;
  }
  
  
  .sipwebKeyboard.disable{
  
      display: flex; /* SIP AQUI BERNARDO*/
  
      width: 120px;
      height: 120px;
      background-image: url("https://app.brasilconnecting.com.br/images/img/sipwebCall.svg");
  
      background-repeat: no-repeat;
  
      border-radius: 10px;
      -webkit-transition: 0.5s ease-in-out;
    -moz-transition: 0.5s ease-in-out;
    -ms-transition: 0.5s ease-in-out;
    -o-transition: 0.5s ease-in-out;
    transition: 0.5s ease-in-out;
    overflow: hidden;
  }
  
  .sipwebKeyboard.active{
  
      background-color: #0C3545;
  
      display: flex;
      justify-content: center;
      align-items: center;
      width: 15rem;
      height: 18rem;
  
      border-radius: 10px;
      -webkit-transition: 0.5s ease-in-out;
    -moz-transition: 0.5s ease-in-out;
    -ms-transition: 0.5s ease-in-out;
    -o-transition: 0.5s ease-in-out;
    transition: 0.5s ease-in-out;
    overflow: hidden;
  }
  
  .sipwebKeyboard .minimized{
  
      display: flex;
      width: 100px;
      height: 30px;
  
      /* border: 1px solid  red; */
  
      margin-bottom: 10px;
  
  }
  
  .sipwebKeyboard .minimized .min {
     
    display: flex;
    width: 33px;
    height: 10px;
  
    background-color: #1c6480;
    border-radius: 4px;
  
    margin: 10px 0px 0px 13px;
  
    cursor: pointer;
  }
  
  .sipwebKeyboard .keySip{
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100%;
  
      /* border: 1px solid red; */
      /* border: 1px solid red; */
  }
  
  
  .sipwebKeyboard .keySip .minizedSip{
      width: 100%;
      height: 20px;
  
      /* border: 1px solid red; */
  }
  
  .sipwebKeyboard .keySip .minizedSip .minimizedSipWeb{
      width: 30px;
      height: 8px;
  
      margin: 8px 0px 0px 10px;
  
      background-color: #2d88ac;
  
      border-radius: 0.23rem;
  
      cursor: pointer;
  
      display: none;
  }
  
  
  .sipwebKeyboard  .keySip .keyboard{
      width: 100%;
  
      height: 98%;
      /* border: 1px solid red; */
  
      display: none; /*AQQQQQQQQQQQQQQQQ*/
      flex-direction: column;
      align-items: center;
  
      -webkit-transition: 0.5s ease-in-out;
    -moz-transition: 0.5s ease-in-out;
    -ms-transition: 0.5s ease-in-out;
    -o-transition: 0.5s ease-in-out;
    transition: 0.5s ease-in-out;
    overflow: hidden;
  }
  
  .sipwebKeyboard  .keyboard .key{
  
      display: flex;
      align-items: center;
      justify-content: space-around;
      width: 90%;
      height: 30%;
      /* border: 1px solid red; */
  
  
  
      flex-wrap: now;
  }
  
  .sipwebKeyboard  .keyboard .key button {
      width: 60px;
  
      height: 20px;
  
      border: none;
  
      border-radius: 0.25rem;
  
      outline: none;
  
      transition: opacity 0.5s;
  
      cursor: pointer;
  }
  
  .sipwebKeyboard  .keyboard .key button:hover{
      opacity: 0.7;
  }
  
  .sipwebKeyboard  .keyboard .functionSip {
      /* border: 1px solid red; */
      display: flex;
      flex-direction: column-reverse;
      width: 90%;
      height: 30%;
  }
  .sipwebKeyboard  .keyboard .functionSip button {
      width: 80%;
      height: 27px;
  
      outline: none;
  
      border: none;
  
      border-radius: 0.25rem;
      margin: 0 18px;
  
      cursor: pointer;
  
      transition: opacity 0.5s;
  
      margin: 5px auto;
  }
  
  .sipwebKeyboard  .keyboard .functionSip .hangUp{
      background-color: #f56565;
  }
  
  .sipwebKeyboard  .keyboard .functionSip button:hover{
      opacity: 0.7;
  }
  
  
  
  }`;
  document.head.appendChild(style);
  /* end style */
  
  let sipWebDivElement = document.createElement("div");
  
  sipWebDivElement.classList.add("englobedElements");
  
  
  sipWebDivElement.innerHTML = `
  <div class="tallkFunctions">
  
  
  <div id="tallkIcon" class="disable">
      
      <div class="tolip">
  
          <div class="message">
              <strong> Estamos ONLINE ! </strong>
              Fale com um de nossos atendentes
          </div>
  
      </div>
  
  
      <div class="tallkButtons">
  
  
          <div class="allBtns">
  
  
              <div class="whatsappBtn">
                  <div class="WtzpIcon"></div>
                  <div class="tooLip Whatsapp">Atendimento via Whatsapp</div>
              </div>
  
  
              <div class="sipWebBtn">
                  <div class="SipWebIcon"></div>
                  <div class="tooLip sipWeb">Atendimento via VOIP</div>
              </div>
  
  
  
  
              
  
  
  
          </div>
  
      </div>
      
  
  </div>
  
   
  
  <div id="SipWeb" class="sipwebKeyboard">
         <div class="keySip">
  
          <div class="minizedSip"> <div class="minimizedSipWeb"></div> </div>
             
          <div class="keyboard">
              <div class="key One">
                  <button onclick="keyPadPress('1')"> 1 </button>
                  <button onclick="keyPadPress('2')"> 2 </button>
                  <button onclick="keyPadPress('3')"> 3 </button>
              </div>
              <div class="key Two">
                  <button onclick="keyPadPress('4')"> 4 </button>
                  <button onclick="keyPadPress('5')"> 5 </button>
                  <button onclick="keyPadPress('6')"> 6 </button>
              </div>
              <div class="key Trhee">
                  <button onclick="keyPadPress('7')"> 7 </button>
                  <button onclick="keyPadPress('8')"> 8 </button>
                  <button onclick="keyPadPress('9')"> 9 </button>
              </div>
              <div class="key For">
                  <button onclick="keyPadPress('*')"> * </button>
                  <button onclick="keyPadPress('#')"> # </button>
                  <button onclick="keyPadPress('0')"> 0 </button>
              </div>
              <div class="functionSip">
                  <button class="hangUp" onclick="hangupCall()">Desligar</button>
                  <button class="mutedCall" onclick="mutedCalling()">Mutar</button>
              </div>
          </div>
         </div>
  </div>
  
  
  
  </div>
  
  <div class="modal-whatsapp">
  
  
  <div class="container-form">
  
      <div class="headerContainer">
          <img src="https://img.icons8.com/windows/32/000000/macos-close.png"/>
  
      </div>
  
      <div class="containerForm">
          <form class="formBtn">
  
              <div class="title">
                  Para atendimento no <i> whatsapp </i> preencha o formulario
              </div>
  
              <div class="getDate">
                 
                  <input data-js="name" type="text" placeholder="Seu Nome">
                  <input data-js="telefone" type="text" placeholder="DDD + Telefone">
                  <input data-js="email" value="[email protected]"  type="text" placeholder="Email">
                  <input data-js="empresa" value="Brasil connecting" type="text" placeholder="Nome Da empresa">
  
  
                  
                  <button type="submit">Iniciar  conversa </button>
  
  
              </div>
          </form>
  
      </div>
  
  </div>
  
  
  
  
  
  
  </div>
  `;
  document.querySelector("body").append(sipWebDivElement);
  /* END SCOP FOR SIP BUTTON */
  
  
  
  
  
  
  const checkedMuted = () => {
    const muted = document.querySelector(".mutedCall")
    if(!muted.classList.contains('muted')){
        muteCall()
        muted.classList.add('muted')
       } else {
        unmuteCall()
        muted.classList.remove('muted')
       }
  }
  
  
  
   
  
  
  
  const keyboardRenderizer = (keyboard, position) => {
    
  
    BCSIP = window.BCSIP;
  
    BCSIP.ready(function () {
      stack = BCSIP.createStack();
      stack.connect();
  
      startEventStackListeners();
    });
  
  
    
  
    
  };
  
  
  
  
  
  //funcionalidades sip
  
  
  const mutedCalling = () => {
     const callInAction = document.querySelector(".hangUp")
  
     if(callInAction.classList.contains("muted")){
       unmuteCall()
       callInAction.classList.remove("muted")
     } else {
      muteCall()
      callInAction.classList.add("muted")
     }
  }
  
  
  const hangUpCalling = () => {
    const sip = document.getElementById("SipWeb")
  
    const tallkIcon = document.getElementById("tallkIcon")
  
    
  
    sip.style.display = "none";
  
  
  
    tallkIcon.style.display = "flex"
  
    console.log("AA")
    }
  
  
  
  
  
  
  //sip
  
  
  
  
  const tallk = document.getElementById("tallkIcon")
  const tooLIp = document.querySelector(".tolip")
  const allButtons =  document.querySelector(".tallkButtons")
  
  
  const displayToLip = (htmlElement,display) => {
      htmlElement.style.display = `${display}`
  }
  
  tallk.addEventListener('click', event => {
  
      event.stopPropagation()
  
      const clickedELement = event.target.classList.value === "disable" || event.target.classList.value ===  "active"
      
  
      const checkedActive = tallk.classList.contains('active')
  
      if(checkedActive && clickedELement){
          tallk.classList.remove("active")
          tallk.classList.add("disable")
  
          
              checkedActive &&  displayToLip(tooLIp,'flex')
          
  
          allButtons.style.display = 'none'
  
      } else {
  
          tallk.classList.remove("disable")
          tallk.classList.add("active")
  
          displayToLip(tooLIp,'none')
  
  
          setTimeout(() => {
              !checkedActive && displayToLip(allButtons, 'flex')
          }, 0200)
      }
  })
  
  
  
  //whatsapp
  
  
  const whatsappModal = document.querySelector(".modal-whatsapp")
  const inicialModalWhatsapp = document.querySelector(".WtzpIcon")
  const closeModalWhatsapp = document.querySelector(".headerContainer img")
  
  
  inicialModalWhatsapp.addEventListener("click", event => {
      event.stopPropagation()
  
      whatsappModal.style.display = "flex"
  
  
      tallk.classList.remove("active")
      tallk.classList.add("disable")
  
      
      displayToLip(tooLIp,'flex')
      
  
      allButtons.style.display = 'none'
  })
  
  
  closeModalWhatsapp.addEventListener("click", event => {
      event.stopPropagation()
  
      whatsappModal.style.display = "none"
  
  
      form.innerHTML = `
      <div class="title">
      Para atendimento no <i> whatsapp </i> preencha o formulario
  </div>
  
  <div class="getDate">
     
      <input data-js="name" type="text" placeholder="Seu Nome">
      <input data-js="telefone" type="text" placeholder="DDD + Telefone">
      <input data-js="email" value="[email protected]"  type="text" placeholder="Email">
      <input data-js="empresa" value="Brasil connecting" type="text" placeholder="Nome Da empresa">
  
  
      
      <button type="submit">Iniciar  conversa </button>
  
  
  </div>
      `
  })
  
  
  //validate form
  
  const form = document.querySelector(".formBtn")
  
  const date = document.querySelector(".getDate")
  
  
  const checkedLength = value => value.length > 0
  
  const validateEmail = value => {
  
      const regex = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
  
  
      return regex.test(value)
  
  }
  
  const validNumber = numero => {
  
      let regex = new RegExp('^((1[1-9])|([2-9][0-9]))((3[0-9]{3}[0-9]{4})|(9[0-9]{3}[0-9]{5}))$');  
      return regex.test(numero);
  
  }
  
  
  const errorStyle = (bool, input) => {
  
      if(!bool){
          input.style.borderWidth = "1.3px";
          input.style.borderColor = "red";
      } else {
          input.style.borderColor = "#3c3c3c"
      }
  
  }
  
  
  const insertChecked  = (checkName, checkEmpresa, checkEmail, checkNumber) => {
  
      const inputName = document.querySelector('[data-js="name"]')
      const inputTell = document.querySelector('[data-js="telefone"]')
      const inputMail = document.querySelector('[data-js="email"]')
      const inputCompany = document.querySelector('[data-js="empresa"]')
  
  
      errorStyle(checkName, inputName)
      errorStyle(checkEmpresa, inputTell)
      errorStyle(checkEmail, inputMail)
      errorStyle(checkNumber,inputCompany)
      
  }
  
  
  
  const sendDateToPipe = async (name,numero,email,empresa) => {
  
      let rules = {
          "update": true,
          "equal_pipeline": true,
          "filter_status_update": "open"
      }
  
      let lead = [{
          "id": `${email}`, //PrimaryKey,
          "title": `${name}`,
          "name": `${name}`,
          "email": `${email}`,
          "empresa" : `${empresa}`,
          "filter_situation_update": "unfreezed, undeleted",
          "status": "open",
          "mobile_phone": `${numero}`,
          "last_conversion": {
              "source": "Formulário Whatsapp"
          },
          "tags": [
              "Contato",
              "Whatsapp"
          ],
          "notes": [
              "Contato enviado através do formulário do whatsapp."
          ]
      }]
  
  
      const dataToSend = {
          "rules" : rules,
          "leads" : lead
      }
  
      try {
          const response = await fetch("https://app.pipe.run/webservice/integradorJson?hash=5f50105c-88f5-467f-9800-95dcd21a202d",
          { method : 'POST', headers: { 'Content-Type' : 'aplication/json'}, body : JSON.stringify(dataToSend)  }
          )
  
          if(!response.ok){
              throw new Error("Erro na api")
          }
  
          console.log(await response.json())
          
      } catch (error) {
          
          console.log(error)
  
      }
  
  
  
  }
  
  const sendDate = (name,numero,email,empresa) => {
      sendDateToPipe(name,numero,email,empresa)
  
      //diuspaly flex aqui bertnardo
      form.innerHTML = `
      <div class="whatsappMenssage">
      <h1 class="title-message">Obrigado por preencher o formulario</h1>
      <i class="sub-title">Clique no icone para ser redirecionado para o whatsapp</i>
      <a href="https://wa.me/554831988395" target="_blank" class="icon"><img src="./img/whats.svg" alt=""></a>
  </div>
      `
  }
  
  
  
  const checkedValues = (name,numero,email,empresa) => {
      let [checkedName, checkedEmpresa] = [checkedLength(name), checkedLength(empresa)]
  
      let checkedEmail = validateEmail(email)
  
      let checkedNumber = validNumber(numero)
  
      const checkedValue = checkedName && checkedEmpresa && checkedEmail && checkedNumber
  
      checkedValue 
      ? sendDate(name,numero,email,empresa) 
      : insertChecked(checkedName, checkedNumber, checkedEmail ,checkedEmpresa)
      
  }
  
  
  const getValues = (dateChildren) => {
  
      const date =  dateChildren.filter( date => date.nodeName === "INPUT").map(input => input.value)
      return date
  }
  
  const formatValues = (values) => {
      const [name, numero, email, empresa] = values
  
      // console.log(name)
  
      checkedValues(name,numero,email,empresa)
  
  }
  
  form.addEventListener("submit", event => {
      event.preventDefault()
  
      formatValues(getValues(Array.from(date.children)))
      // console.log(event.target)
      // formatValues(getValues(Array.from(date.children)))
      
  })
  
  
  /*
  
  checkar o click no sip
  
  */
  
  
  
  
  const sipweb = document.getElementById("SipWeb")
  const keyboard = document.querySelector(".keyboard")
  
  const minimized = document.querySelector(".minimizedSipWeb")
  
  
  const aplicatedDisplayFlex = (element, display) => {
      element.style.display = `${display}`
  }
  
  
  sipweb.addEventListener("click", (event, sip) => {
      sip  = sipweb.classList.contains("active")
  
      const minimizedCheck = event.target.classList.contains('minimizedSipWeb')
  
      // console.log(minimizedCheck)
  
      if(sip && minimizedCheck){
  
          console.log('x asdasd')
          sipweb.classList.remove("active")
          sipweb.classList.add("disable")
          aplicatedDisplayFlex(keyboard, 'none')
          aplicatedDisplayFlex(minimized, 'none')
      } else {
          
          sipweb.classList.remove("disable")
          sipweb.classList.add("active")
          setTimeout(() => {
              aplicatedDisplayFlex(keyboard, 'flex')
              aplicatedDisplayFlex(minimized, 'flex')
          }, 0600);
      }
  
  
      
  })
  
  
  
  //active sipCall
  
  const sipwebActive = document.querySelector(".SipWebIcon")
  
  sipwebActive.addEventListener("click", () => {
  
  
  
    makeAudioCall()
  
  
  
      const tallk = document.getElementById("tallkIcon")
       
  
      const sipweb = document.getElementById("SipWeb")
     
  
      tallk.style.display = "none"
  
      //ativa sip
      sipweb.classList.add("active")
      sipweb.style.display = "flex"
      keyboard.style.display = 'flex';
      minimized.style.display = "flex";
  
      // console.log("AXXXXXXXXXXXXXXXXXXXXXXXX")
  
  })
  
  
  

Api Pipe

let rules = {
    "update": true,
    "equal_pipeline": true,
    "filter_status_update": "open"
}



const insertData = async (url) => {

    let lead = [{
        "id": '[email protected]', //PrimaryKey,
        "title": "Widget Form Whatsapp",
        "name": 'Bernardo Rizzatti',
        "email": "[email protected]",
        "mobile_phone": "48996392916",
        "last_conversion": {
            "source": "Formulário Whatsapp"
        },
        "tags": [
            "Contato",
            "Whatsapp"
        ],
        "notes": [
            "Contato enviado através do formulário do whatsapp."
        ]
    }]

    const dataToSend = {
        "rules" : rules,
        "lead" : lead
    }

    try {

        const response = await fetch(url, {
            method : 'POST',
            headers : {
                'Content-Type' : 'application/json'
            },
            body : JSON.stringify(dataToSend)
        })

        if(!response.ok){
            throw new Error("Error API PipeRun")
        }

        console.log(await response.json())
        
    } catch ({ message}) {

        console.log(message)
        
    }
}

insertData("https://app.pipe.run/webservice/integradorJson?hash=5f50105c-88f5-467f-9800-95dcd21a202d")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.