class Phonegap::Connection

Public Class Methods

new(*auth) click to toggle source
# File lib/phonegap-api/base.rb, line 11
def initialize(*auth)
  if auth.any?
    @auth = {:basic_auth => auth.first}
  else
    @auth = {:basic_auth => YAML.load_file("config/phonegap.yml")}
  end
end

Public Instance Methods

apps() click to toggle source
# File lib/phonegap-api/read.rb, line 7
def apps
  Apps.new(self.get("/apps"))
end
check_response!(output) click to toggle source
# File lib/phonegap-api/base.rb, line 39
def check_response!(output)
  raise APIError, output['error'] if output['error'].class == String
  
  output
end
create_app(params) click to toggle source
# File lib/phonegap-api/write.rb, line 4
def create_app(params)
  self.post("/apps", params)
end
delete(url) click to toggle source
# File lib/phonegap-api/base.rb, line 34
def delete(url)
  output = self.class.delete(url, @auth)
  check_response!(output).parsed_response
end
delete_app(app_id) click to toggle source
# File lib/phonegap-api/write.rb, line 8
def delete_app(app_id)
  self.delete("/apps/#{app_id}")
end
get(url) click to toggle source
# File lib/phonegap-api/base.rb, line 19
def get(url)
  output = self.class.get(url, @auth)
  check_response!(output).parsed_response
end
get_app(app_id) click to toggle source
# File lib/phonegap-api/read.rb, line 11
def get_app(app_id)
  App.new(self.get("/apps/#{app_id}"))
end
get_icon(app_id) click to toggle source
# File lib/phonegap-api/read.rb, line 15
def get_icon(app_id)
  self.get("/apps/#{app_id}/icon")
end
get_key(platform, key_id) click to toggle source
# File lib/phonegap-api/read.rb, line 33
def get_key(platform, key_id)
  raise UnsupportedPlatformError unless SUPPORTED_PLATFORMS.include?(platform)
  self.get("/keys/#{platform}/#{key_id}")
end
get_package_url(app_id, platform) click to toggle source
# File lib/phonegap-api/read.rb, line 19
def get_package_url(app_id, platform)
  raise UnsupportedPlatformError unless SUPPORTED_PLATFORMS.include?(platform)
  self.get("/apps/#{app_id}/#{platform}")['location']
end
keys() click to toggle source
# File lib/phonegap-api/read.rb, line 24
def keys
  self.get("/keys")
end
keys_for_platform(platform) click to toggle source
# File lib/phonegap-api/read.rb, line 28
def keys_for_platform(platform)
  raise UnsupportedPlatformError unless SUPPORTED_PLATFORMS.include?(platform)
  self.get("/keys/#{platform}")
end
me() click to toggle source
# File lib/phonegap-api/read.rb, line 3
def me
  self.get("/me")
end
post(url, body) click to toggle source
# File lib/phonegap-api/base.rb, line 24
def post(url, body)
  output = self.class.post(url, @auth.merge!({:body =>{:data => body}}))
  check_response!(output).parsed_response
end
put(url, body) click to toggle source
# File lib/phonegap-api/base.rb, line 29
def put(url, body)
  output = self.class.put(url, @auth.merge!({:body =>{:data => body}}))
  check_response!(output).parsed_response
end