Sha256: fffc17b5e01b3ece24753cfb58ed6256b80d87a34eb86a1dbe48a734b5d6ec96

Contents?: true

Size: 742 Bytes

Versions: 6

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true
require 'osa/util/db'
require 'osa/services/auth_service'
require 'tty-prompt'
require 'osa/util/context'

module OSA
  class SetupService
    def setup!
      Config.delete_all
      config = Config.new
      AuthService.login(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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
osa-0.2.3 lib/osa/services/setup_service.rb
osa-0.2.2 lib/osa/services/setup_service.rb
osa-0.2.1 lib/osa/services/setup_service.rb
osa-0.2.0 lib/osa/services/setup_service.rb
osa-0.1.3 lib/osa/services/setup_service.rb
osa-0.1.2 lib/osa/services/setup_service.rb