class SlackTrello::Commands::CreateCard

Attributes

slack_post_response[R]
webhook_url[R]

Public Class Methods

new(slack_post_args, webhook_url) click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 8
def initialize(slack_post_args, webhook_url)
  @slack_post_response = OpenStruct.new(slack_post_args)
  @webhook_url = webhook_url
end

Public Instance Methods

run() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 13
def run
  return help_message unless valid_text_format?
  return help_message unless num_args == 2
  return list_not_found_message unless trello_card_creator.trello_list

  trello_card
  speaker.speak success_message
  "You should see a notification with a link. If not, the card might not have been created."
end

Private Instance Methods

card_title() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 50
def card_title
  text_message
end
example_command() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 25
def example_command
  "/card (trello_board trello_list) card title"
end
trello_board_name() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 42
def trello_board_name
  args[0]
end
trello_card() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 38
def trello_card
  @card ||= trello_card_creator.first_or_create
end
trello_card_creator() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 29
def trello_card_creator
  args = {
    board_name: trello_board_name,
    list_name: trello_list_name,
    card_name: card_title
  }
  @trello_card_creator ||= SlackTrello::TrelloHelpers::CreateCard.new(args)
end
trello_list_name() click to toggle source
# File lib/slack_trello/commands/create_card.rb, line 46
def trello_list_name
  args[1]
end