Created
August 13, 2013 21:31
-
-
Save scalone/6225892 to your computer and use it in GitHub Desktop.
This file contains 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
def get_app | |
@request = nil | |
url = URI.parse("http://cloudwalk-manager-staging.herokuapp.com/api/users/token.json?email=#{@edit_text_email.text}&password=#{@edit_text_password.text}") | |
posxml_execute_thread { @request = Net::HTTP.post_form(url, {})} | |
loop do | |
break if @request != nil | |
end | |
parsed = JSON.parse(@request.body) | |
api_token = parsed[0]["api_token"].chomp | |
@request2 = nil | |
url2 = URI.parse("http://cloudwalk-manager-staging.herokuapp.com/api/logical_numbers/#{@numeroLogico}.json?access_token=#{api_token}") | |
posxml_execute_thread { @request2 = Net::HTTP.get_response(url2) } | |
loop do | |
break if @request2 != nil | |
end | |
parsed2 = JSON.parse(@request2.body) | |
@app_list_ids = [] | |
@app_hash_list = {} | |
@app_list_ids = parsed2["logical_number"]["app_ids"] | |
arq_config = File.new(@file_config_init, "w+") | |
@app_list_ids.each do |application_id| | |
@request3 = nil | |
@app_list_info = {} | |
url3 = URI.parse("http://cloudwalk-manager-staging.herokuapp.com/api/apps/#{application_id}.json?access_token=#{api_token}") | |
posxml_execute_thread { @request3 = Net::HTTP.get_response(url3) } | |
loop do | |
break if @request3 != nil | |
end | |
parsed3 = JSON.parse(@request3.body) | |
app_info = {} | |
app_info["name"] = parsed3["app"]["name"] | |
app_info["posxml"] = Base64.decode64(parsed3["app"]["posxml"]) | |
app_info["displayable"] = parsed3["app"]["displayable"] | |
app_info["pos_display_label"] = parsed3["app"]["pos_display_label"] | |
@app_list_info["application_id"] = app_info | |
arq = File.new("#{app_info["name"]}" , "w+") | |
arq.write("#{app_info["posxml"]}") | |
arq.close | |
app_info["displayable"] == true ? arq_config.write("*") : arq_config.write("$") | |
arq_config.write(app_info) | |
arq_config.write("\n") | |
end | |
arq_config.close | |
self.content_view = | |
linear_layout :orientation => :vertical do | |
button :text => 'Executar App', :width => :match_parent, :id => 59, :on_click_listener => check_if_exist_posxml | |
end | |
rescue Exception | |
# return_toast_msg("#{$!}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment