public string Process()
        {
            MessageClass message = new MessageClass();

            message.MessageText = "Hello, {0}";
            message.MessageText = string.Format(message.MessageText, Args["Name"]);

            MessageAttachmentsClass attachment = new MessageAttachmentsClass();

            attachment.Title = "This is Attachment Title";
            attachment.Text  = "This is the text of the Message. For more on this please visit 'https://docs.yellowant.com/' ";

            ButtonCommandsClass Bcc = new ButtonCommandsClass();

            Bcc.FunctionName       = "hello";
            Bcc.ServiceApplication = IntegrationID;
            Command Cmd = new Command();

            Cmd.Name = "Button";
            Bcc.Data = Cmd;

            MessageButtonClass button = new MessageButtonClass();

            button.Value   = "value";
            button.Name    = "name";
            button.Text    = "Test Button";
            button.Command = Bcc;

            attachment.AttachButton(button);
            message.Attach(attachment);
            string ToReturn = JsonConvert.SerializeObject(message);

            MessageClass ToSendMessage = new MessageClass();

            ToSendMessage.MessageText = "Sending Message";
            var       user = db.UserIntegrationContext.Where(a => a.IntegrationID == IntegrationID).FirstOrDefault();
            Yellowant ya   = new Yellowant
            {
                AccessToken = user.YellowantIntegrationToken
            };

            ya.SendMessage(IntegrationID, ToSendMessage);
            ToSendMessage.MessageText = "Webhook Message";
            var ExampleData = new {
                first_name = "FirstName",
                last_name  = "LastName"
            };

            ToSendMessage.MessageData = ExampleData;
            //string testData = JsonConvert.SerializeObject(ToSendMessage);
            ya.SendWebhookMessage(IntegrationID, "webhook", ToSendMessage);



            return(ToReturn);
        }
示例#2
0
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowAntUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect(redirecturl + "/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = clientID,
                AppSecret   = clientSecret,
                RedirectURI = redirecturl + "/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration
            {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect(redirecturl + "/userintegration/integrate/"));
        }
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowAntUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect("http://f0008a02.ngrok.io/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = "FvbTB2WePePZH3Zz7IEEvzPpe84FSosINSG67bus",
                AppSecret   = "6YMYY9oB9sU8imWBcYM3Z0MCjbnhCBCWbGHDICODyTLPmKXlqCeanEZrL9xNSuhZ9Eja54Mye5OfAPS2ZrJF1trT0Ag2byh31bMGXpFMQsvc2w5loBLuhmpK5q1d8HeT",
                RedirectURI = "http://f0008a02.ngrok.io/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration
            {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect("http://f0008a02.ngrok.io/userintegration/integrate/"));
        }
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowantUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect("http://appurl.com/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = "Rvpy9UMwy4wfOR0HHohOoCdXk3IIl2n4BhzpMC28",
                AppSecret   = "9ZjwhuaBmFS1Sq08QHDkWay9pBbLYXsbMRSBzOXV6pj7pCILsWDNHl3vfChwgnD90KpNqEJxottOlJp5esefQGVFRKwq13hgrVO2iKDADhpjFg8nytgyeSEC43ikl0Uq",
                RedirectURI = "http://appurl.com/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect("http://appurl.com/userintegration/integrate/"));
        }