Class: DiscoApp::PartnerAppService
- Inherits:
-
Object
- Object
- DiscoApp::PartnerAppService
- Defined in:
- app/services/disco_app/partner_app_service.rb
Instance Method Summary collapse
- #generate_partner_app ⇒ Object
-
#initialize(params) ⇒ PartnerAppService
constructor
A new instance of PartnerAppService.
Constructor Details
#initialize(params) ⇒ PartnerAppService
Returns a new instance of PartnerAppService.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/disco_app/partner_app_service.rb', line 4 def initialize(params) @email = params[:email] @password = params[:password] @app_name = params[:app_name] @app_url = params[:app_url] @organization = params[:organization] @agent = Mechanize.new do |a| a.user_agent_alias = 'Mac Safari' a. = true a.keep_alive = false a.pre_connect_hooks << lambda do |_agent, request| request['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' end end end |
Instance Method Details
#generate_partner_app ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/services/disco_app/partner_app_service.rb', line 21 def generate_partner_app begin # Login to Shopify Partners login # Access Partner dashboard org_link = organizations dashboard = dashboard_page(org_link) # Create App apps_page = refresh_page(dashboard) create_partner_app(apps_page) # Configure newly created app with embedded app use apps_page = refresh_page(dashboard) (apps_page) # Add Disco App icon apps_page = refresh_page(dashboard) add_disco_icon(apps_page) # Fetch API credentials apps_page = refresh_page(dashboard) api_key, secret = api_credentials(apps_page) rescue Mechanize::Error => e puts 'Error while trying to create partner app' puts "Error #{e}, message : #{e.}" return end # Add them to .env.local file append_credentials(api_key, secret) puts '#' * 80 puts 'New Partner App successfully created!' puts 'API Credentials have been pasted to your .env.local file' puts '#' * 80 end |