lib/3scale_api/3scale/api.rb in 3scale_api-1.0.12 vs lib/3scale_api/3scale/api.rb in 3scale_api-1.0.13

- old
+ new

@@ -99,10 +99,23 @@ :service_plan_id => plan.css("service_id").text } end end + def get_service_plans_by_ + results = Array.new + response = @conn.get "/admin/api/application_plans.xml", {:provider_key => @provider_key } + xml = Nokogiri::XML(response.body) + plans = xml.xpath("//plans/plan") + plans = plans.map do |plan| + { + :name => plan.css("name").text, + :service_plan_id => plan.css("service_id").text + } + end + end + def get_services results = Array.new response = @conn.get "/admin/api/services.xml", {:provider_key => @provider_key } xml = Nokogiri::XML(response.body) services = xml.xpath("//services/service") @@ -191,7 +204,21 @@ response = @conn.put "/admin/api/accounts/#{account_id}/users/#{user_id}/member.xml", { :provider_key => @provider_key} response.status == 201 end + def load_application_data(account_id, application_id) + response = @conn.get "/admin/api/accounts/#{account_id}/applications/#{application_id}.xml",{ + :provider_key => @provider_key} + return false if response.status != 200 + xml = Nokogiri::XML(response.body) + application_data = {:keys => Array.new} + xml.xpath("//keys/key").map do |key| + application_data[:keys].push key.text + end + application_data[:app_id] = xml.css("application application_id").text + application_data[:name] = xml.css("application name").text + application_data[:description] = xml.css("application description").text + application_data + end end end