Class: Establish::ItunesConnect
- Inherits:
-
Object
- Object
- Establish::ItunesConnect
- Includes:
- Capybara::DSL
- Defined in:
- lib/establish/itunes_connect.rb
Constant Summary collapse
- ITUNESCONNECT_URL =
"https://itunesconnect.apple.com"
- APP_DETAILS_URL =
"https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/[[app_id]]"
- BUTTON_STRING_NEW_VERSION =
"New Version"
- BUTTON_STRING_SUBMIT_FOR_REVIEW =
"Submit for Review"
Instance Method Summary collapse
-
#create_new_version!(app, version_number) ⇒ Object
Constructive/Destructive Methods.
- #get_app_status(app) ⇒ Object
-
#initialize ⇒ ItunesConnect
constructor
A new instance of ItunesConnect.
- #login(user = nil, password = nil) ⇒ Object
- #open_app_page(app) ⇒ Object
-
#wait_for_elements(name) ⇒ Object
Helper - move out.
Constructor Details
#initialize ⇒ ItunesConnect
Returns a new instance of ItunesConnect.
21 22 23 24 25 26 27 |
# File 'lib/establish/itunes_connect.rb', line 21 def initialize super Capybara.default_driver = :poltergeist self.login end |
Instance Method Details
#create_new_version!(app, version_number) ⇒ Object
Constructive/Destructive Methods
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# 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) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# 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) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# 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) ⇒ Object
Helper - move out
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# 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 |