Module: LeapSalesforce::ExeHelpers
- Defined in:
- lib/leap_salesforce/generator/exe_helpers.rb
Overview
Helpers for LeapSalesforce executable
Instance Method Summary collapse
-
#input_for(query, color = nil) ⇒ String
Return input for query.
-
#query_for_parameters ⇒ Object
Ask user to enter parameters specific to their Salesforce environment.
-
#verify_environment ⇒ Object
Retrieve environment and ensure that environment can be connected to.
-
#verify_oauth ⇒ Object
Retrieve OAuth credentials and verify that they’re correct.
Instance Method Details
#input_for(query, color = nil) ⇒ String
Return input for query
13 14 15 16 17 18 19 20 |
# File 'lib/leap_salesforce/generator/exe_helpers.rb', line 13 def input_for(query, color = nil) if color puts query.colorize(color) else puts query end $stdin.gets.strip end |
#query_for_parameters ⇒ Object
Ask user to enter parameters specific to their Salesforce environment
48 49 50 51 52 53 54 |
# File 'lib/leap_salesforce/generator/exe_helpers.rb', line 48 def query_for_parameters puts 'Please enter the following information to generate files for a new' \ ' leap_salesforce testing repo'.colorize(:green) verify_environment verify_oauth @user_key = [:user_key] || input_for('Enter a key to refer to this user (This will be stored as a Symbol)').delete(':') end |
#verify_environment ⇒ Object
Retrieve environment and ensure that environment can be connected to
23 24 25 26 27 28 29 30 31 |
# File 'lib/leap_salesforce/generator/exe_helpers.rb', line 23 def verify_environment unless LeapSalesforce.sfdx LeapSalesforce.environment = [:environment] || input_for('Enter the environment you want to set things up for ' \ '(This will be parameterised so can be changed later). For production used "prod". Otherwise preference is to use the' \ ' part of the URL that is unique for the environment') end LeapSalesforce.salesforce_reachable? puts "\u2713 Connection to #{LeapSalesforce.general_url} successful".colorize :green end |
#verify_oauth ⇒ Object
Retrieve OAuth credentials and verify that they’re correct
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/leap_salesforce/generator/exe_helpers.rb', line 34 def verify_oauth unless LeapSalesforce.sfdx LeapSalesforce.client_id = [:client_id] || input_for('Client id (Customer Id)') LeapSalesforce.client_secret = [:client_secret] || $stdin.getpass('Client secret (Consumer Secret)') LeapSalesforce.password = [:password] || $stdin.getpass('Password (Recommendation is that 1 password' \ ' be shared across all test users to be easier to manage):') end LeapSalesforce.api_user = ERB.new([:username] || input_for('Salesforce username. It is ideal to start with a System admin' \ ' so that any necessary metadata can be read. More users can be added later. You can use ERB to make name' \ ' vary according to environment (e.g., test.user@<%= LeapSalesforce.environment %>.my.company.com)')).result(binding) LeapSalesforce.oauth_working? end |