class GovFakeNotify::Cli::Root

Root of all commands

Public Instance Methods

create_template() click to toggle source
# File lib/gov_fake_notify/cli/root.rb, line 40
def create_template
  data = {
    id: options.template_id,
    message: File.read(options.path),
    name: options.name,
    subject: options.subject
  }
  res = Net::HTTP.post(URI("#{GovFakeNotify.config.base_url}/control/templates"), JSON.generate(data),
                       { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
  puts res.body
end
start() click to toggle source
# File lib/gov_fake_notify/cli/root.rb, line 26
def start
  if options.config
    GovFakeNotify.config do |c|
      c.from(YAML.parse(File.read(options.config)).to_ruby.merge(options.slice(*(options.keys - ['config']))))
    end
  end
  Rack::Server.start app: GovFakeNotify::RootApp, Port: GovFakeNotify.config.port, server: 'iodine'
end