class ADCDownload::Client
Attributes
Public Class Methods
hostname()
click to toggle source
# File lib/adcdownload/client.rb, line 5 def self.hostname "https://developer.apple.com/services-account/#{PROTOCOL_VERSION}/" end
Public Instance Methods
api_key()
click to toggle source
Fetches the latest API Key from the Apple Dev Portal
# File lib/adcdownload/client.rb, line 10 def api_key cache_path = "/tmp/spaceship_api_key.txt" begin cached = File.read(cache_path) rescue Errno::ENOENT end return cached if cached landing_url = "https://developer.apple.com/account/" logger.info("GET: " + landing_url) response = @client.get(landing_url) headers = response.headers results = headers['location'].match(/.*appIdKey=(\h+)/) if (results || []).length > 1 api_key = results[1] File.write(cache_path, api_key) if api_key.length == 64 return api_key else raise "Could not find latest API Key from the Dev Portal - the server might be slow right now" end end