public static async Task <IdentityHistoryFunctionApp.SlackAPI.User> PullSlackUser(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "PullSlackUser")] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string user = req.Query["user"];

            log.LogInformation($"user: {user}");

            var res = await slackClient.APIRequestWithTokenAsync <MyUserInfoResponse>(new Tuple <string, string>("user", user));

            var slackUser = res.user;

            log.LogInformation($"slackUser: {JsonConvert.SerializeObject(slackUser)}");

            return(slackUser);
        }
Beispiel #2
0
        private Task <UpdateResponse> UpdateWithBlocksAsync(
            string ts,
            string channelId,
            string text,
            string botName           = null,
            string parse             = null,
            bool linkNames           = false,
            IBlock[] blocks          = null,
            Attachment[] attachments = null,
            // ReSharper disable once InconsistentNaming
            bool as_user = false)
        {
            var tupleList = new List <Tuple <string, string> >
            {
                new Tuple <string, string>(nameof(ts), ts),
                new Tuple <string, string>("channel", channelId),
                new Tuple <string, string>(nameof(text), text)
            };

            if (!string.IsNullOrEmpty(botName))
            {
                tupleList.Add(new Tuple <string, string>("username", botName));
            }

            if (!string.IsNullOrEmpty(parse))
            {
                tupleList.Add(new Tuple <string, string>(nameof(parse), parse));
            }

            if (linkNames)
            {
                tupleList.Add(new Tuple <string, string>("link_names", "1"));
            }

            if (blocks != null && blocks.Length != 0)
            {
                tupleList.Add(new Tuple <string, string>(nameof(blocks), JsonConvert.SerializeObject(blocks, new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                })));
            }

            if (attachments != null && attachments.Length != 0)
            {
                tupleList.Add(new Tuple <string, string>(nameof(attachments), JsonConvert.SerializeObject(attachments)));
            }

            tupleList.Add(new Tuple <string, string>(nameof(as_user), as_user.ToString()));
            return(_actualClient.APIRequestWithTokenAsync <UpdateResponse>(tupleList.ToArray()));
        }
Beispiel #3
0
        public async Task <OrganizationSlackInfo> GetInfo()
        {
            var response = await _slackTaskClient.APIRequestWithTokenAsync <TeamInfoResponse>();

            return(new OrganizationSlackInfo(response.team.name));
        }