public IActionResult GetWhatsApp(WhatsAppMessage model)
        {
            var message = new MessagingResponse();

            message.Message("Received your mesage");

            return(Ok(message.ToString()));
        }
        public IActionResult SendWhatsApp(WhatsAppMessage model)
        {
            var message = MessageResource.Create(
                to: new PhoneNumber("whatsapp:" + model.To),
                from: new PhoneNumber("whatsapp:" + model.From),
                body: model.Message,
                client: _client); // pass in the custom client

            return(Ok(message.Sid));
        }
示例#3
0
        /// <summary>
        /// QR Code gerado para envio de mensagem no WhatsApp
        /// </summary>
        /// <param name="message">Mensagem a ser enviada</param>
        /// <returns>QR Code que direciona para o whatsapp</returns>
        public static Bitmap GeneratedQRCodeWhatsApp(string message)
        {
            WhatsAppMessage generator = new WhatsAppMessage(message);
            string          payload   = generator.ToString();

            QRCodeGenerator qrGenerator    = new QRCodeGenerator();
            QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode         = new QRCode(qrCodeData);
            Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

            return(qrCodeAsBitmap);
        }
示例#4
0
        /// <summary>
        /// WhatsAppMessage
        /// </summary>
        protected void QR_WhatsAppMsg()
        {
            WhatsAppMessage generator = new WhatsAppMessage("你好约翰,你怎么看QR码?");
            string          payload   = generator.ToString();

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);

            QR            = qrCode.GetGraphic(4);
            QR_show.Image = QR.GetThumbnailImage(300, 300, null, IntPtr.Zero);
        }
示例#5
0
        public ActionResult InboundWhatsAppMessage()
        {
            var inbound = WebhookParser.ParseWebhook <JObject>
                              (Request.Body, Request.ContentType);
            var message = new WhatsAppMessage
            {
                MessageId = inbound["message_uuid"].ToString(),
                From      = inbound["from"]["number"].ToString(),
                To        = inbound["to"]["number"].ToString(),
                Text      = inbound["message"]["content"]["text"].ToString()
            };

            _db.Messages.Add(message);
            _db.SaveChanges();
            return(Ok());
        }
 public void MoveNext()
 {
     this.Compliant = this.Compliant.NextMessage;
 }
 public IteratorWhatsapp(WhatsAppMessage complaint)
 {
     this.Compliant = complaint;
 }
示例#8
0
        static void Iterator()
        {
            var A = new House(100, 25, 4);
            var B = new House(102, 16, 1);
            var C = new House(104, 34, 5);
            var D = new House(106, 20, 3);
            var E = new House(108, 9, 2);
            var F = new House(109, 25, 4);
            var G = new Square("G", 16, 2, 5);
            var H = new Square("H", 16, 2, 5);
            var I = new Square("I", 16, 2, 5);
            var J = new Square("J", 36, 5, 4);

            var street = new Street(110, 64, 25);

            A.Street = street;
            B.Street = street;
            C.Street = street;
            D.Street = street;
            E.Street = street;
            F.Street = street;
            G.Street = street;
            H.Street = street;
            I.Street = street;
            J.Street = street;

            G.Builder = new mixedBuilder();
            H.Builder = new FavorableBuilder();
            I.Builder = new UnfavorableBuilder();

            // BOARD
            var complaintsByBoard = new ComplaintByBoard();

            A.AddObserver(complaintsByBoard);
            B.AddObserver(complaintsByBoard);
            C.AddObserver(complaintsByBoard);
            D.AddObserver(complaintsByBoard);
            E.AddObserver(complaintsByBoard);
            F.AddObserver(complaintsByBoard);

            // WHATSAPP
            WhatsAppMessage whatsAppList = null;

            whatsAppList = new WhatsAppMessage(new FireReport(G), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(H), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(I), whatsAppList);
            var complaintsByWhatsapp = new ComplaintByWhatsapp(whatsAppList);

            // DESK
            var complaintsByDesk = new ComplaintByDesk(J);

            B.Spark();
            F.Spark();

            // TEST
            var fireman = new Firefighter();

            fireman.Vehicle = new FireTruck();
            fireman.Tool    = new WaterHose();
            var secretary = new FirefighterSecretary(fireman);

            secretary.AttendCompliant(complaintsByBoard);
            secretary.AttendCompliant(complaintsByDesk);
            Console.Clear();
            secretary.AttendCompliant(complaintsByWhatsapp);
        }
