Class: FastlaneCore::ItunesConnect

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL
Defined in:
lib/fastlane_core/itunes_connect/itunes_connect.rb,
lib/fastlane_core/itunes_connect/itunes_connect_login.rb,
lib/fastlane_core/itunes_connect/itunes_connect_helper.rb,
lib/fastlane_core/itunes_connect/itunes_connect_apple_id.rb

Overview

Find the Apple ID based on the App Identifier

Defined Under Namespace

Classes: ItunesConnectGeneralError, ItunesConnectLoginError

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"
WAITING_FOR_REVIEW =
"Waiting For Review"
LIST_APPLE_IDS_URL =
"https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary"

Instance Method Summary collapse

Constructor Details

#initializeItunesConnect

Returns a new instance of ItunesConnect.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fastlane_core/itunes_connect/itunes_connect.rb', line 36

def initialize
  super

  return if Helper.is_test?
  
  Capybara.run_server = false
  Capybara.default_driver = :poltergeist
  Capybara.javascript_driver = :poltergeist
  Capybara.current_driver = :poltergeist
  Capybara.app_host = ITUNESCONNECT_URL

  # Since Apple has some SSL errors, we have to configure the client properly:
  # https://github.com/ariya/phantomjs/issues/11239
  Capybara.register_driver :poltergeist do |a|
    conf = ['--debug=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1']
    Capybara::Poltergeist::Driver.new(a, {
      phantomjs: Phantomjs.path,
      phantomjs_options: conf,
      phantomjs_logger: File.open("/tmp/poltergeist_log.txt", "a"),
      js_errors: false,
      timeout: 90
    })
  end

  page.driver.headers = { "Accept-Language" => "en" }

  
end

Instance Method Details

#find_apple_id(app_identifier) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/fastlane_core/itunes_connect/itunes_connect_apple_id.rb', line 5

def find_apple_id(app_identifier)
  

  apps = JSON.parse(page.evaluate_script("$.ajax({type: 'GET', url: '#{LIST_APPLE_IDS_URL}', async: false})")['responseText'])['data']

  return apps['summaries'].find { |v| v['bundleId'] == app_identifier }['adamId'].to_i
rescue => ex
  # Do nothing right now...
end

#login(user = nil, password = nil) ⇒ bool

Loggs in a user with the given login data on the iTC Frontend. You don’t need to pass a username and password. It will Automatically be fetched using the CredentialsManager::PasswordManager. This method will also automatically be called when triggering other actions like #open_app_page

Parameters:

  • user (String) (defaults to: nil)

    (optional) The username/email address

  • password (String) (defaults to: nil)

    (optional) The password

Returns:

  • (bool)

    true if everything worked fine

Raises:



15
16
17
18
19
20
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
52
53
54
55
56
57
58
59
# File 'lib/fastlane_core/itunes_connect/itunes_connect_login.rb', line 15

def (user = nil, password = nil)
  Helper.log.info "Logging into iTunesConnect"

  user ||= CredentialsManager::PasswordManager.shared_manager.username
  password ||= CredentialsManager::PasswordManager.shared_manager.password

  result = visit ITUNESCONNECT_URL
  raise "Could not open iTunesConnect" unless result['status'] == 'success'

  sleep 3
  
  if page.has_content?"My Apps"
    # Already logged in
    return true
  end

  begin
    wait_for_elements('#accountpassword')
  rescue => ex
    # when the user is already logged in, this will raise an exception
  end

  fill_in "accountname", with: user
  fill_in "accountpassword", with: password

  begin
    (wait_for_elements(".enabled").first.click rescue nil) # Login Button
    wait_for_elements('.homepageWrapper.ng-scope')
    
    if page.has_content?"My Apps"
      # Everything looks good
    else
      raise ItunesConnectLoginError.new("Looks like your login data was correct, but you do not have access to the apps.")
    end
  rescue => ex
    Helper.log.debug(ex)
    raise ItunesConnectLoginError.new("Error logging in user #{user} with the given password. Make sure you entered them correctly.")
  end

  Helper.log.info "Successfully logged into iTunesConnect"

  true
rescue => ex
  error_occured(ex)
end