Class: OSA::SetupService

Inherits:
Object
  • Object
show all
Defined in:
lib/osa/services/setup_service.rb

Instance Method Summary collapse

Instance Method Details

#setup!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/osa/services/setup_service.rb', line 9

def setup!
  Config.delete_all
  config = Config.new
  AuthService.(config)

  context = Context.new(config)
  folders = context.graph_client.folders.all
  choices = folders.map { |folder|
    [folder['displayName'], folder['id']]
  }.to_h
  prompt = TTY::Prompt.new
  junk_folder_id = prompt.select('Select junk folder:', choices)
  spamcop_email = prompt.ask('Spamcop report email:') { |q| q.validate :email }

  config.update! junk_folder_id: junk_folder_id, spamcop_report_email: spamcop_email
end