示例#9
0
        static void Proxy()
        {
            var A = new House(100, 25, 4);
            var B = new House(102, 16, 1);
            var C = new House(104, 34, 5);
            var D = new House(106, 20, 3);
            var E = new House(108, 9, 2);
            var F = new House(109, 25, 4);
            var G = new Square("G", 16, 2, 5);
            var H = new Square("H", 16, 2, 5);
            var I = new Square("I", 16, 2, 5);
            var J = new Square("J", 36, 5, 4);

            var street = new Street(110, 64, 25);

            A.Street = street;
            B.Street = street;
            C.Street = street;
            D.Street = street;
            E.Street = street;
            F.Street = street;
            G.Street = street;
            H.Street = street;
            I.Street = street;
            J.Street = street;

            G.Builder = new mixedBuilder();
            H.Builder = new FavorableBuilder();
            I.Builder = new UnfavorableBuilder();

            // WHATSAPP
            WhatsAppMessage whatsAppList = null;

            whatsAppList = new WhatsAppMessage(new FireReport(G), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(H), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(I), whatsAppList);

            // HEART ATTACK - 2
            var passerbyReport = new HearthAttackReport();

            passerbyReport.Pedestrian = new Passerby();
            whatsAppList = new WhatsAppMessage(passerbyReport, whatsAppList);

            var foreignPasserbyReport = new HearthAttackReport();
            var passerbyAddapter      = new ForeignPasserbyAdapter(new ForeignPasserby(pc: 0.20, pb: 0.30, phr: 0.50));

            foreignPasserbyReport.Pedestrian = passerbyAddapter;
            whatsAppList = new WhatsAppMessage(foreignPasserbyReport, whatsAppList);

            // ROBBERY - 3
            var robbertyReport1 = new RobberyReport();

            robbertyReport1.Place = A;
            whatsAppList          = new WhatsAppMessage(robbertyReport1, whatsAppList);

            var robbertyReport2 = new RobberyReport();

            robbertyReport2.Place = B;
            whatsAppList          = new WhatsAppMessage(robbertyReport2, whatsAppList);

            var robbertyReport3 = new RobberyReport();

            robbertyReport3.Place = J;
            whatsAppList          = new WhatsAppMessage(robbertyReport3, whatsAppList);

            // BURNT LAMPS - 5
            var burntReport1 = new BurntLampReport();

            burntReport1.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport1, whatsAppList);

            var burntReport2 = new BurntLampReport();

            burntReport2.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport2, whatsAppList);

            var burntReport3 = new BurntLampReport();

            burntReport3.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport3, whatsAppList);

            var burntReport4 = new BurntLampReport();

            burntReport4.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport4, whatsAppList);

            var burntReport5 = new BurntLampReport();

            burntReport5.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport5, whatsAppList);

            var complaintsByWhatsapp = new ComplaintByWhatsapp(whatsAppList);

            // TEST
            CompliantHandler handler = new CopProxy().CreateHeroe();

            handler = new FiremanProxy().CreateHeroe(handler);
            handler = new ElectricianProxy().CreateHeroe(handler);
            handler = new MedicProxy().CreateHeroe(handler);

            var operator911 = new Operator911(handler);

            operator911.AttendReport(complaintsByWhatsapp);
        }
示例#10
0
 public void Post([FromBody] WhatsAppMessage message)
 {
     _whatsAppService.SendMessage(message.Body, message.ToPhoneNumber);
 }
示例#11
0
        private async Task <QRCodeData> GenerateWhatsAppMessageQrCode(CreateWhatsAppMessageModel model)
        {
            var message = new WhatsAppMessage(model.Phone, model.Body);

            return(await GenerateAsync(message));
        }