Skip to content

Instantly share code, notes, and snippets.

@melito
Created February 19, 2009 19:47
Show Gist options
  • Save melito/67081 to your computer and use it in GitHub Desktop.
Save melito/67081 to your computer and use it in GitHub Desktop.
gem 'mechanize', '>=0.9.0'
require 'mechanize'
###
# Log in to itunes connect, get the list of applications.
#
# Example:
#
# ITunesConnect.new do |client|
# client.login '[email protected]', 'password'
# client.applications.each do |app|
# puts "#{app.name}: #{app.status}"
# end
# end
#
class ITunesConnect
Application = Struct.new(:name, :status, :submitted_on)
def initialize
@agent = WWW::Mechanize.new
@home_page = nil
yield self if block_given?
end
def login username, password
page = @agent.get('http://itunesconnect.apple.com/')
form = page.form('appleConnectForm')
form.theAccountName = username
form.theAccountPW = password
@home_page = form.submit(form.buttons.first)
end
def applications
apps_page = @home_page.link_with(:text => /manage your/i).click
apps_page.parser.css('table.app-details').map do |table|
name = table.at('./tr/td[1]').inner_text.strip
status = table.at('span.status').next.next.next.content.strip
table.at('.//td[contains(., "Date Submitted")]').inner_text =~ /Date Submitted:\s*(\d+\s\w+\s\d+)/
submitted = $1
Application.new(name, status, submitted)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment