Skip to content

Instantly share code, notes, and snippets.

@lacostej
Last active November 16, 2015 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lacostej/ed2cf99ad55ccbe1b675 to your computer and use it in GitHub Desktop.
Save lacostej/ed2cf99ad55ccbe1b675 to your computer and use it in GitHub Desktop.
iTunesConnect - Updating MarketingURL and Support URL using spaceship
require 'spaceship'
user = ...
password = ...
Spaceship.login(user, password)
Spaceship::Tunes.login(user, password)
all_apps = Spaceship::Tunes::Application.all
def for_all_versions(app, &block)
puts "Dealing with #{app.name} #{app.platform}"
return if app.platform.nil? # skip uncomplete bundles
[app.live_version, app.edit_version].reject { |c| c.nil? }.each { |av|
puts "Dealing with #{app.name} #{app.platform} #{av.version}"
begin
block.call(av)
rescue => e
puts "Couldn't update... #{e}"
end
}
true
end
def update_support_url(app)
for_all_versions(app) {|av| update_version_support_url(av)}
end
def update_version_support_url(version)
modified=false
version.languages.each { |l|
if l['supportURL']['value'] != 'http://support.dragonbox.com'
l['supportURL']['value'] = 'http://support.dragonbox.com'
puts "Modified for #{l['language']}"
modified = true
end
}
if modified
puts "Saving..."
version.save!
end
end
MARKETING_URLS= {
'1005050125'=> 'http://dragonbox.com/numbers',
'634444186' => 'http://dragonbox.com/algebra#12+',
'1050385026' => 'http://dragonbox.com/numbers',
'522069155' => 'http://dragonbox.com/algebra#5+',
'875267105' => 'http://dragonbox.com/elements',
#'524970998' => 'http://dragonbox.com/algebra#12+', # DragonBox
'905001594' => 'http://dragonbox.com/algebra', # Lite
'840134991' => 'http://dragonbox.com/algebra', # EDU
'1040536593' => 'http://dragonbox.com/numbers',
'524967552' => 'http://dragonbox.com/algebra#5+',
'813681744' => 'http://dragonbox.com/algebra#12+',
'880047992' => 'http://dragonbox.com/elements'
#'928439953' => 'http://dragonbox.com/',
#'928417389' => 'http://dragonbox.com/',
#'928410442' => 'http://dragonbox.com/',
#'928444013' => 'http://dragonbox.com/'
}
def display_marketing_url(app)
for_all_versions(app) {|av| display_version_marketing_url(av) }
end
def display_version_marketing_url(version)
newURL=MARKETING_URLS[version.application.apple_id]
return if newURL.nil?
modified=false
version.languages.each { |l|
if l['marketingURL']['value'] != newURL
l['marketingURL']['value'] = newURL
puts "Modified to #{newURL} for #{l['language']}"
modified = true
end
}
if modified
puts "Saving..."
version.save!
end
end
all_apps.each {|a| update_support_url(a) } && true
all_apps.each {|a| display_marketing_url(a) } && true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment