Class: BulletTrain::IncomingWebhooks::Scaffolders::IncomingWebhooksScaffolder

Inherits:
SuperScaffolding::Scaffolder
  • Object
show all
Defined in:
lib/bullet_train/incoming_webhooks/scaffolders/incoming_webhooks_scaffolder.rb

Instance Method Summary collapse

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bullet_train/incoming_webhooks/scaffolders/incoming_webhooks_scaffolder.rb', line 8

def run
  unless argv.count >= 1
    puts ""
    puts "🚅 usage: bin/super-scaffold incoming-webhooks SomeProvider"
    puts ""
    puts "E.g. prepare to receive system-level webhooks from ClickFunnels"
    puts "  bin/super-scaffold incoming-webhooks ClickFunnels"
    puts ""
    puts "🏆 Protip: Commit your other changes before running Super Scaffolding so it's easy to undo if you (or we) make any mistakes."
    puts "If you do that, you can reset to your last commit state by using `git checkout .` and `git clean -d -f` ."
    puts ""
    return
  end

  provider_name = argv.shift
  transformer = Scaffolding::IncomingWebhooksTransformer.new(provider_name)

  `yes n | bin/rails g model Webhooks::Incoming::#{provider_name}Webhook data:jsonb processed_at:datetime verified_at:datetime`

  transformer.scaffold_incoming_webhook

  puts ""
  puts "1. To receive webhooks in your development environment, you'll need to configure a tunnel.".yellow
  puts "     See http://bullettrain.co/docs/tunneling for more information.".yellow
  puts ""
  puts "2. Once you have a tunnel running, you can configure the provider to deliver webhooks to:".yellow
  puts "     https://your-tunnel.ngrok.io/webhooks/incoming/#{provider_name.tableize.singularize}_webhooks".yellow
  puts ""

  transformer.restart_server
end