Exemplo n.º 1
0
        public async Task <JObject> BuildSlackPayload(string header, string sourceId, ICloseClient closeApi, string jobPostCustomer = null)
        {
            Dictionary <string, Option> customers = await closeApi.GetListOfCustomers();

            BlocksBuilder builder        = new BlocksBuilder();
            StaticSelect  customerSelect = new StaticSelect("customer_select", customers.Values.ToList(), "Customer");
            SlackAction   actions        = new SlackAction("actions")
                                           .AddElement(customerSelect);

            // check if we have detected a customer and if so set it as initial option
            if (!string.IsNullOrEmpty(jobPostCustomer))
            {
                actions.AddElement(new Button("addToClose_btn", "Add to Close", ButtonStyle.PRIMARY));
                if (customers.ContainsKey(jobPostCustomer))
                {
                    customerSelect.AddInitialOption(customers[jobPostCustomer]);
                }
            }

            // adding button in the proper place
            actions.AddElement(new Button("qualifyLead_btn", "Qualify Lead", string.IsNullOrEmpty(jobPostCustomer) ? ButtonStyle.PRIMARY : ButtonStyle.DEFAULT));

            builder.AddBlock(new Section(new Text(" ")));
            builder.AddBlock(new Section(new Text(" ")));
            builder.AddBlock(new Section(new Text("*" + header + "*" + Environment.NewLine + sourceId, "mrkdwn"), "msg_header"));
            builder.AddBlock(actions);
            builder.AddBlock(new Divider());

            return(builder.GetJObject());
        }
Exemplo n.º 2
0
        public static JObject BuildDefaultSlackPayload(string header, Option selectedOption, SlackPostState postState, string leadId = "", Dictionary <string, Option> customers = null)
        {
            BlocksBuilder builder = new BlocksBuilder();
            SlackAction   actions = new SlackAction("actions");

            if (!(customers is null))
            {
                StaticSelect customerSelect = new StaticSelect("customer_select", customers.Values.ToList(), "Customer");
                actions.AddElement(customerSelect);

                if (!(selectedOption is null))
                {
                    customerSelect.AddInitialOption(selectedOption);
                }
            }

            actions.AddElement(new Button("addToClose_btn", "Add to Close", ButtonStyle.PRIMARY));

            // adding button in the proper place
            actions.AddElement(new Button("qualifyLead_btn", "Qualify Lead"));

            builder.AddBlock(new Section(new Text(" ")));
            builder.AddBlock(new Section(new Text(" ")));
            builder.AddBlock(new Section(new Text(header, "mrkdwn"), "msg_header"));

            if (postState == SlackPostState.ACTIONS)
            {
                builder.AddBlock(actions);
            }
            else if (postState == SlackPostState.FINAL)
            {
                builder.AddBlock(new Section(new Text($":white_check_mark: *Opportunity added to <https://app.close.com/lead/{leadId}|Close.com>*", "mrkdwn")));
            }

            builder.AddBlock(new Divider());

            return(builder.GetJObject());
        }