public SlackRequest Map(OutgoingWebhookRequest outgoingWebhookRequest)
        {
            _logger.Debug(JsonConvert.SerializeObject(outgoingWebhookRequest));
            CommandType commandType;
            var         bParse = Enum.TryParse(outgoingWebhookRequest.trigger_word.Replace(" ", ""), true, out commandType);

            if (bParse)
            {
                return new SlackRequest
                       {
                           CommandType = commandType,
                           CommandText =
                               outgoingWebhookRequest.text.Substring(outgoingWebhookRequest.trigger_word.Length)
                               .Trim(' ', '#', ':', '<', '>'),
                           AuthorizationToken = outgoingWebhookRequest.token,
                           ChannelName        = outgoingWebhookRequest.channel_name
                       }
            }
            ;
            var error = $"Unable to parse trigger word\n{outgoingWebhookRequest.trigger_word}\ninto a command type.";

            _logger.Error(error);
            throw new SlackRequestMapException(error);
        }
    }
        public void RejectedOutgoingWebhookTests(string triggerWord, string text)
        {
            var sc = new OutgoingWebhookRequest
            {
                text         = text,
                trigger_word = triggerWord
            };

            Assert.Throws <SlackRequestMapException>(() => Mapper.Map(sc));
        }
        public void OutgoingWebhookTests(string text, string token, string channel_name, string trigger_word, CommandType commandType, string commandText)
        {
            var sc = new OutgoingWebhookRequest
            {
                text         = text,
                token        = token,
                channel_name = channel_name,
                trigger_word = trigger_word
            };
            var sr = Mapper.Map(sc);

            sr.CommandType.ShouldBeEquivalentTo(commandType);
            sr.CommandText.ShouldBeEquivalentTo(commandText);
            sr.ChannelName.ShouldBeEquivalentTo(channel_name);
            sr.AuthorizationToken.ShouldBeEquivalentTo(token);
        }
 public OutgoingWebhookResponse OutgoingWebhook(OutgoingWebhookRequest outgoingWebhookRequest)
 {
     try
     {
         var slackRequest  = RequestMapper.Map(outgoingWebhookRequest);
         var slackResponse = Processor.Process(slackRequest);
         return(ResponseMapper.MapToOutgoingWebhookResponse(slackResponse));
     }
     catch (Exception e)
     {
         Log.Error("Encountered error while processing outgoing webhook request.", e);
         return(new OutgoingWebhookResponse
         {
             Text = ExceptionResponse
         });
     }
 }