class Establish::ItunesConnect
Constants
- APP_DETAILS_URL
- BUTTON_STRING_NEW_VERSION
- BUTTON_STRING_SUBMIT_FOR_REVIEW
- ITUNESCONNECT_URL
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/establish/itunes_connect.rb, line 21 def initialize super Capybara.default_driver = :poltergeist self.login end
Public Instance Methods
create_new_version!(app, version_number)
click to toggle source
Constructive/Destructive Methods
# File lib/establish/itunes_connect.rb, line 84 def create_new_version!(app, version_number) open_app_page(app) if page.has_content?BUTTON_STRING_NEW_VERSION click_on BUTTON_STRING_NEW_VERSION Helper.log.info "Creating a new version (#{version_number})" all(".fullWidth.nobottom.ng-isolate-scope.ng-pristine").last.set(version_number.to_s) click_on "Create" else Helper.log.info "Creating a new version" end true end
get_app_status(app)
click to toggle source
# File lib/establish/itunes_connect.rb, line 62 def get_app_status(app) open_app_page(app) if page.has_content?"Waiting For Review" # That's either Upload Received or Waiting for Review if page.has_content?"To submit a new build, you must remove this version from review" return App::AppStatus::WAITING_FOR_REVIEW else return App::AppStatus::UPLOAD_RECEIVED end elsif page.has_content?BUTTON_STRING_NEW_VERSION return App::AppStatus::READY_FOR_SALE elsif page.has_content?BUTTON_STRING_SUBMIT_FOR_REVIEW return App::AppStatus::PREPARE_FOR_SUBMISSION else raise "App status not yet implemented" end end
login(user = nil, password = nil)
click to toggle source
# File lib/establish/itunes_connect.rb, line 29 def login(user = nil, password = nil) Helper.log.info "Logging into iTunesConnect" host = "itunesconnect.apple.com" user ||= PasswordManager.new.username password ||= PasswordManager.new.password visit ITUNESCONNECT_URL fill_in "accountname", with: user fill_in "accountpassword", with: password begin wait_for_elements(".enabled").first.click wait_for_elements('.ng-scope.managedWidth') rescue raise "Error logging in user #{user} with the given password. Make sure you set them correctly" end Helper.log.info "Successfully logged into iTunesConnect" true end
open_app_page(app)
click to toggle source
# File lib/establish/itunes_connect.rb, line 52 def open_app_page(app) Helper.log.info "Opening detail page for app #{app}" visit APP_DETAILS_URL.gsub("[[app_id]]", app.apple_id.to_s) wait_for_elements('.page-subnav') true end
wait_for_elements(name)
click to toggle source
Helper
- move out
# File lib/establish/itunes_connect.rb, line 105 def wait_for_elements(name) counter = 0 results = all(name) while results.count == 0 Helper.log.debug "Waiting for #{name}" sleep 0.2 results = all(name) counter += 1 if counter > 100 Helper.log.debug page.html Helper.log.debug caller raise "Couldn't find element '#{name}' after waiting for quite some time" end end return results end