Created
January 6, 2009 18:22
-
-
Save tenderlove/43930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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